matthew@ noticed that using 'disklabel -e' seems to lose the starting and ending bounds for the OpenBSD area on the disk. This is a result of getasciilabel() deliberately ignoring label fields that are forcibly set by the OS when the disklabel is read.
If you reboot or otherwise force the disklabel to be read from the disk the values would be restored. However it is unfortunate and possibly confusing. One approach to fix this is given in the diff below. Get the OS provided values and put them into the newly constructured label. Works for me. ok? .... Ken Index: disklabel.c =================================================================== RCS file: /cvs/src/sbin/disklabel/disklabel.c,v retrieving revision 1.179 diff -u -p -r1.179 disklabel.c --- disklabel.c 22 May 2011 13:05:47 -0000 1.179 +++ disklabel.c 2 Jun 2011 02:42:18 -0000 @@ -842,6 +842,7 @@ edit(struct disklabel *lp, int f) int first, ch, fd, error = 0; struct disklabel label; FILE *fp; + u_int64_t total_sectors, starting_sector, ending_sector; if ((fd = mkstemp(tmpfil)) == -1 || (fp = fdopen(fd, "w")) == NULL) { if (fd != -1) @@ -867,8 +868,18 @@ edit(struct disklabel *lp, int f) warn("%s", tmpfil); break; } + /* Get values set by OS and not the label. */ + if (ioctl(f, DIOCGPDINFO, &label) < 0) + err(4, "ioctl DIOCGPDINFO"); + ending_sector = DL_GETBEND(&label); + starting_sector = DL_GETBSTART(&label); + total_sectors = DL_GETDSIZE(&label); memset(&label, 0, sizeof(label)); error = getasciilabel(fp, &label); + DL_SETBEND(&label, ending_sector); + DL_SETBSTART(&label, starting_sector); + DL_SETDSIZE(&label, total_sectors); + if (error == 0) { if (cmplabel(lp, &label) == 0) { puts("No changes.");