3

I create a file of 100MB size, and using losetup assign it to /dev/loop0.

Consequently I use fdisk to create an empty DOS partition table, and a new partition that spans the entire disk.

One thing that is unusual to me and I cannot understand, is that the aforementioned partition begins at the 63rd sector; this implies that the partition table takes up 62 sectors, i.e. 31Kb.

I was under the impression that all data regarding partition entries is recorded in the master boot record, the first sector of the drive, and thus only the first 512 bytes of the disk should be off bounds.

Examining the drive, the sectors after the first are not completely filled with null, so clearly there is some detail I am missing regarding partition tables.

fdisk print (display type = sectors):

      Device Boot     Start        End     Blocks   Id  System
/dev/loop0p1   *         63     192779      96358+  83  Linux
  • My fdisk (util-linux 2.20.1) reserves the first 2048 sectors. Times are a-movin' – roaima Jun 20 '16 at 23:11
  • @roaima Ah, does the utility simply 'reserve' additional space after the bootloader merely for alignment? – Maxim Blinov Jun 20 '16 at 23:19
  • Sectors 2 - 63 are normally unused in FAT-based MS systems. They can contain GRUB stage 1.5 on Linux. – Zdenek Jun 2 '18 at 12:27
4

The MBR partition format is three decades old, and subject to weirdness for historical reasons.

Back then, the computer needed to know the geometry of the hard disk. How is data organized on a hard disk? In three dimensions: cylinder, heads and sectors.

tracks, cylinders, sectors, heads

(Diagram by LionKimbro)

The geometry was stored with maximum values that were large enough for the time: 8 bits for the number of heads (1–255), 6 bits for the number of sectors on a track (1–63), and 10 bits for the number of tracks per head, i.e. the number of cylinders (1–1023), with one sector containing 512 bytes. Nowadays computers don't need to know the actual geometry of the disk (and those numbers aren't even meaningful), but the format remains, and disks using MBR partitioning have a size that's expressed in CHS format, but all that matters is that the product of the three numbers is equal to the total number of sectors.

The starting address of the start of a partition is expressed in CHS format, and a lot of older operating systems didn't support partitions spanning different tracks, i.e. a partition had to be aligned on a cylinder boundary. That means a multiple of 63 sectors for the first partition.

There's a space of 31 kB that isn't used for partition content. It can be used for a bootloader.

The modern GPT partition format, which is the standard for newer PCs with >1 TB disks, likes to align partition on 1 MB boundaries, so there's about 1023 kB free before the start of the first partition. Again, this can be used by a bootloader. Modern operating systems align MBR partitions on 1MB boundaries too, dropping the CHS compatibility, and ensuring that partitions fall on a sector boundary on drives with 4 kB sectors (= 8 traditional sectors of 512 kB). Aligning partitions on a sector boundary (as in, the actual sector size used by the disk, i.e. its preferred transfer size) helps performance.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.