Re: 10.2 Gig HDD

Max (max@Linuz.sns.it)
Thu, 21 Jan 1999 16:58:28 +0100 (MET)


First, the quick answer:

On Wed, 20 Jan 1999, Neil Conway wrote:
>
>I have btw read the Large-disk HOWTO (very educational) but am still
>confused as to the above point.

About the logical/physical geometry thing, right?
Logical geometry used by Linux must be such that Linux can calculate the
correct physical geometry from it.

Now, the long answer:

>Hmm, perhaps you can clarify something that confuses me...
>
>If you do invent your own geometry, how does the DRIVE know what you are
>using? Suppose for example, the drive has native geometry of 3200,16,63
>and you decide you want to have less than 1000 cylinders, so you pick
>something like 800,64,63. When the drive is first asked for Sector
>(1,62,54) it can make a good guess that you have got a custom geometry,
>but if you have previously asked it for Sector (1,2,2) will it have
>given you the wrong sector?

You are (almost) right.

Let's try to explain the situation:
In order to talk to the disk, Linux needs to know its physical geometry:
either the correct C/H/S to give meaningful C/H/S address or the LBA
capacity. LBA means that Linux and the disk use the 'linear sector number'
to communicate, which makes things much easier.

Now, IDE disks can have at most 16 *physical* heads. If you tell the kernel
that the geometry of your disk is 787/128/63 (as with my 3G Western Digital)
the kernel will use the *physical* geometry 6296/16/63 for C/H/S addressing
(it's deduced from the logical geometry you specify, knowing Heads<=16)
or will use LBA, knowing that the disk has 6346368 sectors (approx 3GB).

Till now things are simple: get your disk *physical* geometry,
invent a COMPATIBLE logical geometry and tell it to the kernel.

By 'compatible' I mean: the kernel must be able to deduce the correct physical
geometry from it. It's easy since the kernel divides by 2 the number of heads
and multiplies by 2 the numbers of cylinders, until heads<=16, to get the
physical geometry.

So the working logical geometries for my disk would be any of:
787/128/63
1574/ 64/64
3148/ 32/63
6296/ 16/63 (equal to the physical geometry)
(the number of logical heads must be <= 255)

The hard part comes now: The Linux kernel is not the only software on the
world, so it must agree with other software about where the partitions are.

In particular:

a) The *logical* geometry, and not the *physical* one is used to
describe partitions on the disk partition table, due to braindead
design of partition table.
This is actually one of the reasons *logical* geometry was invented.
It also means that Linux fdisk wants to know the logical geometry
(it asks it to the kernel)

b) If you have DOS partitions on that disk, DOS and Linux must agree
about where partitions are. Also DOS fdisk and Linux fdisk must agree.

So the logical geometry told to the Linux kernel should agree as much as
possible with the one that DOS will get from the BIOS.
In particular the number of heads and sectors must be the same.

Given that, if the BIOS tells DOS a lower number of cylinders,
DOS will only be able to access the first part of the disk.
And the BIOS can report 1024 cylinders at maximum...
To make things nastier, very old BIOSes always report the *physical*
geometry.

Also, LILO must be able to load the Linux kernel from disk using BIOS services,
and this may give some problems, as said above: the BIOS can report (and access)
only up to 1024 logical cylinders.
Again, logical geometry used by the BIOS (and by LILO) must match
as much as possible with the one used by Linux (heads and cyls must match)
or nasty things can happen.

>Yesterday I performed a horrifically crude hack to get just such a disk
>working on an old machine. The default RH5.2 installation didn't want
>to let us build a single partition due to the disk having more than 1024
>cylinders (and thus LILO might possibly crash and burn).

That's just RedHat fdisk (or whatever you used) being too picky.
As explained above, for LILO to work, the kernel must be within the 1024
logical cyilinders. If you make a partition within that limit and put all
LILO files in it (the kernel image and the various /boot/* files) you are ok.
Then you can make other partitions above the 1024-cyl limit, and Linux will
happily use them.

>So, not being totally confident about hacking the partition table directly
>with Linux's fdisk

If the logical geometry used by Linux is compatible with the one reported by
BIOS (same # of heads and sectors, said above), using Linux fdisk is safe even
on a disk with LILO installed and/or holding DOS partitions.

>I booted DOS (oh the shame :-)) and used MS-fdisk to make
>a partition. This made a suitably translated partition table (roughly
>the above values), which Linux of course happily honoured. (Obviously I
>wiped the DOS partition though.)
>
>I'd rather not have to use DOS again in similar circumstances (!)...

Hehe. That's not so a crude hack indeed... but a safe way to be sure that DOS
will honour a partition ;)

>Neil
>

Massimiliano Ghilardi

----------------------------------------------------------------
| I have yet to meet a person who had a bad experience of Linux. |
| Most have never had an experience. |
----------------------------------------------------------------

-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.rutgers.edu
Please read the FAQ at http://www.tux.org/lkml/