Linux - Partition table (Sector 0)

> Operating System - Kernel (Windows, Unix, Linux) > Linux / Unix > Linux - Disk (storage devices)

1 - About

The partition data are saved in a partition table found in sector 0 of the disk.

Partition table is also known as:

  • disk slices
  • disk label

Advertising

3 - Syntax (or type, structure)

3.1 - GUID Partition Table (GPT)

GUID Partition Table (GPT) is a standard for the layout of the partition table.

3.2 - BSD/SUN type

A BSD/SUN type disklabel can describe 8 partitions, the third of which should be a âwhole diskâ partition. Do not start a partition that actually uses its first sector (like a swap partition) at cylinder 0, since that will destroy the disklabel.

3.3 - IRIX/SGI type

An IRIX/SGI type disklabel can describe 16 partitions, the eleventh of which should be an entire “volume” partition, while the ninth should be labeled “volume header”. The volume header will also cover the parti- tion table, i.e., it starts at block zero and extends by default over five cylinders. The remaining space in the volume header may be used by header directory entries. No partitions may overlap with the volume header. Also do not change its type and make some file system on it, since you will lose the partition table. Use this type of label only when working with Linux on IRIX/SGI machines or IRIX/SGI disks under Linux.

3.4 - DOS type

A DOS type partition table can describe an unlimited number of partitions. In sector 0 there is room for the description of 4 partitions (called “primary”). One of these may be an extended partition; this is a box holding logical partitions, with descriptors found in a linked list of sectors, each preceding the corresponding logical partitions. The four primary partitions, present or not, get numbers 1-4. Logical partitions start numbering from 5.

In a DOS type partition table the starting offset and the size of each partition is stored in two ways: as an absolute number of sectors (given in 32 bits) and as a Cylinders/Heads/Sectors triple (given in 10+8+6 bits). The former is OK - with 512-byte sectors this will work up to 2 TB. The latter has two different problems. First of all, these C/H/S fields can be filled only when the number of heads and the number of sectors per track are known. Secondly, even if we know what these numbers should be, the 24 bits that are available do not suffice. DOS uses C/H/S only, Windows uses both, Linux never uses C/H/S.

4 - Management

4.1 - Editor

Advertising

4.2 - View

4.2.1 - fdisk

Linux - fdisk - Partition table manipulator

p
Disk /dev/sda: 68.7 GB, 68719476736 bytes, 134217728 sectors
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 4096 bytes
I/O size (minimum/optimal): 4096 bytes / 4096 bytes
Disk label type: dos
Disk identifier: 0x0008c758

   Device Boot      Start         End      Blocks   Id  System
/dev/sda1   *        2048     1026047      512000   83  Linux
/dev/sda2         1026048    67108863    33041408   83  Linux

4.2.2 - Parted

The partition information are available with the print command of parted. start parted.

(parted) print
Model: VMware, VMware Virtual S (scsi)
Disk /dev/sda: 376GB
Sector size (logical/physical): 512B/512B
Partition Table: msdos

Number  Start   End     Size    Type     File system  Flags
 1      32.3kB  107MB   107MB   primary  ext3         boot
 2      107MB   21.5GB  21.4GB  primary               lvm

In the header:

  • The first line displays the size of the disk,
  • The second line displays the disk label type,
  • and the remaining output shows the partition table.

In the partition table:

  • the Minor number is the partition number. For example, the partition with minor number 1 corresponds to dev/sda1.
  • The Start and End values are in megabytes.
  • The Type is one of primary, extended, or logical.
  • The Filesystem is the file system type, which can be one of xt2, ext3, FAT, hfs, jfs, linux-swap, ntfs, reiserfs, hp-ufs, sun-ufs, or xfs.
  • The Flags column lists the flags set for the partition. Available flags are boot, root, swap, hidden, raid, lvm, or lba.
Advertising