Skip site navigation (1)Skip section navigation (2)
Date:      Mon, 17 Jun 2002 13:44:41 +1000 (EST)
From:      Bruce Evans <bde@zeta.org.au>
To:        "Greg 'groggy' Lehey" <grog@FreeBSD.ORG>
Cc:        Hans Lambermont <hans@lambermont.dyndns.org>, <freebsd-stable@FreeBSD.ORG>, <freebsd-fs@FreeBSD.ORG>
Subject:   Re: fdisk seems broken for slices above cyl 1023
Message-ID:  <20020617125915.H3073-100000@gamplex.bde.org>
In-Reply-To: <20020616233233.GC56375@wantadilla.lemis.com>

next in thread | previous in thread | raw e-mail | index | archive | help
On Mon, 17 Jun 2002, Greg 'groggy' Lehey wrote:

> On Sunday, 16 June 2002 at 23:24:01 +0200, Hans Lambermont wrote:
> > Hi,
> >
> > I'm battling with fdisk on a 20 GB disk with 4 slices.
> >
> > This is the disk:
> > ad0: 19077MB <TOSHIBA MK2018GAP> [38760/16/63] at ata0-master UDMA100
> > On FreeBSD 4.6-RC #1: Sun Jun 16 2002
> > Fdisk translates the geometry to : cylinders=2584 heads=240
> > sectors/track=63 (15120 blks/cyl)
> >
> > This disk was partitioned during sysinstal in 4 slices:
> >     /dev/ad0s1 Suspend to Disk, 0.3 GB
> >     /dev/ad0s2 FreeBSD slice 1, 8.3 GB
> >     /dev/ad0s3 FreeBSD slice 2, 8.3 GB
> >     /dev/ad0s4 other,           2.4 GB
> > (etc)
> > Still 124 ?!
> >
> > This is seriously wrong. This looks like an fdisk bug to me.

This is correct and not a bug.  C/H/S values in fdisk tables are limited
to 10/8/6 bits, respectively, so the best tha can be done with a 'C'
value larger than 1023 is truncate it mod 1024.  FreeBSD's fdisk(8)
does this.  However, over the last few years, some bad hacks for
clipping the CHS values have become less nonstandard, and are required
to satisfy some broken BIOSes.  Your original fdisk entries (not shown
above) seem to have been created by an fdisk that supports this.  IIRC,
the starting CHS for partitions starting on a cylinder > 1023 are
1023/254/63, and the ending CHS is 1023/[actual H]/[actual S].  The
starting head number must be 254, not the maximum representable head
number of 255, to work around other bugs in other or the same broken
BIOSes.

> Yes, correct.  fdisk truncates the cylinder number to 10 bits.  I
> looked at the code a couple of days ago, but it's such a mess that the
> best thing to do would be to throw it away and start again, possibly
> importing something from NetBSD or OpenBSD.

No thanks.  Why is unaudited grass always considered greener by those
who don't use it?  I know that the 1988 Minix fdisk is better because
I wrote most of it, and even early Linux command line fdisks are better
because they apparently obtained a lot from the Minix one, but copyright
and political considerations prevented importing these even before
there was a FreeBSD fdisk with different features to clobber.

> > Any help is appreciated.
>
> Don't talk about cylinders with fdisk.  It works OK with LBA mode
> (start and end sector).

CHS must be set correctly for booting on some systems.

Bruce


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




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