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:

  1. Open a terminal with access to a user that can run sudo.
    $ id
    uid=1000(user) gid=1000(user) groups=1000(user),27(sudo)
  2. 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.

  3. 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"
  4. 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.

  5. 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
  6. 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.

  7. 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.

  8. Open the /etc/fstab file in a text editor with root privileges.
    $ sudo vi /etc/fstab
  9. 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.

  10. 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.

  11. 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
Discuss the article:

Comment anonymously. Login not required.