UUID (UUID)
A UUID is a long ID number that is practically guaranteed to be unique. Linux gives each partition one, so it can always find the right partition even if you plug drives into different ports and their names change. You will see UUIDs in configuration files, database records, and web addresses.
A UUID is a 128-bit identifier written as 32 hex digits in five groups: 3f1c9a7e-2b4d-4f8e-9a1c-0d5e6f7a8b9c. RFC 9562 defines the versions:
- v4: random (the most common)
- v7: time-ordered, good for database keys
- v1/v6: time and node based
In Linux storage there are several IDs, and they are easy to mix up:
- Filesystem UUID (
UUID=): created bymkfs, used in fstab and on the kernelroot=line. Reformatting changes it. - Partition UUID (
PARTUUID=): stored in the GPT entry; survives reformatting the filesystem - Disk GUID: the GPT disk identifier
- FAT filesystems use a short 8-digit volume ID like
1A2B-3C4D
Why not /dev/sda1? Kernel device names are assigned in detection order. Adding a USB drive or a second disk can shift sda to sdb. UUIDs do not move.
Cloned disks share UUIDs. Two disks with the same filesystem UUID attached at once confuse mounts. Change one with tune2fs -U random (ext4) after cloning.
Finding UUIDs
# Every block device with its UUID and type
$ sudo blkid
/dev/sda1: UUID="1A2B-3C4D" TYPE="vfat" PARTUUID="a1b2..."
/dev/sda2: UUID="3f1c9a7e-2b4d-4f8e-9a1c-0d5e6f7a8b9c" TYPE="ext4" PARTUUID="c3d4..."
# Table view
$ lsblk -o NAME,UUID,PARTUUID,MOUNTPOINTS
# Symlinks the system keeps for you
$ ls -l /dev/disk/by-uuid/
# Generate one
$ uuidgen
0c8f2b8e-5c3a-4f51-9d2e-7b6a1e4c9f00 UUIDs are what keep a server booting when you add disks. The usual trouble is copying the wrong one into fstab (PARTUUID where UUID was expected, or a UUID from before a reformat) or cloning a disk and ending up with duplicates. When a boot drops to emergency mode complaining about a missing device, compare the UUID in /etc/fstab against blkid output first.