From owner-freebsd-questions@FreeBSD.ORG Mon Jan 25 02:58:12 2010 Return-Path: Delivered-To: freebsd-questions@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 891001065670; Mon, 25 Jan 2010 02:58:12 +0000 (UTC) (envelope-from rnoland@FreeBSD.org) Received: from gizmo.2hip.net (gizmo.2hip.net [64.74.207.195]) by mx1.freebsd.org (Postfix) with ESMTP id 588158FC0A; Mon, 25 Jan 2010 02:58:12 +0000 (UTC) Received: from [192.168.1.4] (adsl-157-36-161.bna.bellsouth.net [70.157.36.161]) (authenticated bits=0) by gizmo.2hip.net (8.14.3/8.14.3) with ESMTP id o0P2w7kb080850 (version=TLSv1/SSLv3 cipher=DHE-RSA-CAMELLIA256-SHA bits=256 verify=NO); Sun, 24 Jan 2010 21:58:09 -0500 (EST) (envelope-from rnoland@FreeBSD.org) From: Robert Noland To: Mark Andrews In-Reply-To: <201001242057.o0OKvHUE089237@drugs.dv.isc.org> References: <20100122041237.GA22312@gothschlampen.com> <20100124092947.B72039@starfire.mn.org> <201001242057.o0OKvHUE089237@drugs.dv.isc.org> Content-Type: text/plain Organization: FreeBSD Date: Sun, 24 Jan 2010 20:41:22 -0600 Message-Id: <1264387282.2869.24.camel@balrog.2hip.net> Mime-Version: 1.0 X-Mailer: Evolution 2.26.3 FreeBSD GNOME Team Port Content-Transfer-Encoding: 7bit X-Spam-Status: No, score=-0.5 required=5.0 tests=AWL,BAYES_00, FH_DATE_PAST_20XX,RCVD_IN_PBL,RDNS_DYNAMIC,SPF_SOFTFAIL autolearn=no version=3.2.5 X-Spam-Checker-Version: SpamAssassin 3.2.5 (2008-06-10) on gizmo.2hip.net X-Mailman-Approved-At: Mon, 25 Jan 2010 04:04:20 +0000 Cc: John , "Thomas K." , Dan Naumov , freebsd-questions@freebsd.org, FreeBSD-STABLE Mailing List Subject: Re: Loader, MBR and the boot process X-BeenThere: freebsd-questions@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: User questions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 25 Jan 2010 02:58:12 -0000 On Mon, 2010-01-25 at 07:57 +1100, Mark Andrews wrote: > In message , Dan N > aumov writes: > > On Sun, Jan 24, 2010 at 5:29 PM, John wrote: > > > On Fri, Jan 22, 2010 at 07:02:53AM +0200, Dan Naumov wrote: > > >> On Fri, Jan 22, 2010 at 6:49 AM, Dan Naumov wrote= > > : > > >> > On Fri, Jan 22, 2010 at 6:12 AM, Thomas K. wro= > > te: > > >> >> On Fri, Jan 22, 2010 at 05:57:23AM +0200, Dan Naumov wrote: > > >> >> > > >> >> Hi, > > >> >> > > >> >>> I recently found a nifty "FreeBSD ZFS root installation script" and > > >> >>> been reworking it a bit to suit my needs better, including changing = > > it > > >> >>> from GPT to MBR partitioning. However, I was stumped, even though I > > >> >>> had done everything right (or so I thought), the system would get > > >> >>> stuck at Loader and refuse to go anywhere. After trying over a dozen > > >> >> > > >> >> probably this line is the cause: > > >> >> > > >> >> dd if=3D/mnt2/boot/zfsboot of=3D/dev/"${TARGETDISK}"s1a skip=3D1 seek= > > =3D1024 > > >> >> > > >> >> Unless by "swap first" you meant the on-disk location, and not the > > >> >> partition letter. If swap is partition "a", you're writing the loader > > >> >> into swapspace. > > >> >> > > >> >> > > >> >> Regards, > > >> >> Thomas > > >> > > > >> > At first you made me feel silly, but then I decided to double-check, I > > >> > uncommented the swap line in the partitioning part again, ensured I > > >> > was writing the bootloader to "${TARGETDISK}"s1b and ran the script. > > >> > Same problem, hangs at loader. Again, if I comment out the swap, > > >> > giving the entire slice to ZFS and then write the bootloader to > > >> > "${TARGETDISK}"s1a, run the script, everything works. > > >> > > >> I have also just tested creating 2 slices, like this: > > >> > > >> gpart create -s mbr "${TARGETDISK}" > > >> gpart add -s 3G -t freebsd "${TARGETDISK}" > > >> gpart create -s BSD "${TARGETDISK}"s1 > > >> gpart add -t freebsd-swap "${TARGETDISK}"s1 > > >> > > >> gpart add -t freebsd "${TARGETDISK}" > > >> gpart create -s BSD "${TARGETDISK}"s2 > > >> gpart add -t freebsd-zfs "${TARGETDISK}"s2 > > >> > > >> gpart set -a active -i 2 "${TARGETDISK}" > > >> gpart bootcode -b /mnt2/boot/boot0 "${TARGETDISK}" > > >> > > >> > > >> and later: > > >> > > >> dd if=3D/mnt2/boot/zfsboot of=3D/dev/"${TARGETDISK}"s2 count=3D1 > > >> dd if=3D/mnt2/boot/zfsboot of=3D/dev/"${TARGETDISK}"s2a skip=3D1 seek=3D= > > 1024 > > >> > > >> > > >> Putting the swap into it's own slice and then putting FreeBSD into > > >> it's own slice worked fine. So why the hell can't they both coexist in > > >> 1 slice if the swap comes first? > > > > > > I know what the answer to this USED to be, but I don't know if it is > > > still true (obviously, I think so, I or wouldn't waste your time). > > > > > > The filesystem code is all carefully written to avoid the very > > > first few sector of the partition. =A0That's because the partition > > > table is there for the first filesystem of the slice (or disk). > > > That's a tiny amout of space wasted, because it's also skipped on > > > all the other filesystems even though there's not actually anything > > > there, but it was a small inefficency, even in the 70's. > > > > > > Swap does not behave that way. =A0SWAP will begin right at the slice > > > boundry, with 0 offset. =A0As long as it's not the first partition, no > > > harm, no foul. =A0If it IS the first partition, you just nuked your parti= > > tion > > > table. =A0As long as SWAP owns the slice, again, no harm, no foul, but > > > if there were filesystems BEHIND it, you just lost 'em. > > > > > > That's the way it always used to be, and I think it still is. =A0SWAP can > > > only be first if it is the ONLY thing using that slice (disk), otherwise, > > > you need a filesystem first to protect the partition table. > > > -- > > > > > > John Lind > > > john@starfire.MN.ORG > > > > This explanation does sound logical, but holy crap, if this is the > > case, you'd think there would be bells, whistles and huge red label > > warnings in EVERY FreeBSD installation / partitioning guide out there > > warning people to not put swap first (unless given a dedicated slice) > > under any circumstances. The warnings were nowhere to be seen and lots > > of pointy hair first greyed and were then lost during the process of > > me trying to figure out why my system would install but wouldn't boot. > > >From "man bsdlabel". > > offset The offset of the start of the partition from the beginning of > the drive in sectors, or * to have bsdlabel calculate the correct > offset to use (the end of the previous partition plus one, ignor- > ing partition `c'. For partition `c', * will be interpreted as > an offset of 0. The first partition should start at offset 16, > because the first 16 sectors are reserved for metadata. Ok, now this has my attention... My gut feeling right now is that this is a bug in geom_part_bsd. I don't understand why the label isn't protected. (Adding -b 16 when adding the swap partition fixes this) Another project to goes on my list... If anyone knows why this is done like this... please share. robert. > > - Sincerely, > > Dan Naumov > > _______________________________________________ > > freebsd-stable@freebsd.org mailing list > > http://lists.freebsd.org/mailman/listinfo/freebsd-stable > > To unsubscribe, send any mail to "freebsd-stable-unsubscribe@freebsd.org" -- Robert Noland FreeBSD