Partition & filesystem volume labels (e2label, UUID, fstab)
Dynamic device node paths like /dev/sda and /dev/nvme0n1 can change order when storage hardware or bus controllers change. Linux solves this with Persistent Block Device Naming using filesystem UUIDs, GPT PARTUUIDs, volume labels, and partition labels in /etc/fstab.
Persistent identifier types
| Identifier | Location | fstab Syntax Example | Use Case |
|---|---|---|---|
| Filesystem UUID | Superblock of the filesystem | UUID=4f923b7a-9a81-4b72-9d33-871d8a11a2bc | Standard /etc/fstab entries; remains constant regardless of bus changes or repartitioning of other disks. |
| GPT PARTUUID | GPT partition table entry | PARTUUID=8c6b1b8a-70e2-4c77-96a1-94e51f729221 | Kernel boot parameters (root=PARTUUID=...); persists even before filesystems are formatted. |
| Filesystem LABEL | Filesystem superblock header | LABEL=ROOT_FS | Human-readable volume identification for removable media and backup drives. |
| GPT PARTLABEL | GPT partition table header | PARTLABEL=EFI_SYSTEM | Partition identification prior to filesystem creation. |
Managing volume labels across filesystems
| Filesystem | Set Label Command | View Label Command | Max Characters |
|---|---|---|---|
| Ext4 / Ext3 / Ext2 | sudo e2label /dev/sdX1 "ROOT_FS"or sudo tune2fs -L "ROOT_FS" /dev/sdX1 | sudo e2label /dev/sdX1 | 16 chars |
| XFS | sudo xfs_admin -L "DATA_POOL" /dev/sdX1 | sudo xfs_admin -l /dev/sdX1 | 12 chars |
| Btrfs | sudo btrfs filesystem label /mnt/pool "STORAGE" | sudo btrfs filesystem label /mnt/pool | 255 chars |
| FAT32 / ESP | sudo fatlabel /dev/sdX1 "EFI-SYSTEM" | sudo fatlabel /dev/sdX1 | 11 chars |
Sample /etc/fstab configuration
# /etc/fstab: Static filesystem mounting configuration
# <file system> <mount point> <type> <options> <dump> <pass>
# Root Filesystem (Ext4, persistent UUID)
UUID=b5e8697b-9516-43b9-bb22-835ec443dbcf / ext4 defaults,noatime,errors=remount-ro 0 1
# EFI System Partition (FAT32, persistent UUID)
UUID=7A29-C412 /boot/efi vfat umask=0077,fmask=0077,shortname=winnt 0 2
# User Home Directory (Btrfs subvolume)
UUID=89d21c33-4f32-498c-8c01-f2bc394a819b /home btrfs subvol=@home,compress=zstd,noatime 0 0
# In-Memory Temporary Storage (tmpfs)
tmpfs /tmp tmpfs defaults,noatime,mode=1777 0 0If a filesystem is corrupted and repaired, its UUID may change. The filesystem repair guide covers recovery tools that can rewrite superblock identifiers.
Sources & references
- e2label(8) — Linux manual page — documents e2label for displaying or changing ext2/ext3/ext4 volume labels, including the 16-character limit
- xfs_admin(8) — Linux manual page — documents xfs_admin for XFS filesystem label management with -L option to set labels and -l to print them
- fatlabel(8) — Linux manual page — documents fatlabel for setting MS-DOS/FAT32 filesystem labels, including the 11-byte limit
- blkid(8) — Linux manual page — documents blkid for querying block device attributes including LABEL and UUID tokens from filesystem metadata
- lsblk(8) — Linux manual page — documents lsblk for listing block devices with filesystem information, supporting lsblk -f for viewing labels and UUIDs
Frequently asked questions
Why should I use UUID instead of /dev/sda in fstab?
Device node paths like /dev/sda are assigned dynamically at boot and can change order when hardware changes. UUIDs are stored in the filesystem superblock and remain constant regardless of bus changes or repartitioning of other disks.
What is the difference between UUID and PARTUUID?
UUID is stored in the filesystem superblock and identifies the filesystem. PARTUUID is stored in the GPT partition table entry and identifies the partition itself. PARTUUID persists even before the filesystem is formatted.
How do I set a label on an Ext4 filesystem?
Use sudo e2label /dev/sdX1 "ROOT_FS" or sudo tune2fs -L "ROOT_FS" /dev/sdX1. Ext2/3/4 labels are limited to 16 characters.
How do I set a label on an XFS filesystem?
Use sudo xfs_admin -L "DATA_POOL" /dev/sdX1 to set the label and sudo xfs_admin -l /dev/sdX1 to view it. XFS labels are limited to 12 characters.
What is PARTLABEL in Linux?
PARTLABEL is a human-readable name stored in the GPT partition table header. You can use it in /etc/fstab with syntax like PARTLABEL=EFI_SYSTEM to identify a partition before a filesystem is created on it.
How do I view filesystem labels and UUIDs?
Use lsblk -f to view all devices with their filesystem labels, UUIDs, and mount points. You can also use blkid to query individual devices.