Mounting disk partitions by UUID keeps storage devices attached to consistent mount points across reboots and hardware changes. Systems that rely on multiple disks, external drives, or shared storage gain predictable paths for application data and user directories, which reduces configuration drift and avoids surprises when device names change.
In Linux, each filesystem stores a Universally Unique Identifier in its superblock. Tools such as blkid read these identifiers, and /etc/fstab can reference them instead of volatile device paths like /dev/sda1. During boot, systemd and the mount utility parse /etc/fstab and attach each partition to a directory in the unified filesystem tree based on these entries.
Editing /etc/fstab requires root privileges and careful attention to syntax, filesystem type, and mount options. A wrong UUID, incorrect mount point, or typo in options can delay boot or drop the system into emergency mode until configuration is corrected. Access to a rescue console or live media helps recover quickly if a mistake is introduced.
Steps to mount disk partitions by UUID in Linux:
- Open a terminal with access to a user that can run sudo.
$ id uid=1000(user) gid=1000(user) groups=1000(user),27(sudo)
- List block devices to identify the partition that should be mounted by UUID.
$ lsblk NAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINTS sda 8:0 0 238.5G 0 disk ├─sda1 8:1 0 512M 0 part /boot └─sda2 8:2 0 238G 0 part / sdb 8:16 0 931.5G 0 disk └─sdb1 8:17 0 931.5G 0 part
The example commands below assume /dev/sdb1 is the partition to mount by UUID.
- Find the UUID of the target partition using blkid or assign a UUID if none is present.
$ sudo blkid /dev/sdb1 /dev/sdb1: UUID="39ea80c4-e748-47eb-835c-64025de53e26" TYPE="ext4" PARTUUID="a1b2c3d4-01"
- Create a backup of the current /etc/fstab file before making changes.
$ sudo cp /etc/fstab /etc/fstab.bak
An incorrect line in /etc/fstab can prevent Linux from booting normally; use the backup or a rescue shell to restore the file if necessary.
- Create the /mnt/uuidtest directory to serve as the mount point for the partition.
$ sudo mkdir --parents /mnt/uuidtest $ ls -ld /mnt/uuidtest drwxr-xr-x 2 root root 4096 Jun 10 12:34 /mnt/uuidtest
- Temporarily mount the partition by UUID to confirm the mount point and filesystem type.
$ sudo mount -t ext4 UUID=39ea80c4-e748-47eb-835c-64025de53e26 /mnt/uuidtest $ df -h | grep uuidtest /dev/sdb1 916G 1G 915G 1% /mnt/uuidtest
Use the filesystem type reported by blkid, such as ext4 or xfs, instead of ext4 if a different type is shown.
- Unmount the test mount once access and data look correct.
$ sudo umount /mnt/uuidtest
No output from umount indicates that the partition was detached successfully.
- Open the /etc/fstab file in a text editor with root privileges.
$ sudo vi /etc/fstab
- Add a new line that uses the UUID and mount point with the appropriate filesystem type and options.
UUID=39ea80c4-e748-47eb-835c-64025de53e26 /mnt/uuidtest ext4 defaults 0 1
The fields are, in order, the UUID, mount point, filesystem type, mount options, dump flag, and filesystem check order.
- Reload all persistent mounts using the updated /etc/fstab entry.
$ sudo mount -a
Absence of error messages from mount indicates that every entry in /etc/fstab, including the new UUID line, was parsed successfully.
- Verify that the partition is mounted at the configured mount point.
$ findmnt /mnt/uuidtest TARGET SOURCE FSTYPE OPTIONS /mnt/uuidtest /dev/sdb1 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.
Comment anonymously. Login not required.
