Skip site navigation (1)Skip section navigation (2)
Date:      Sun, 24 Jan 2010 20:41:22 -0600
From:      Robert Noland <rnoland@FreeBSD.org>
To:        Mark Andrews <marka@isc.org>
Cc:        John <john@starfire.mn.org>, "Thomas K." <fwd@gothschlampen.com>, Dan Naumov <dan.naumov@gmail.com>, freebsd-questions@freebsd.org, FreeBSD-STABLE Mailing List <freebsd-stable@freebsd.org>
Subject:   Re: Loader, MBR and the boot process
Message-ID:  <1264387282.2869.24.camel@balrog.2hip.net>
In-Reply-To: <201001242057.o0OKvHUE089237@drugs.dv.isc.org>
References:  <cf9b1ee01001211957j43a9d6a9j3d1e29d19aebf418@mail.gmail.com> <20100122041237.GA22312@gothschlampen.com> <cf9b1ee01001212049u6cffd8abo9efa380a8efa9609@mail.gmail.com> <cf9b1ee01001212102r70b88806m21b167a2aa833362@mail.gmail.com> <20100124092947.B72039@starfire.mn.org> <cf9b1ee01001240759j2476cf3es2babd8b32a90f9aa@mail.gmail.com> <201001242057.o0OKvHUE089237@drugs.dv.isc.org>

next in thread | previous in thread | raw e-mail | index | archive | help
On Mon, 2010-01-25 at 07:57 +1100, Mark Andrews wrote:
> In message <cf9b1ee01001240759j2476cf3es2babd8b32a90f9aa@mail.gmail.com>, Dan N
> aumov writes:
> > On Sun, Jan 24, 2010 at 5:29 PM, John <john@starfire.mn.org> 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 <dan.naumov@gmail.com> wrote=
> > :
> > >> > On Fri, Jan 22, 2010 at 6:12 AM, Thomas K. <fwd@gothschlampen.com> 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 <rnoland@FreeBSD.org>
FreeBSD




Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?1264387282.2869.24.camel>