Last updated: 2026-08-18

Linux Partition HOWTO: Disk partitioning guide

Category: Storage AdministrationStandard: UEFI, GPT & Linux 6.x
Summary & Core Principles
  • Partition Scheme: Always use GUID Partition Tables (GPT) for all drives unless strictly constrained by legacy 1980s BIOS systems.
  • Sector Alignment: Align all partition boundaries to exact 1 MiB (2048 sector) multiples to guarantee alignment with 4Kn physical sectors and SSD flash erase blocks.
  • Persistent Mounting: Reference partitions by filesystem UUID= or GPT PARTUUID= in /etc/fstab rather than raw kernel node paths (/dev/sda).

Table of contents

  1. 1. Fundamentals of Linux disk partitioning
  2. 2. Block device identification and naming conventions
  3. 3. Partition table standards: GPT vs. MBR
  4. 4. Partition requirements, sizing & subvolume strategies
  5. 5. Creating partitions with fdisk, gdisk, and parted
  6. 6. Filesystem creation (Ext4, Btrfs, XFS, VFAT)
  7. 7. Persistent labeling & device identification (UUID / PARTUUID)
  8. 8. Swap space: zram, swapfiles, and dedicated partitions
  9. 9. Partition table recovery and repair
  10. 10. Full-disk encryption with LUKS
  11. 11. UEFI boot flow and the EFI System Partition
  12. 12. Storage geometries: LBA, 4Kn Advanced Format, and NVMe FTL

1. Fundamentals of Linux disk partitioning

A partition is a continuous region of logical blocks on a storage device that is isolated from other regions on the same drive. The operating system treats each partition as a separate block device, so different filesystems, LUKS encryption layers, and swap areas can coexist on one disk.

Partitioning serves several operational requirements:

2. Block device identification and naming conventions

Linux exposes storage devices as special block device nodes in /dev/. The device prefix reflects the underlying hardware interface:

Device PathStorage InterfaceDrive ExamplePartition Example
/dev/nvmeXnYpZPCIe NVMe SSD/dev/nvme0n1 (Controller 0, Namespace 1)/dev/nvme0n1p1 (Partition 1)
/dev/sdXSATA / SAS / USB SCSI/dev/sda (First SATA drive)/dev/sda1 (Partition 1)
/dev/vdXVirtIO Block (KVM/QEMU)/dev/vda (First virtual disk)/dev/vda1 (Partition 1)
/dev/mmcblkXpYeMMC / SD Storage/dev/mmcblk0/dev/mmcblk0p1
Non-Deterministic Device Ordering

Kernel device names like /dev/sda and /dev/nvme0n1 are assigned dynamically during boot depending on controller detection timing. In production configurations, always reference partitions using persistent identifiers (such as UUID= or PARTUUID=) in /etc/fstab.

3. Partition table standards: GPT vs. MBR

The partition table defines the layout, boundaries, and types of all partitions on a drive. Modern systems use GPT; MBR remains only for legacy BIOS compatibility.

GPT on-disk layout

GPT stores redundant metadata at both ends of the disk. The UEFI specification (section 5) defines the following structure:

LBAStructurePurpose
LBA 0Protective MBRA legacy MBR with a single partition entry of type 0xEE spanning the disk. Prevents GPT-unaware utilities from accidentally overwriting GPT structures.
LBA 1Primary GPT HeaderContains the EFI PART signature, disk GUID, partition entry array location, CRC32 checksums, and pointers to the backup header.
LBA 2 to 33Primary Partition Entry Array128 entries of 128 bytes each (16 KiB total). Each entry holds a partition type GUID, unique partition GUID, start/end LBA, and partition name.
LBA 34 to n-34Usable disk spacePartition data area. First usable LBA is typically 34; last usable LBA is disk_size - 34.
LBA n-33 to n-2Backup Partition Entry ArrayMirror of the primary entry array for recovery.
LBA n-1Backup GPT HeaderMirror of the primary header. Its My LBA and Alternate LBA fields are reversed relative to the primary.

MBR on-disk layout

MBR packs all metadata into a single 512-byte sector at LBA 0:

