How Linux Uses UUIDs to Identify Disk Partitions

This article provides an overview of how the Linux operating system uses Universally Unique Identifiers (UUIDs) to consistently and reliably identify disk partitions. You will learn why UUIDs replace traditional device naming schemes, how the system extracts and maps these identifiers through the kernel and udev, the distinction between filesystem UUIDs and partition table identifiers, and how they are implemented within critical configuration files like /etc/fstab and the GRUB bootloader.

The Problem with Traditional Device Names

Historically, Linux assigned storage devices and their partitions sequential names based on hardware detection order, such as /dev/sda1, /dev/sdb1, or /dev/nvme0n1p1. While simple, this naming scheme is dynamic. If a hard drive is plugged into a different SATA port, a USB drive is plugged in before boot, or a storage controller alters its scan order, the assigned device letters can change. A system configured to mount the root filesystem from /dev/sda2 may fail to boot if that drive is suddenly recognized as /dev/sdb2.

What Is a UUID?

A UUID (Universally Unique Identifier) is a 128-bit number formatted as a 36-character string of hexadecimal digits separated by hyphens (for example, 4f3b72c1-8d2a-4b9e-b15f-6a7c8d9e0f1a). The mathematical probability of generating duplicate UUIDs is practically zero, ensuring that every partition and filesystem has a globally unique reference regardless of the machine or port it is connected to.

How Linux Detects and Maps UUIDs

When the Linux kernel boots or detects a new block device, it scans the partition tables and storage media. The process of turning raw hardware into UUID-addressed devices works as follows:

  1. Filesystem Creation: When a filesystem (such as ext4, XFS, or Btrfs) is formatted using a command like mkfs.ext4, a UUID is generated and written directly into the filesystem's superblock metadata.
  2. Device Event and Probing: The Linux kernel detects the device and notifies systemd-udevd (the device manager).
  3. Identifier Extraction: The udev daemon uses low-level utilities (such as blkid) to read the superblock of each detected partition and extract the UUID.
  4. Symlink Generation: Using this extracted data, udev populates the /dev/disk/by-uuid/ directory with symbolic links. Each link is named after a UUID and points directly to the active hardware node (e.g., /dev/disk/by-uuid/4f3b... -> /dev/sda1).

Filesystem UUID vs. PARTUUID

Linux distinguishes between two common types of persistent identifiers:

PARTUUID is often used in minimal environments or early boot stages when the kernel needs to locate the root device before specific filesystem drivers are initialized.

Viewing Partition UUIDs

Linux administrators can inspect persistent identifiers using standard terminal utilities:

Practical Implementation in Linux

UUIDs are primarily utilized in two critical areas to guarantee system stability:

1. Persistent Mounting via /etc/fstab

The /etc/fstab file defines how storage partitions are automatically mounted at boot. Instead of referencing volatile device names, modern Linux distributions use the UUID= syntax:

UUID=4f3b72c1-8d2a-4b9e-b15f-6a7c8d9e0f1a  /home  ext4  defaults  0  2

When the system parses this entry, it resolves the target device via /dev/disk/by-uuid/, ensuring /home is mounted to the correct physical partition regardless of hardware configuration changes.

2. Bootloader and Kernel Directives

The bootloader (such as GRUB) passes the location of the root partition to the Linux kernel via command-line arguments. Using the root=UUID=... parameter allows the initramfs (initial RAM filesystem) to locate and mount the root storage device reliably before transferring control to the main operating system.