Disk Management

fdisk, gdisk, parted, mkfs, fsck, blkid, and smartctl for partitioning, formatting, and drive health.

Overview

Disk management is a foundational SRE skill. Whether you are adding a data volume to a database server, replacing a failed drive, or setting up a new host, you need to understand partitioning schemes, filesystem creation, integrity checking, and drive health monitoring.

MBR vs GPT

Every disk starts with a partition table, which records where each partition begins and ends. There are two schemes, and the size of the disk usually decides between them.

MBR (Master Boot Record) is the legacy scheme stored in the first 512 bytes of a disk. That sector holds 446 bytes of boot code, a 64-byte partition table with room for 4 entries, and the magic signature 0x55AA. So MBR supports at most 4 primary partitions (or 3 primary + 1 extended with logical partitions inside) and disks up to 2 TiB. Use fdisk to work with MBR disks.

GPT (GUID Partition Table) is the modern standard. It supports up to 128 partitions per disk, one for each of its 128 partition entries of 128 bytes, and disks beyond 2 TiB. A GPT disk begins with a protective MBR and the primary GPT header, and it stores a backup partition table at the end of the disk for recovery. Use gdisk or parted for GPT disks. All disks over 2 TiB must use GPT.

Key concepts

  • MBR
  • GPT
  • UUID
  • SMART attributes
  • fsck
  • parted

Interview questions

  • Walk me through adding a new 4 TiB data disk to a Linux server from raw device to mounted filesystem.
  • How do you check if a disk is failing in production without taking downtime?
  • What is the difference between fdisk, gdisk, and parted? When do you use each?

Sign up free to read the full topic

More Linux topics

Start free on Cariara · Coding problems · System design studio