OffsetSizeContent
0x000440 bytesBootstrap code (master boot code)
0x1B84 bytesOptional unique disk signature
0x1BE64 bytesFour 16-byte partition table entries (primary partitions)
0x1FE2 bytesBoot signature 0x55AA

Each 16-byte MBR partition entry contains a bootable flag, CHS start/end addresses, a 1-byte partition type code, and a 32-bit LBA start and sector count. The 32-bit LBA limit is what caps MBR at 2.2 TB. Extended partitions (type 0x05, 0x0F, or 0x85) create a linked list of partition table sectors for logical volumes beyond the 4 primary slots.

For detailed GUID mappings, see Partition Types, GPT GUIDs & Discoverable Partitions →.

4. Partition requirements, sizing & subvolume strategies

Partition layout requirements depend on whether you are using traditional fixed partitions or a Copy-on-Write (CoW) filesystem with subvolumes (such as Btrfs or ZFS):

Mount PointPartition TypeTypical AllocationFilesystemDescription
/boot/efi or /efiEFI System Partition (ESP)512 MB to 1 GBVFAT (FAT32)Required by UEFI firmware for bootloaders and Unified Kernel Images.
/ (Root)Linux Root50 GB to 100 GB+Ext4, Btrfs, or XFSOperating system binaries, libraries, system configurations, and containers.
/homeLinux HomeRemaining Disk SpaceExt4, Btrfs, or XFSUser directories, configurations, and personal data.
[SWAP]Linux Swap0 (zram) or 4 to 16 GBSwap SpaceIn-memory zram swap device or dedicated swapfile on disk.

Detailed sizing rules and subvolume considerations are available in Partition Requirements & Sizing Guide →.

5. Creating partitions with fdisk, gdisk, and parted

Partitions can be managed from the command line using standard utilities:

# Start fdisk on an NVMe drive
sudo fdisk /dev/nvme0n1

# Key fdisk interactive commands:
# g -> Initialize a new GPT partition table
# n -> Create a new partition
# t -> Set partition type (e.g., 1 for EFI, 23 for Linux Root)
# p -> Display the partition table
# w -> Write changes to disk and exit

Scriptable partitioning with parted

For provisioning scripts, Kickstart files, and cloud image builds, parted accepts multiple commands in a single non-interactive invocation. Use --script (or -s) to suppress prompts and -a optimal to enforce 1MiB alignment:

# Create a full UEFI/GPT layout in one scripted call
sudo parted --script -a optimal /dev/nvme0n1 \
  mklabel gpt \
  mkpart "EFI system partition" fat32 1MiB 1025MiB \
  set 1 esp on \
  mkpart "swap" linux-swap 1025MiB 17GiB \
  mkpart "root" ext4 17GiB 100%

# Verify the result
sudo parted --script /dev/nvme0n1 print

Note that mkpart does not create the filesystem. The fs-type parameter only sets the partition type GUID on GPT disks. Run mkfs.* separately after partitioning.

Follow the full tutorial in How to Partition with fdisk, gdisk & parted →.

6. Filesystem creation

After creating partitions, format them with the appropriate filesystem:

# Format the EFI System Partition (FAT32)
sudo mkfs.vfat -F 32 -n "EFI-SYSTEM" /dev/nvme0n1p1

# Format Root with Ext4 (64-bit metadata checksums enabled)
sudo mkfs.ext4 -L "ROOT_FS" /dev/nvme0n1p2

# Format Data partition with Btrfs
sudo mkfs.btrfs -L "DATA_POOL" /dev/nvme0n1p3

# Format High-Performance storage with XFS
sudo mkfs.xfs -L "DATABASE" /dev/nvme0n1p4

Filesystem comparison

The three dominant Linux filesystems serve different workloads. Ext4 is the default on Debian and Ubuntu. XFS is the default on RHEL, AlmaLinux, and Rocky Linux. Btrfs is the default on Fedora and openSUSE.

