[buug] x86 disk partitioning, and detailed structure, lilo, sfdisk, ...

Michael Paoli Michael.Paoli at cal.berkeley.edu
Sun Dec 6 11:40:16 PST 2009


x86 disk partitioning, and detailed structure, lilo, sfdisk, ...

(at least some of this was discussed at a BUUG meeting some month(s)
ago)

Probably the best documentation I've yet run across for explaining x86
disk partitioning (e.g. IBM PC, etc.) and its structure, is within the
LILO documentation.  E.g. for a typical Debian LILO installation, in the
file:
/usr/share/doc/lilo/Manual.txt.gz
It also coveres a fair amount some of the particular caveats of certain
operating systems and their filesystems - e.g. DOS and its storage of
disk and file system parameters (cluster size, number of sectors, number
of heads, etc.).

Another quite handy tool (but hazardous if mishandled) is sfdisk.
With the -x option to sfdisk (along with some other suitable options and
arguments) we can essentially see all the partition detail, including
all the details of partition tables used in extended and logical
partitions.

With extended partition, the first sector of the partition is yet
another partition table.  These are typically recursively chained, to
produce the desired logical partitions, with most all such partition
tables containing one logical partition, and yet another extended
partition (the extended partition generally being present in all but the
last partition table).

In the below example, with the -x option, we see the details of all
these partition tables (without the -x option, we'd just see the
partitions which would generally have an associated device).

Also, using the -uS option and option argument, gives us the information
at the 512 byte sector level (so we don't lose detail rounding off to
larger units), and the -l gives us our information in a nice
human-readable format (the -d option, particularly with -uS and without
-x is handy for a format much more suitable for sfdisk input - handy for
backing up, and recreating or duplicating a partition scheme).

"hazardous if mishandled" - sfdisk is very powerful, but relatively
unforgiving.  If you don't include the -l or -d option, you're editing
your partition table with the partition specification supplied via
stdin, and if it gets EOF before otherwise being interrupted or
terminated, you may have just overwritten (or trashed) your partition
table.

On the (quite) positive side, for those that are cautious and know what
they're doing, sfdisk will let one write pretty much any possible
parition configuration, and with quite low-level control on exactly how
it is written out, precise boundaries (down to the 512 byte sector),
etc.  It's also very handy for backing up a partition scheme, and being
able to restore or copy it.  (e.g. part of my regular backups save and
backup the partition information, using -uS and (separately) both -d and
-l options, for use or consideration during restores).

# 2>&1 sudo sfdisk -uS -l -x /dev/hda

Disk /dev/hda: 4764 cylinders, 240 heads, 63 sectors/track
Units = sectors of 512 bytes, counting from 0

    Device Boot    Start       End   #sectors  Id  System
/dev/hda1            63    619919     619857  83  Linux
/dev/hda2   *    619920  25477199   24857280   7  HPFS/NTFS
/dev/hda3      25477200  25749359     272160   c  W95 FAT32 (LBA)
/dev/hda4      25749360  72031679   46282320  85  Linux extended

/dev/hda5      25764480  26369278     604799  83  Linux
     -          26369279  72031679   45662401   5  Extended
     -          25749360  25749359          0   0  Empty
     -          25749360  25749359          0   0  Empty

/dev/hda6      26369280  30563567    4194288  82  Linux swap / Solaris
     -          30563568  72031679   41468112   5  Extended
     -          26369279  26369278          0   0  Empty
     -          26369279  26369278          0   0  Empty

/dev/hda7      30572640  33521038    2948399  8e  Linux LVM
     -          33521039  72031679   38510641   5  Extended
     -          30563568  30563567          0   0  Empty
     -          30563568  30563567          0   0  Empty

/dev/hda8      33521040  36469438    2948399  8e  Linux LVM
     -          36469439  72031679   35562241   5  Extended
     -          33521039  33521038          0   0  Empty
     -          33521039  33521038          0   0  Empty

/dev/hda9      36469440  39417838    2948399  8e  Linux LVM
     -          39417839  72031679   32613841   5  Extended
     -          36469439  36469438          0   0  Empty
     -          36469439  36469438          0   0  Empty

/dev/hda10     39417840  42366238    2948399  8e  Linux LVM
     -          42366239  72031679   29665441   5  Extended
     -          39417839  39417838          0   0  Empty
     -          39417839  39417838          0   0  Empty

/dev/hda11     42366240  45314638    2948399  8e  Linux LVM
     -          45314639  72031679   26717041   5  Extended
     -          42366239  42366238          0   0  Empty
     -          42366239  42366238          0   0  Empty

/dev/hda12     45314640  48263038    2948399  8e  Linux LVM
     -          48263039  72031679   23768641   5  Extended
     -          45314639  45314638          0   0  Empty
     -          45314639  45314638          0   0  Empty

/dev/hda13     48263040  51211438    2948399  8e  Linux LVM
     -          51211439  72031679   20820241   5  Extended
     -          48263039  48263038          0   0  Empty
     -          48263039  48263038          0   0  Empty

/dev/hda14     51211440  54159838    2948399  8e  Linux LVM
     -          54159839  72031679   17871841   5  Extended
     -          51211439  51211438          0   0  Empty
     -          51211439  51211438          0   0  Empty

/dev/hda15     54159840  57108238    2948399  8e  Linux LVM
     -          57108239  72031679   14923441   5  Extended
     -          54159839  54159838          0   0  Empty
     -          54159839  54159838          0   0  Empty

/dev/hda16     57108240  60056638    2948399  8e  Linux LVM
     -          60056639  72031679   11975041   5  Extended
     -          57108239  57108238          0   0  Empty
     -          57108239  57108238          0   0  Empty

/dev/hda17     60056640  63005038    2948399  8e  Linux LVM
     -          63005039  72031679    9026641   5  Extended
     -          60056639  60056638          0   0  Empty
     -          60056639  60056638          0   0  Empty

/dev/hda18     63005040  65953438    2948399  8e  Linux LVM
     -          65953439  72031679    6078241   5  Extended
     -          63005039  63005038          0   0  Empty
     -          63005039  63005038          0   0  Empty

/dev/hda19     65953440  68901838    2948399  8e  Linux LVM
     -          68901839  72031679    3129841   5  Extended
     -          65953439  65953438          0   0  Empty
     -          65953439  65953438          0   0  Empty

/dev/hda20     68901840  71850238    2948399  8e  Linux LVM
     -          68901839  68901838          0   0  Empty
     -          68901839  68901838          0   0  Empty
     -          68901839  68901838          0   0  Empty





More information about the buug mailing list