Date: Mon, 31 Mar 2003 15:13:43 +1000 (EST) From: Bruce Evans <bde@zeta.org.au> To: Nate Lawson <nate@root.org> Cc: cvs-all@FreeBSD.org Subject: Re: cvs commit: src/sbin/fdisk fdisk.c Message-ID: <20030331140740.R17363@gamplex.bde.org> In-Reply-To: <Pine.BSF.4.21.0303301153000.5939-100000@root.org> References: <Pine.BSF.4.21.0303301153000.5939-100000@root.org>
next in thread | previous in thread | raw e-mail | index | archive | help
On Sun, 30 Mar 2003, Nate Lawson wrote: > On Sat, 29 Mar 2003, Poul-Henning Kamp wrote: > > In message <Pine.BSF.4.21.0303291408451.4536-100000@root.org>, 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: <UNUSED> 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: <UNUSED> The data for partition 4 is: <UNUSED> %%% This shows that the disk has a single partition set up with a geometry of H=255/S=63. Bruce
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20030331140740.R17363>