FeatureExt4XFSBtrfs
Max volume size16 TiB (default) / 64 ZiB (with 64bit feature)8 EiB16 EiB
Max file size16 TiB8 EiB (VFS limit)8 EiB (practical VFS limit; 16 EiB theoretical)
JournalingMetadata only (data=ordered default)Metadata onlyCopy-on-write
Online growYesYesYes
Online shrinkNo (offline only)NoYes
SnapshotsNoNo (native reflink for file-level CoW)Yes (native)
CompressionNoNoYes (zstd, lzo, zlib)
Data checksumsMetadata onlyMetadata onlyData + metadata
SubvolumesNoNoYes
Default onDebian, UbuntuRHEL, AlmaLinux, RockyFedora, openSUSE

Ext4 is the safest general-purpose choice with the longest production track record (stable since 2008). XFS excels at large-file sequential I/O and parallel workloads. Btrfs provides snapshots, compression, and self-healing checksums. For deep dives and enterprise volume management, explore the Ext4 Architecture & Tuning Guide, XFS Optimization Guide, Btrfs Deep Dive, OpenZFS on Linux Guide, and LVM Tutorial.

7. Persistent labeling & device identification

Use lsblk to verify filesystem labels, UUIDs, and mount points across all block devices:

# View all devices with filesystem metadata
lsblk -f

# Sample /etc/fstab configuration using persistent UUIDs:
UUID=4f923b7a-9a81-4b72-9d33-871d8a11a2bc  /         ext4   defaults,noatime  0  1
UUID=7A29-C412                             /boot/efi vfat   umask=0077        0  2
UUID=e2f8910a-31b4-482a-bc91-2a8190cba718  /home     ext4   defaults,noatime  0  2

Learn more in Filesystem Labels & Persistent Naming → and e2label Command Reference →.

8. Swap space: zram, swapfiles, and dedicated partitions

Linux supports several swap mechanisms:

Read the complete configuration guide in Configuring Swap Space & zram →.

9. Partition table recovery and repair

GPT includes built-in recovery capabilities via its secondary partition table stored at the end of the disk. Because the backup header and entry array mirror the primary, a corrupted primary can be rebuilt from the backup.

Verifying and repairing GPT with gdisk

gdisk provides a dedicated recovery and transformation menu (accessed with r from the main menu). The v command on the main menu verifies disk integrity by checking CRC32 values and comparing the primary and backup structures:

# Launch gdisk on the damaged disk
sudo gdisk /dev/nvme0n1

# Verify integrity from the main menu
Command (? for help): v

# Enter the recovery menu if problems are found
Command (? for help): r

# Recovery and transformation options:
# b -> Rebuild primary GPT header from backup
# c -> Load backup partition table (rebuilds main)
# d -> Use main GPT header (rebuilds backup)
# e -> Load main partition table from disk (rebuilds backup)
# f -> Load MBR and build fresh GPT from it

# Write repaired table and exit
recovery/transformation command (? for help): w

Recovering deleted partitions with testdisk

When a partition has been deleted or the table is severely damaged, testdisk can scan the disk surface for filesystem signatures and reconstruct the partition table. It performs a quick search first, then an optional deeper search that scans the entire disk:

# Launch testdisk on the damaged disk
sudo testdisk /dev/nvme0n1

# Select partition table type (auto-detected, usually correct)
# Choose "Analyse" to inspect the current partition table
# Choose "Quick Search" to scan for deleted partitions
# Use "Deeper Search" if Quick Search misses partitions
# Mark found partitions as P (primary) or L (logical)
# Write the recovered partition table to disk

Always back up the GPT header before attempting repairs. In gdisk, use b from the main menu to save a binary backup of the protective MBR, primary header, backup header, and partition table to a file. For corrupted superblock repair, inode rebuilding, and disaster recovery strategies, see the Filesystem Repair Guide (e2fsck, xfs_repair, btrfs check) and the Linux Backup & Disaster Recovery Reference.

10. Full-disk encryption with LUKS

LUKS (Linux Unified Key Setup) is the standard for full-disk encryption on Linux, implemented by cryptsetup on top of the kernel's dm-crypt subsystem. LUKS2 is the default format since cryptsetup 2.1 and stores metadata in a redundant header at the start of the partition.

