Skip to content

LVM and Disk Partitioning

Linux exposes storage devices as block device files under /dev/. Block devices support random Access by fixed-size blocks ( 512 bytes or 4096 bytes), unlike character devices which are Accessed as a stream of bytes.

Definition. A block device is a storage device that supports reading and writing data in Fixed-size blocks, addressed by a linear block number. The kernel caches block device I/O in the Page cache.

Naming conventions:

Device TypePath PatternExampleNotes
SCSI/SATA/dev/sdX/dev/sdaLetters assigned in detection order
NVMe/dev/nvmeXnY/dev/nvme0n1X = controller, Y = namespace
Virtio (VM)/dev/vdX/dev/vdaParavirtualized disks
MMC/eMMC/dev/mmcblkX/dev/mmcblk0Embedded devices
Loop/dev/loopX/dev/loop0Loopback-mounted files
Device Mapper/dev/dm-X/dev/dm-0LVM, crypt, multipath
MD RAID/dev/mdX/dev/md0Software RAID arrays

Partitions are numbered after the device name:

/dev/sda # entire disk
/dev/sda1 # first partition
/dev/sda15 # 15th partition (GPT allows many)
/dev/nvme0n1p1 # first partition on first namespace of NVMe controller 0
/dev/nvme0n1p2 # second partition

Definition. A partition table is a data structure stored at the beginning of a disk that Describes the layout of partitions, their starting sectors, sizes, types, and status flags.

MBR uses a 512-byte boot sector at LBA 0 containing a 446-byte bootstrap code area, a 64-byte Partition table (four 16-byte entries), and a 2-byte signature (0x55AA).

PropertyMBR
Max disk size2 TiB (32-bit sector count)
Max partitions4 primary, or 3 + 1 extended (with logical)
Sector addressing32-bit LBA
Boot methodLegacy BIOS only
Partition ID1-byte type code

MBR is obsolete. Use it only when you need legacy BIOS boot on hardware that lacks UEFI.

GPT is part of the UEFI specification. It stores partition entries in a linked list structure with a Protective MBR at LBA 0 for backward compatibility.

PropertyGPT
Max disk size8 ZiB (2^64 bytes)
Max partitions128 by default (configurable)
Sector addressing64-bit LBA
Boot methodUEFI (with protective MBR for compat)
Partition ID128-bit GUID type + 128-bit GUID name
RedundancyBackup partition table at end of disk
GPT disk layout:
LBA 0: Protective MBR (512 bytes)
LBA 1: GPT header (92 bytes)
LBA 2-33: Partition entries (128 entries x 128 bytes each)
LBA 34+: First usable sector (partition data starts here)
Last LBA - 33: Backup partition entries
Last LBA - 1: Backup GPT header