From owner-cvs-all Fri Nov 23 8: 6:37 2001 Delivered-To: cvs-all@freebsd.org Received: from mail6.speakeasy.net (mail6.speakeasy.net [216.254.0.206]) by hub.freebsd.org (Postfix) with ESMTP id 58E5A37B41A for ; Fri, 23 Nov 2001 08:06:16 -0800 (PST) Received: (qmail 21927 invoked from network); 23 Nov 2001 16:06:21 -0000 Received: from unknown (HELO laptop.baldwin.cx) ([64.81.54.73]) (envelope-sender ) by mail6.speakeasy.net (qmail-ldap-1.03) with SMTP for ; 23 Nov 2001 16:06:21 -0000 Message-ID: X-Mailer: XFMail 1.4.0 on FreeBSD X-Priority: 3 (Normal) Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 8bit MIME-Version: 1.0 In-Reply-To: <20011123234342.I5572-100000@delplex.bde.org> Date: Fri, 23 Nov 2001 08:06:14 -0800 (PST) From: John Baldwin To: Bruce Evans Subject: Re: cvs commit: src/sys/kern subr_diskmbr.c Cc: cvs-all@FreeBSD.org, cvs-committers@FreeBSD.org, Peter Wemm Sender: owner-cvs-all@FreeBSD.ORG Precedence: bulk List-ID: List-Archive: (Web Archive) List-Help: (List Instructions) List-Subscribe: List-Unsubscribe: X-Loop: FreeBSD.ORG 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 <>< 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