Date: Fri, 23 Nov 2001 08:06:14 -0800 (PST) From: John Baldwin <jhb@FreeBSD.org> To: Bruce Evans <bde@zeta.org.au> Cc: cvs-all@FreeBSD.org, cvs-committers@FreeBSD.org, Peter Wemm <peter@wemm.org> Subject: Re: cvs commit: src/sys/kern subr_diskmbr.c Message-ID: <XFMail.011123080614.jhb@FreeBSD.org> In-Reply-To: <20011123234342.I5572-100000@delplex.bde.org>
next in thread | previous in thread | raw e-mail | index | archive | help
On 23-Nov-01 Bruce Evans wrote:
> 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").
Yes, I'm saying that this is wrong. :) boot1 shouldn't have a MBR in it. That
is the real layering violation. disklabel doesn't grok MBR's at all, rather,
we've hacked boot1 to provide a MBR when disklabel takes over a disk. Since
Peter has fixed the bug in it, it is now just ugly rather than broken as well.
It's still somewhat broken however as anything that tries to check such a
labeled disk and tries to find a valid MBR is going to choke.
> Bruce
--
John Baldwin <jhb@FreeBSD.org> <>< http://www.FreeBSD.org/~jhb/
"Power Users Use the Power to Serve!" - http://www.FreeBSD.org/
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?XFMail.011123080614.jhb>
