Skip site navigation (1)Skip section navigation (2)
Date:      Sat, 24 Nov 2001 01:28:29 +1100 (EST)
From:      Bruce Evans <bde@zeta.org.au>
To:        John Baldwin <jhb@FreeBSD.org>
Cc:        Peter Wemm <peter@wemm.org>, <cvs-committers@FreeBSD.org>, <cvs-all@FreeBSD.org>
Subject:   Re: cvs commit: src/sys/kern subr_diskmbr.c
Message-ID:  <20011123234342.I5572-100000@delplex.bde.org>
In-Reply-To: <XFMail.011121122618.jhb@FreeBSD.org>

next in thread | previous in thread | raw e-mail | index | archive | help
On Wed, 21 Nov 2001, John Baldwin wrote:

> On 21-Nov-01 Peter Wemm wrote:
> > John Baldwin wrote:
> >> Eh?  Did you not kill DD mode in userland?
> >
> > Not quite.  The problem was that the alternate boot1 layout was not
> > recognized by subr_diskmbr.c as "dangerous" (and therefore ignored) so it
> > tried to interpret it and failed messily.
> >
> > disklabel -r -w ad1 auto
> > .. was failing apparently.  The whole DD thing still needs to be
> > resolved.
>
> That isn't supposed to work.  You don't write a disklabel to a hard drive on a
> PC, you write a MBR using 'fdisk'.  disklabel ad1 auto should fail.  Right now
> it does DD mode.

Erm, this is supposed to work.  It works for me, at least for md instead
of ad.  Test program:

%%%
SOMEFILE=/tmp/zz
cp /boot/boot1 ${SOMEFILE}
time dd if=/dev/zero of=${SOMEFILE} oseek=99999 count=1
mdconfig -a -t vnode -f ${SOMEFILE} -u 0
disklabel md0
disklabel -rw md0 auto
disklabel md0
mdconfig -d -u 0
%%%

The failure for old kernels is interesting.  The size of the BSD
compatibility slice is just 50000 intead of the size of disk because
the bogus MBR has a bogus size of 50000.  Labelling this slice using
"auto" should just work.  But it fails because disklabel(9) reads the
virgin label from a wrong device (/dev/md0 instead of /dev/md0c).
"disklabel -rw md0s4 auto" works correctly.  disklabel(8) still reads
the virgin label from a wrong device (/dev/md0s4 instead of /dev/md0s4c),
but this is only logically wrong since these devices are normally (and
initially always) physically identical.

> If you don't want it to fail, it should write a disklabel (not
> a MBR).  (If this is a non-boot disk in a FreeBSD only system this would be ok.)

Well, "disklabel -rw" writes a label only, but "disklabel -Brw md0"
writes boot blocks to /dev/md0c, wherever that is.  If md0 is empty,
then md0c is is the whole of md0 and boot1 gets written to the MBR.
On the next open after all minors on md0 are closed, the bogus partition
table in boot1 gets used.  I copied boot1 to the MBR explicitly in the
above test (just to get the bogus partition table and show that it
doesn't break "auto").

Bruce


To Unsubscribe: send mail to majordomo@FreeBSD.org
with "unsubscribe cvs-all" in the body of the message




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