From owner-freebsd-embedded@FreeBSD.ORG Fri Aug 7 20:58:26 2009 Return-Path: Delivered-To: freebsd-embedded@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 2D90A106568C for ; Fri, 7 Aug 2009 20:58:26 +0000 (UTC) (envelope-from fb-embedded@psconsult.nl) Received: from mx1.psconsult.nl (psc11.adsl.iaf.nl [80.89.238.138]) by mx1.freebsd.org (Postfix) with ESMTP id A84C88FC23 for ; Fri, 7 Aug 2009 20:58:25 +0000 (UTC) Received: from mx1.psconsult.nl (localhost [80.89.238.138]) by mx1.psconsult.nl (8.14.2/8.14.2) with ESMTP id n77KwHxB084027 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO); Fri, 7 Aug 2009 22:58:22 +0200 (CEST) (envelope-from fb-embedded@psconsult.nl) Received: (from paul@localhost) by mx1.psconsult.nl (8.14.2/8.14.2/Submit) id n77KwH4v084026; Fri, 7 Aug 2009 22:58:17 +0200 (CEST) (envelope-from fb-embedded@psconsult.nl) Date: Fri, 7 Aug 2009 22:58:17 +0200 From: Paul Schenkeveld To: freebsd-embedded@freebsd.org Message-ID: <20090807205817.GA82868@psconsult.nl> Mail-Followup-To: freebsd-embedded@freebsd.org, freebsd-current@freebsd.org References: <3131aa530908070809l2ac13931xf65981db6eeb83e8@mail.gmail.com> <19068.18919.843159.936827@gromit.timing.com> <20090807.104414.221852486.imp@bsdimp.com> MIME-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: <20090807.104414.221852486.imp@bsdimp.com> User-Agent: Mutt/1.5.17 (2007-11-01) Cc: freebsd-current@freebsd.org Subject: Re: [NanoBSD] Can't use boot0cfg for changing the booting slice X-BeenThere: freebsd-embedded@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Dedicated and Embedded Systems List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 07 Aug 2009 20:58:26 -0000 On Fri, Aug 07, 2009 at 10:44:14AM -0600, M. Warner Losh wrote: > In message: <19068.18919.843159.936827@gromit.timing.com> > John Hein writes: > : Olivier Cochard-Labbé wrote at 17:09 +0200 on Aug 7, 2009: > : > I meet a problem under FreeBSD 7.2 and 8.0-current (nanoBSD) using > : > boot0cfg: I can't use boot0cfg for changing the booting slice. > : > Here is my problem: > : > I'm using the FreeBSD Boot manager on a system with MBR partitions. > : > The active slice is the partition 1, but I want to boot from the slice 2. > : > > : > Then I use boot0cfg like that: > : > > : > sysctl kern.geom.debugflags=16 > : > boot0cfg -s 2 -v /dev/ad0 > : > sysctl kern.geom.debugflags=0 > : > > : > But, after the reboot my system still reboot from the slice 1 (but the > : > boot loader show correctly that the default choice is now the 2)! > : > Where is my problem ? > : > : Are you sure you're booting from slice 1? > : Is fstab on slice 2 pointing to slice 1? > > Also, boot0cfg won't mark the slice as ACTIVE, just remember that was > the last slice you booted from... To mark it active, you must use > fdisk. If by 'active' you mean 'what mount reports root as' then I > think John's suggestion is right on the money... [I cc'ed freebsd-current as I feel this is a regression that really needs fixing before 8.0 comes out] Pre-7.2 world: boot0cfg changes the default slice to boot from by altering block0 byte at offset 0x1b9. Allowed values are 0-3 to boot from slice 1 thru 4 or 4 to boot from the next drive. Boot0 ignores the active flag in the MBR and only looks at the byte described above. 7.2-and-up world: boot0cfg still changes the same byte at 0x1b9 in block0 but boot0 seems to completely ignore this byte and boots from the slice marked active in the MBR. NanoBSD relies on the working of boot0cfg when upgrading, since 7.2 this just does not work any more. It seems that the original implementation of boot0 introduced the new way of storing the default slice to boot from to allow for other defaults than just slice 1 thru 4 which the active flag(s) in MBR allow. My personal opinion is that boot0 should either look at the byte at 0x1b9 or at the active flags. Since the active flags can only specify a default of 1 thru 4 and the design of MBR and the active flags is broken by design [1] I'd *really* like to see boot0 revert to the pre-7.2 behaviour. Hope this gets fixed before 8.0 comes out, leaving it the way it is renders boot0cfg and NanoBSD (which relies on boot0cfg) crippled and too difficult to use for all users not intimately acquainted with the way boot0cfg, the MBR record and boot0 interact. Unfortunately I'm not enough x86 assembly literate to understand the diffs between boot0.s in 7.1 and 7.2 to be able to produce a useful patch. [1] I have had installs of 8.0 snapshots that left MBR with more than one MBR slice marked active, BIOS subsequently completely rejected the disk and the only remedy was to manually fdisk -a from fixit mode using a live CD/DVD. This has happened with several recent Intel desktop boards like DG965RY and DP35DP. > Warner Regards, Paul Schenkeveld