Kernel device names can change when disks are added, controllers are reordered, or a virtual machine boots with different storage timing. Mounting by filesystem UUID keeps a data volume tied to the intended directory even when the kernel assigns a different device name.
Each filesystem stores its own UUID in metadata on the device. blkid reads that identifier and the filesystem type, mount can resolve a UUID=… source, and the system mount table can save the same stable reference for future mounts.
The examples below use an ext4 filesystem and a persistent local data mount. Replace the device path, UUID, filesystem type, mount point, mount options, and final check field for the target filesystem, because a malformed persistent mount entry can leave the volume unavailable during boot.
Steps to mount a disk partition by UUID in Linux:
- List the target block device before changing any mount configuration.
$ lsblk -o NAME,SIZE,TYPE,MOUNTPOINTS /dev/vdb1 NAME SIZE TYPE MOUNTPOINTS vdb1 64G part
Use the filesystem device, usually a partition such as /dev/vdb1, /dev/sdb1, /dev/nvme1n1p1, or a logical volume under /dev/mapper. If MOUNTPOINTS already shows a path, the filesystem is already mounted.
- Read the filesystem UUID and type from the target device.
$ sudo blkid /dev/vdb1 /dev/vdb1: LABEL="data" UUID="fcc7979c-742b-43aa-9fe5-6a014e23496f" BLOCK_SIZE="4096" TYPE="ext4"
- Create the mount point directory.
$ sudo mkdir -p /mnt/data
Files already present in the mount point directory stay hidden while another filesystem is mounted there.
- Test a direct mount by UUID before saving persistent configuration.
$ sudo mount UUID=fcc7979c-742b-43aa-9fe5-6a014e23496f /mnt/data
- Confirm that the UUID resolved to the intended device and mount point.
$ findmnt -M /mnt/data -o TARGET,SOURCE,FSTYPE,OPTIONS TARGET SOURCE FSTYPE OPTIONS /mnt/data /dev/vdb1 ext4 rw,relatime
The -M option checks the exact mount point instead of walking up parent directories.
- Unmount the test mount before editing /etc/fstab.
$ sudo umount /mnt/data
- Back up the current /etc/fstab file.
$ sudo cp --archive /etc/fstab /etc/fstab.bak
A malformed /etc/fstab entry can delay boot or leave the filesystem unavailable until the file is corrected.
- Open /etc/fstab in an editor with root privileges.
$ sudoedit /etc/fstab
- Add a persistent mount line that uses the UUID instead of the raw device path.
UUID=fcc7979c-742b-43aa-9fe5-6a014e23496f /mnt/data ext4 defaults 0 2
The fields are source, mount point, filesystem type, mount options, dump flag, and filesystem check order. Use 0 0 for filesystems that should not be checked by fsck at boot, and consider defaults,nofail for storage that may be absent during boot.
- Verify the saved /etc/fstab entry before mounting from it.
$ sudo findmnt --verify --verbose /mnt/data /mnt/data [ ] target exists [ ] UUID=fcc7979c-742b-43aa-9fe5-6a014e23496f translated to /dev/vdb1 [ ] source /dev/vdb1 exists [ ] FS type is ext4 Success, no errors or warnings detected
Correct the /etc/fstab line before continuing if findmnt reports an error or warning.
- Mount the saved entry by its mount point.
$ sudo mount /mnt/data
- Confirm that the persistent entry mounted the expected filesystem.
$ findmnt -M /mnt/data -o TARGET,SOURCE,FSTYPE,OPTIONS TARGET SOURCE FSTYPE OPTIONS /mnt/data /dev/vdb1 ext4 rw,relatime
Mohd Shakir Zakaria is a cloud architect with deep roots in software development and open-source advocacy. Certified in AWS, Red Hat, VMware, ITIL, and Linux, he specializes in designing and managing robust cloud and on-premises infrastructures.