# Format a partition with LUKS2 (default)
sudo cryptsetup luksFormat /dev/nvme0n1p3

# Open the encrypted partition, mapping it to /dev/mapper/data
sudo cryptsetup open /dev/nvme0n1p3 data

# Format the decrypted mapper device with ext4
sudo mkfs.ext4 -L "ENCRYPTED" /dev/mapper/data

# Close the encrypted partition when done
sudo cryptsetup close data

The LUKS2 header occupies 16 MiB by default (configurable via --offset), providing space for up to 32 keyslots and online reencryption. The header is stored twice (primary and secondary) for resilience against corruption. Back up the header with cryptsetup luksHeaderBackup before any potentially destructive operation, as losing the header renders the encrypted data permanently unrecoverable.

For detailed performance optimizations (such as bypassing CPU workqueues on NVMe drives) and automated boot unlocking via TPM2 or Clevis/Tang network key escrow, see the LUKS2 & dm-crypt Encryption Guide and the Automated TPM2 / NBDE Encryption Guide.

11. UEFI boot flow and the EFI System Partition

On UEFI systems, the firmware boot manager reads EFI executables (PE format .efi files) from the EFI System Partition (ESP), a FAT32 partition identified by GPT type GUID C12A7328-F81F-11D2-BA4B-00A0C93EC93B. The boot flow is:

  1. Firmware initialization: UEFI firmware reads the BootOrder NVRAM variable to determine which boot entry to load.
  2. Boot loader execution: The firmware loads the EFI executable specified by the boot entry. For removable media, it falls back to \EFI\BOOT\BOOTX64.EFI.
  3. Kernel handoff: The boot loader (such as systemd-boot or GRUB) loads the Linux kernel and initramfs, then calls ExitBootServices() to transfer control from firmware to the kernel.
  4. Initramfs: The initramfs mounts the root filesystem, then pivots to it as PID 1.

systemd-boot is a simple UEFI boot manager and the reference implementation of the Boot Loader Specification. It reads Boot Loader Specification Type #1 entries from /loader/entries/ on the ESP and Type #2 Unified Kernel Images from /EFI/Linux/. UKIs combine systemd-stub, the kernel, initramfs, and kernel command line into a single signed .efi binary for Secure Boot.

Frequently asked questions

What is a disk partition in Linux?

A partition is a continuous region of logical blocks on a storage device, isolated from other regions on the same drive. The operating system treats each partition as a separate block device for different filesystems, LUKS encryption layers, or swap areas.

Should I use GPT or MBR partition table?

Use GPT for all drives unless constrained by legacy BIOS systems. GPT supports disk sizes up to 8 ZiB, 128 primary partitions by default, and stores a backup partition table at the end of the disk with CRC32 integrity verification. MBR is limited to 2.2 TB and 4 primary partitions.

How should I reference partitions in /etc/fstab?

Reference partitions by filesystem UUID= or GPT PARTUUID= rather than raw device paths like /dev/sda. Kernel device names are assigned dynamically at boot and can change order depending on controller detection timing.

What sector alignment should I use for partitions?

Align all partition boundaries to 1 MiB (2048 sector) multiples. This guarantees alignment with 4Kn physical sectors and SSD flash erase blocks, eliminating read-modify-write performance penalties.

What filesystem should I choose: Ext4, XFS, or Btrfs?

Ext4 is the default on Debian and Ubuntu with the longest production track record (stable since 2008). XFS is the default on RHEL and excels at large-file sequential I/O. Btrfs provides snapshots, compression, and self-healing checksums via copy-on-write.

How do I recover a corrupted GPT partition table?

GPT stores a backup partition table at the end of the disk. Use gdisk's recovery menu (press r from the main menu) to rebuild the primary header from the backup. For deleted partitions, testdisk can scan the disk surface for filesystem signatures.

What is LUKS full-disk encryption?

LUKS (Linux Unified Key Setup) is the standard for full-disk encryption on Linux, implemented by cryptsetup on top of dm-crypt. LUKS2 is the default format since cryptsetup 2.1 and stores metadata in a redundant header at the start of the partition.