LVM and Disk Partitioning
Disk Fundamentals
Section titled “Disk Fundamentals”Block Devices
Section titled “Block Devices”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 Type | Path Pattern | Example | Notes |
|---|---|---|---|
| SCSI/SATA | /dev/sdX | /dev/sda | Letters assigned in detection order |
| NVMe | /dev/nvmeXnY | /dev/nvme0n1 | X = controller, Y = namespace |
| Virtio (VM) | /dev/vdX | /dev/vda | Paravirtualized disks |
| MMC/eMMC | /dev/mmcblkX | /dev/mmcblk0 | Embedded devices |
| Loop | /dev/loopX | /dev/loop0 | Loopback-mounted files |
| Device Mapper | /dev/dm-X | /dev/dm-0 | LVM, crypt, multipath |
| MD RAID | /dev/mdX | /dev/md0 | Software 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 partitionPartition Tables
Section titled “Partition Tables”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 (Master Boot Record)
Section titled “MBR (Master Boot Record)”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).
| Property | MBR |
|---|---|
| Max disk size | 2 TiB (32-bit sector count) |
| Max partitions | 4 primary, or 3 + 1 extended (with logical) |
| Sector addressing | 32-bit LBA |
| Boot method | Legacy BIOS only |
| Partition ID | 1-byte type code |
MBR is obsolete. Use it only when you need legacy BIOS boot on hardware that lacks UEFI.
GPT (GUID Partition Table)
Section titled “GPT (GUID Partition Table)”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.
| Property | GPT |
|---|---|
| Max disk size | 8 ZiB (2^64 bytes) |
| Max partitions | 128 by default (configurable) |
| Sector addressing | 64-bit LBA |
| Boot method | UEFI (with protective MBR for compat) |
| Partition ID | 128-bit GUID type + 128-bit GUID name |
| Redundancy | Backup 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