Re: Partition table/Extended partition table documentation.

Max (max@Linuz.sns.it)
Wed, 13 Jan 1999 16:17:10 +0100 (MET)


On Wed, 13 Jan 1999, Mike A. Harris wrote:

>Due to the last message I sent about partitions in reply to
>someone, I want to do some experiments with some partitioning. I
>would like to obtain some documentation on exactly how the
>partition table is layed out, as well as how the extended
>partition tables (or various different ones) are layed out. I
>have a decent understanding of the main partition table, and have
>manually edited it on numerous disk recovery situations, however
>I've not had much need to muck with extended tables, and have no
>idea how or where they are stored, and what the layout is.
>
>Pointers to docs and source code would be great. I'm going to
>grab the various fdisk programs sources, and LILO sources for
>starters.

I have played tricks with partitions since when a black-out somehow erased
the whole partition table on my computer :(

Extended partitions are not complex: the first 512 bytes of the partition
just contain another partition table, which describes how the extended
partition itself is layed out.

There are two "standards" around:
first one (used by DOS, works on Linux too)
is to use the first entry of that table for a real, "data" partition
and the second entry (if needed) for another nested extended partition that
will describe the remaining partitions in the same way.
So you get a chain of extended partitions, when each one describes the next one
and also a "data" (ext2, DOS or whatever you like) partition.

second one (accepted by Linux at least, but is probably just a side effect of
implementing the above standard with too general code)
allows using as many entries as you want in an extended partition, with the
limit that is contains at most another extended partition (which should be the
last used entry if I remember correctly).

Of course there are also BSD, Sun, etc partitioning schemes,
but that's another thing.

One BIG caveat: DOS and Linux don't agree about the meaning of "linear sector"
counts on extended partitions, so you'll have big problems using both DOS and
Linux on a disk with extended partitions, _unless_ each extended partition in
the chain starts from the first sector of a cylinder.

Also, a really nice program to play with partition is in my opinion the Norton
Disk Editor. It allows to enter arbitrary data in the partition tables (and in
the whole disk if that matters) showing the data in a clean format. It can
calculate the C/H/S values from linear sector ones and vice-versa.

P.S. My hardest work on partitions was to *physically* move a 2GB ext2
partition by a 510MB offset toward the end of a 3GB disk...
I had to write all the offsets on paper not to risk damaging it, and copied
it using 'dd' in 510MB chunks, starting from the end of the partition and going
backward... a nightmare. But it worked perfectly.
As a side note, I didn't have any other disk/tape to do a backup *shiver*

>Thanks, TTYL
>
>--
>Mike A. Harris - Computer Consultant - Linux advocate
>
>Linux software galore: http://freshmeat.net

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/