From owner-cvs-all@FreeBSD.ORG Sun Mar 30 21:14:02 2003 Return-Path: Delivered-To: cvs-all@freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id 0918C37B401; Sun, 30 Mar 2003 21:14:02 -0800 (PST) Received: from mailman.zeta.org.au (mailman.zeta.org.au [203.26.10.16]) by mx1.FreeBSD.org (Postfix) with ESMTP id 30A9B43F75; Sun, 30 Mar 2003 21:14:00 -0800 (PST) (envelope-from bde@zeta.org.au) Received: from katana.zip.com.au (katana.zip.com.au [61.8.7.246]) by mailman.zeta.org.au (8.9.3/8.8.7) with ESMTP id PAA18977; Mon, 31 Mar 2003 15:13:44 +1000 Date: Mon, 31 Mar 2003 15:13:43 +1000 (EST) From: Bruce Evans X-X-Sender: bde@gamplex.bde.org To: Nate Lawson In-Reply-To: Message-ID: <20030331140740.R17363@gamplex.bde.org> References: MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII cc: cvs-src@FreeBSD.org cc: Poul-Henning Kamp cc: src-committers@FreeBSD.org cc: cvs-all@FreeBSD.org Subject: Re: cvs commit: src/sbin/fdisk fdisk.c X-BeenThere: cvs-all@freebsd.org X-Mailman-Version: 2.1.1 Precedence: list List-Id: CVS commit messages for the entire tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 31 Mar 2003 05:14:04 -0000 On Sun, 30 Mar 2003, Nate Lawson wrote: > On Sat, 29 Mar 2003, Poul-Henning Kamp wrote: > > In message , Nate Lawson writ > > es: > > >On Sat, 29 Mar 2003, Poul-Henning Kamp wrote: > > >> Modified files: > > >> sbin/fdisk fdisk.c > > >> Log: > > >> Use default geometry in case the device doesn't provide one: > > >> 512 for sectorsize. > > >> 63 for sectors. > > >> 255 for heads. > > >> This will mostly show up on MD(4) devices. > > > > > >Won't this be a problem for small devices or for int 13 booting? That's > > >why we use 64 heads, 32 sectors for scsi devices < 1 GB. > > > > You can specify any number you like to fdisk using all the usual > > ways of doing so, and you should if you want to copy the image to > > some other media afterwards. > > Sure. My concern was for devices like USB flash disks where your defaults > may not be appropriate and the info IS being written to media. Would you > be willing to put in a < 1GB size check on the media to use more > appropriate heads/sector values? This is more broken than I thought. fdisk now defaults to a wrong geometry in all cases where the BIOS geometry differs from the firmware geometry. The default geometry was H=1/S=1 or whatever is returned by DIOCGDINFO until this was broken in -current. This is still non-broken in RELENG_4. H=1/S=1 doesn't cause any serious problems and has the advantage that it is obviously a fake geometry. It should never occur for the usual case of fdisk on whole disk devices, but I see it a lot for fdisk on images of MBRs in regular files (since ioctls cannot work on regular files). This geometry is essentially just a hack to avoid the division by zero bugs that were implemented in rev.1.65, since the label was always available. Normally (in RELENG_4), fdisk is run on a whole disk device and DIOCINFO returns a geometry guessed from the MBR. The firmware geometry is only returned when there doesn't seem to be an MBR or all partition entries are empty. The firmware geometry is rarely what fdisk needs to know since it rarely matches what the partition table uses or what the BIOS would use for the first nonempty partition. All of my non-removable hard disks (except old (small) offline ones) have BIOS geometry H=255/S=63, but the firmware geometry is H=64/S=16 for all the newer/larger (ATA), so fdisk now produces wrong geometries for most of my disks. The differences between working and broken fdisk output are: %%% --- fdisk.RELENG_4.out Mon Mar 31 14:55:19 2003 +++ fdisk.current.out Mon Mar 31 14:28:13 2003 @@ -1,9 +1,9 @@ ******* Working on device /dev/ad0 ******* parameters extracted from in-core disklabel are: -cylinders=3737 heads=255 sectors/track=63 (16065 blks/cyl) +cylinders=59560 heads=16 sectors/track=63 (1008 blks/cyl) Figures below won't work with BIOS for partitions not in cyl 1 parameters to be used for BIOS calculations are: -cylinders=3737 heads=255 sectors/track=63 (16065 blks/cyl) +cylinders=59560 heads=16 sectors/track=63 (1008 blks/cyl) Media sector size is 512 %%% The disk is the same in both cases. The full output for the non-broken case is: fdisk.RELENG_4.out: %%% ******* Working on device /dev/ad0 ******* parameters extracted from in-core disklabel are: cylinders=3737 heads=255 sectors/track=63 (16065 blks/cyl) Figures below won't work with BIOS for partitions not in cyl 1 parameters to be used for BIOS calculations are: cylinders=3737 heads=255 sectors/track=63 (16065 blks/cyl) Media sector size is 512 Warning: BIOS sector numbering starts with sector 1 Information from DOS bootblock is: The data for partition 1 is: The data for partition 2 is: sysid 165 (0xa5),(FreeBSD/NetBSD/386BSD) start 2056320, size 57512700 (28082 Meg), flag 80 (active) beg: cyl 128/ head 0/ sector 1; end: cyl 635/ head 254/ sector 63 The data for partition 3 is: The data for partition 4 is: %%% This shows that the disk has a single partition set up with a geometry of H=255/S=63. Bruce