From nobody@FreeBSD.org Sun May 24 12:55:51 2009 Return-Path: Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id A73C6106564A for ; Sun, 24 May 2009 12:55:51 +0000 (UTC) (envelope-from nobody@FreeBSD.org) Received: from www.freebsd.org (www.freebsd.org [IPv6:2001:4f8:fff6::21]) by mx1.freebsd.org (Postfix) with ESMTP id 95BB18FC26 for ; Sun, 24 May 2009 12:55:51 +0000 (UTC) (envelope-from nobody@FreeBSD.org) Received: from www.freebsd.org (localhost [127.0.0.1]) by www.freebsd.org (8.14.3/8.14.3) with ESMTP id n4OCtpv5001330 for ; Sun, 24 May 2009 12:55:51 GMT (envelope-from nobody@www.freebsd.org) Received: (from nobody@localhost) by www.freebsd.org (8.14.3/8.14.3/Submit) id n4OCtoqL001311; Sun, 24 May 2009 12:55:50 GMT (envelope-from nobody) Message-Id: <200905241255.n4OCtoqL001311@www.freebsd.org> Date: Sun, 24 May 2009 12:55:50 GMT From: Frank van den Boom To: freebsd-gnats-submit@FreeBSD.org Subject: choose / adjust the booting slice doesn't work with boot0cfg -s disk X-Send-Pr-Version: www-3.1 X-GNATS-Notify: >Number: 134907 >Category: bin >Synopsis: boot0cfg(8): choose / adjust the booting slice doesn't work with boot0cfg -s disk >Confidential: no >Severity: non-critical >Priority: medium >Responsible: vwe >State: feedback >Quarter: >Keywords: >Date-Required: >Class: sw-bug >Submitter-Id: current-users >Arrival-Date: Sun May 24 13:00:03 UTC 2009 >Closed-Date: >Last-Modified: Tue Sep 7 07:20:02 UTC 2010 >Originator: Frank van den Boom >Release: 7.2 >Organization: >Environment: FreeBSD 7.2-RELEASE FreeBSD 7.2-RELEASE #0: Fri May 1 07:18:07 UTC 2009 root@driscoll.cse.buffalo.edu:/usr/obj/src/sys/GENERIC amd64 >Description: choose / adjust the booting slice doesn't work with: boot0cfg -s disk on the next boot >How-To-Repeat: - divide a disk into two sclices - install FreeBSD 7.2 RELEASE on slice 1 - reboot - install FreeBSD 7.2 RELEASE on the other slice - start FreeBSD (for example slice one; chosen by the FreeBSD bootmanager) - to select from which disk and slice is booted (example boot0cfg -s2 da0) - reboot - u can see that slice two (F2) is selected - BUT FreeBSD starts from slice 1 >Fix: >Release-Note: >Audit-Trail: State-Changed-From-To: open->feedback State-Changed-By: vwe State-Changed-When: Tue Jun 16 21:50:05 UTC 2009 State-Changed-Why: Frank, by any chance, have you set '-o noupdate' to boot0? Can you please show us the output of `boot0cfg -v {dev}'? Responsible-Changed-From-To: freebsd-bugs->vwe Responsible-Changed-By: vwe Responsible-Changed-When: Tue Jun 16 21:50:05 UTC 2009 Responsible-Changed-Why: track http://www.freebsd.org/cgi/query-pr.cgi?pr=134907 From: Frank van den Boom To: bug-followup@FreeBSD.org, frank@am-knie.de Cc: Subject: Re: bin/134907: boot0cfg(8): choose / adjust the booting slice doesn't work with boot0cfg -s disk Date: Fri, 19 Jun 2009 18:23:54 -0700 First of all, thank you for your efforts! >Frank, >by any chance, have you set '-o noupdate' to boot0? No. >Can you please show us the output of `boot0cfg -v {dev}'? Output: boot0cfg -v /dev/da0 # flag start chs type end chs offset size 1 0x80 0: 1: 1 0xa5 1023:254:63 63 61432497 2 0x00 1023:255:63 0xa5 1023:254:63 61432560 64388520 version=1.0 drive=0x80 mask=0xf ticks=182 bell=# (0x23) options=packet,update,nosetdrv default_selection=F1 (Slice 1) Output: fdisk ******* Working on device /dev/da0 ******* parameters extracted from in-core disklabel are: cylinders=7832 heads=255 sectors/track=63 (16065 blks/cyl) Figures below won't work with BIOS for partitions not in cyl 1 parameters to be used for BIOS calculations are: cylinders=7832 heads=255 sectors/track=63 (16065 blks/cyl) Media sector size is 512 Warning: BIOS sector numbering starts with sector 1 Information from DOS bootblock is: The data for partition 1 is: sysid 165 (0xa5),(FreeBSD/NetBSD/386BSD) start 63, size 61432497 (29996 Meg), flag 80 (active) beg: cyl 0/ head 1/ sector 1; end: cyl 1023/ head 254/ sector 63 The data for partition 2 is: sysid 165 (0xa5),(FreeBSD/NetBSD/386BSD) start 61432560, size 64388520 (31439 Meg), flag 0 beg: cyl 1023/ head 255/ sector 63; end: cyl 1023/ head 254/ sector 63 The data for partition 3 is: The data for partition 4 is: Output slice 1: df -h Filesystem Size Used Avail Capacity Mounted on /dev/da0s1a 484M 224M 221M 50% / devfs 1.0K 1.0K 0B 100% /dev /dev/da0s1h 12G 4.0K 11G 0% /home /dev/da0s1g 484M 12K 445M 0% /tmp /dev/da0s1f 14G 1.4G 12G 10% /usr /dev/da0s1e 484M 402K 445M 0% /var Output slice 2: df -h Filesystem Size Used Avail Capacity Mounted on /dev/da0s2a 484M 224M 221M 50% / devfs 1.0K 1.0K 0B 100% /dev /dev/da0s2g 14G 4.0K 13G 0% /home /dev/da0s2f 484M 12K 445M 0% /tmp /dev/da0s2e 14G 1.4G 12G 10% /usr /dev/da0s2d 484M 296K 445M 0% /var Output: uname -a FreeBSD 7.2-RELEASE FreeBSD 7.2-RELEASE #0: Fri May 1 07:18:07 UTC 2009 root@driscoll.cse.buffalo.edu:/usr/obj/usr/src/sys/GENERIC amd64 From: Brian Somers To: bug-followup@FreeBSD.org, frank@am-knie.de Cc: Subject: Re: bin/134907: boot0cfg(8): choose / adjust the booting slice doesn't work with boot0cfg -s disk Date: Tue, 23 Jun 2009 04:16:13 -0700 --Sig_/fol4OLRnzgDkB+qw5+Vq_YU Content-Type: multipart/mixed; boundary="MP_/7mtcgNJ1KkBP8UxZa0p78Gs" --MP_/7mtcgNJ1KkBP8UxZa0p78Gs Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: quoted-printable Content-Disposition: inline I'll interject here as I've just spent some time in this code... I hope I'm not stepping on anyone's toes. Hopefully there isn't an issue with running on amd64, but assuming this isn't the case, can you run: dd if=3D/dev/ad0 count=3D1 | hexdump -C | sed -ne 1p -e '/01b0/p' Here, this will show something like this: 00000000 fc 31 c0 8e c0 8e d8 8e d0 bc 00 7c 89 e6 bf 00 |.1.........|..= ..| 000001b0 90 90 44 72 69 76 65 20 00 00 80 83 37 00 80 01 |..Drive ....7..= .| The important parts are: - The first 12 bytes - "MAGIC" for boot0cfg. I'd expect them to be correct, otherwise boot0cfg would be whinging. - The "Drive " bytes - also "MAGIC". Again, I'd expect them to be correct for the same reason. - byte 1b9: The boot slice (base 0). You should see this byte changing as you use -s1 (value 0), -s2 (value 1), -s3 (value 2). So if all's good so far, check that you haven't got a dodgy /boot.config on s1a or s2a. Once the MBR runs the bottom half of the loader, this file will be used to override what's actually booted. I suspect everything will be fine.... but please check before trying the attached patch. I have different boot code here where I store more than just the boot slice at offset 0x1b9. In my modified boot code, I had to disable the ORing of $NOUPDATE, otherwise for some reason that still escapes me, the boot partition that was stored in %al (or was it %cl) was ending up incorrect. It's entirely possible that this patch will do nothing useful, but I think it's worth trying... given that everything else looks sane! Thanks. --=20 Brian Somers Don't _EVER_ lose your sense of humour ! --MP_/7mtcgNJ1KkBP8UxZa0p78Gs Content-Type: text/x-patch Content-Transfer-Encoding: quoted-printable Content-Disposition: attachment; filename=boot0.patch Index: boot0.S =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D RCS file: /home/ncvs/src/sys/boot/i386/boot0/boot0.S,v retrieving revision 1.16.2.2 diff -u -r1.16.2.2 boot0.S --- boot0.S 13 Jan 2009 22:28:48 -0000 1.16.2.2 +++ boot0.S 23 Jun 2009 11:05:34 -0000 @@ -373,7 +373,7 @@ * Timed out or default selection */ use_default: movb _OPT(%bp),%al # Load default - orb $NOUPDATE,_FLAGS(%bp) # Disable updates + #orb $NOUPDATE,_FLAGS(%bp) # Disable updates jmp check_selection # Join common code =20 /* --MP_/7mtcgNJ1KkBP8UxZa0p78Gs-- --Sig_/fol4OLRnzgDkB+qw5+Vq_YU Content-Type: application/pgp-signature; name=signature.asc Content-Disposition: attachment; filename=signature.asc -----BEGIN PGP SIGNATURE----- Version: GnuPG v2.0.11 (FreeBSD) iQCVAwUBSkC5jw7tvOdmanQhAQLYqgP/Szx6SUwsjLW30Dr74c9UnD5SCH202eK5 kV7A8iTm5LjBrjpmAHepKwHmkI6EO6oi2pF1kqQQeI1ArMFcTyx/tiQWBb4YU4eW QTJVrk6sCI27LrcYqLnL3psWCeGpTYfM5mWTb9iszRiyvDvbPx/7OsbdB5EgewuX TZNq1ewvixM= =ln86 -----END PGP SIGNATURE----- --Sig_/fol4OLRnzgDkB+qw5+Vq_YU-- From: Dmitry Pryanishnikov To: bug-followup@FreeBSD.org, Brian Somers Cc: frank@am-knie.de Subject: Re: bin/134907: boot0cfg(8): choose / adjust the booting slice doesn't work with boot0cfg -s disk Date: Thu, 17 Sep 2009 22:20:30 +0300 Hello! > From: Brian Somers > Date: Tue, 23 Jun 2009 04:16:13 -0700 > I have different boot code here where I store more than just the boot > slice at offset 0x1b9. In my modified boot code, I had to disable the > ORing of $NOUPDATE, otherwise for some reason that still escapes > me, the boot partition that was stored in %al (or was it %cl) was > ending up incorrect. I'm facing with the same problem: after doing 'boot0cfg -s 4 ad0' (from the 7.2-STABLE booted from ad0s3, active slice=ad0s3), both 'boot0cfg -v' and hd confirm that the _OPT's contents set up correctly (I'm using CFLAGS+= -DVOLUME_SERIAL in /sys/boot/i386/boot0, so _OPT offset is 0x1b5 for me).BUT! when I reboot with this setting (*), boot0 correctly shows default=F4 (6.4-RELEASE is on ad0s4), however after timeout boots the 7.2-STABLE from ad0s3.This result changes only when I actually press F4 (not waiting for keypress timeout) - this time system boots from ad0s4, and _after this_ default starts to work (**): next time after keypress timeout system boots actually from ad0s4. So, what's the difference between MBR contents in points (*) and (**)? Only the active partition flag (0x80 vs 0x0) in partition table: at (*) the active partition is still ad0s3, while at (**) it's ad0s4. So it seems that this ORing of $NOUPDATE is actual cause of the problem: boot0 code always updates partition table, so selected partition becomes active, but just doesn't save the result back to HDD in case of keypress timeout. I'm not sure whether this issue depends on BIOS (my MB is Intel D975XBX2) or on the secondary bootstrap code, but it definitely should be fixed. I don't see the point of the 'orb $NOUPDATE' below use_default: movb _OPT(%bp),%al # Load default orb $NOUPDATE,_FLAGS(%bp) # Disable updates but it seems that it's actually causing the problem. Sincerely, Dmitry -- nic-hdl: LYNX-RIPE From: David Wolfskill To: bug-followup@FreeBSD.org Cc: Subject: Re: bin/134907: boot0cfg<8>: choose / adjust the booting slice doesn't work with boot0cfg -s disk Date: Sun, 9 May 2010 10:09:18 -0700 --pBxr27OvcVUkmud5 Content-Type: text/plain; charset=iso-8859-1 Content-Disposition: inline Content-Transfer-Encoding: quoted-printable After several years of using boot0cfg(8) to flip machines from one bootable slice to another without problems, I started seeing the symptoms cited in this PR at work; a circumvention (in that case) was to "reinforce" the default selection by augmenting it by pressing the function key corresponding to the (allegedly) "default" selection. I has assumed(!) that perhaps this was because of something wonky on the RAID controller on these machines. Then I started seeing the same thing at home, on a recently-obtained, refurbished Dell Optiplex machine, and thought I'd try to find out what's going on -- and found the PR. Following the suggestion to inspect the first sector of the boot drive, here are 3 samples. The first 2 work; the 3rd exhibits the cited symptoms ... and also exhibits what looks to me to be an anomaly in the sector in question: My laptop: g1-199(9.0-C)[1] df / Filesystem 1K-blocks Used Avail Capacity Mounted on /dev/ad0s4a 1519502 491996 905946 35% / g1-199(9.0-C)[2] sudo boot0cfg -v /dev/ad0 # flag start chs type end chs offset size 1 0x00 0: 1: 1 0xa5 1023: 3:63 63 10474317 2 0x00 1023:255:63 0xa5 1023: 7:63 10474380 10474380 3 0x00 1023:255:63 0xa5 1023: 11:63 20948760 10474380 4 0x80 1023:255:63 0xa5 1023: 14:63 31423140 203013405 version=3D1.0 drive=3D0x80 mask=3D0xf ticks=3D182 bell=3D (0x7) options=3Dpacket,update,nosetdrv default_selection=3DF4 (Slice 4) g1-199(9.0-C)[3] sudo dd if=3D/dev/ad0 count=3D1 | hd | sed -ne 1p -e '/01b= 0/p' Password: 1+0 records in 1+0 records out 512 bytes transferred in 0.025182 secs (20332 bytes/sec) 00000000 fc 31 c0 8e c0 8e d8 8e d0 bc 00 7c 89 e6 bf 00 |.1.........|..= ..| 000001b0 66 bb 44 72 69 76 65 20 00 03 80 8f b6 00 00 01 |f.Drive ......= ..| g1-199(9.0-C)[4]=20 My build machine: freebeast(8.0-S)[1] df / Filesystem 1K-blocks Used Avail Capacity Mounted on /dev/aacd0s3a 1482638 326566 1037462 24% / freebeast(8.0-S)[2] sudo dd if=3D/dev/aacd0 count=3D1 | hd | sed -ne 1p -e = '/01b0/p'=20 Password: 1+0 records in 1+0 records out 512 bytes transferred in 0.015300 secs (33464 bytes/sec) 00000000 fc 31 c0 8e c0 8e d8 8e d0 bc 00 7c 89 e6 bf 00 |.1.........|..= ..| 000001b0 66 bb 44 72 69 76 65 20 b1 02 80 8f b6 00 00 01 |f.Drive ......= ..| freebeast(8.0-S)[3] sudo boot0cfg -v /dev/aacd0 # flag start chs type end chs offset size 1 0x00 0: 1: 1 0xa5 651:254:63 63 10474317 2 0x00 652: 0: 1 0xa5 1023:254:63 10474380 10474380 3 0x80 1023:255:63 0xa5 1023:254:63 20948760 10474380 4 0x00 1023:255:63 0xa5 1023:254:63 31423140 40194630 version=3D1.0 drive=3D0x80 mask=3D0xf ticks=3D182 bell=3D (0x7) options=3Dpacket,update,nosetdrv default_selection=3DF3 (Slice 3) freebeast(8.0-S)[4]=20 The new machine: albert(8.0-S)[1] df / Filesystem 1K-blocks Used Avail Capacity Mounted on /dev/ad4s2a 1519502 320620 1077322 23% / albert(8.0-S)[2] sudo dd if=3D/dev/ad4 count=3D1 | hd | sed -ne 1p -e '/01b= 0/p' Password: 1+0 records in 1+0 records out 512 bytes transferred in 0.011337 secs (45162 bytes/sec) 00000000 fc 31 c0 8e c0 8e d8 8e d0 bc 00 7c 89 e6 bf 00 |=FC1=C0.=C0.= =D8.=D0=BC.|.=E6=BF.| 000001b0 69 76 65 20 00 00 80 8f b1 00 80 83 b6 00 00 01 |ive ....=B1...= =B6...| albert(8.0-S)[3] sudo boot0cfg -v /dev/ad4 # flag start chs type end chs offset size 1 0x00 0: 1: 1 0xa5 1023: 15:63 63 10485153 2 0x80 1023:255:63 0xa5 1023: 15:63 10485216 10485216 3 0x00 1023:255:63 0xa5 1023: 15:63 20970432 467426736 version=3D2.0 drive=3D0x80 mask=3D0xf ticks=3D182 bell=3D# (0x23) options=3Dpacket,update,nosetdrv volume serial ID b100-8083 default_selection=3DF1 (Slice 1) albert(8.0-S)[4]=20 If it would be useful, I can get similar information from the oddball machines aty work Peace, david --=20 David H. Wolfskill david@catwhisker.org Depriving a girl or boy of an opportunity for education is evil. See http://www.catwhisker.org/~david/publickey.gpg for my public key. --pBxr27OvcVUkmud5 Content-Type: application/pgp-signature Content-Disposition: inline -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.0 (FreeBSD) iEUEARECAAYFAkvm7D0ACgkQmprOCmdXAD0pEQCYlBHXvRgFSwYxVZG+z9lr+Cve 9QCfdxe/w/ulskEbZ/DZN8+60i5oMh4= =4jGH -----END PGP SIGNATURE----- --pBxr27OvcVUkmud5-- From: Tsurutani Naoki To: bug-followup@FreeBSD.org, frank@am-knie.de Cc: Subject: Re: bin/134907: boot0cfg(8): choose / adjust the booting slice doesn't work with boot0cfg -s disk Date: Tue, 07 Sep 2010 16:18:31 +0900 Hi, I think this problem should be fixed ASAP. Mr. Brian's patch should be applied, to remove inconsistency between boot0's boot slice and active partition; even if "noupdate" option is set, information about active partition shold be updated. Otherwise, we should update it through boot0cfg(8). BTW, I do not know why setting "update" option can avoid this... >Unformatted: