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=0(root) gid=0(root) groups=0(root)
  2. List block devices to identify the partition that should be mounted by UUID.
    $ lsblk
    NAME   MAJ:MIN RM   SIZE RO TYPE MOUNTPOINTS
    loop0    7:0    0     1G  0 loop /mnt/data
    loop1    7:1    0   512M  0 loop /mnt/mountdemo
    loop2    7:2    0   128M  0 loop 
    loop3    7:3    0   128M  0 loop /mnt/uuiddemo
    loop4    7:4    0   256M  0 loop 
    loop5    7:5    0    64M  0 loop 
    loop6    7:6    0    64M  0 loop 
    nbd0    43:0    0     0B  0 disk 
    nbd1    43:32   0     0B  0 disk 
    nbd2    43:64   0     0B  0 disk 
    nbd3    43:96   0     0B  0 disk 
    nbd4    43:128  0     0B  0 disk 
    nbd5    43:160  0     0B  0 disk 
    nbd6    43:192  0     0B  0 disk 
    nbd7    43:224  0     0B  0 disk 
    vda    254:0    0  59.6G  0 disk 
    `-vda1 254:1    0  59.6G  0 part /etc/hosts
                                     /etc/hostname
                                     /etc/resolv.conf
    vdb    254:16   0 606.4M  1 disk 
    nbd8    43:256  0     0B  0 disk 
    nbd9    43:288  0     0B  0 disk 
    nbd10   43:320  0     0B  0 disk 
    nbd11   43:352  0     0B  0 disk 
    nbd12   43:384  0     0B  0 disk 
    nbd13   43:416  0     0B  0 disk 
    nbd14   43:448  0     0B  0 disk 
    nbd15   43:480  0     0B  0 disk

    The example commands below assume /dev/loop1 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/loop1
    /dev/loop1: LABEL="mountdemo" UUID="4bb9a2c6-c8ee-46f7-9bf4-50dea6b8bffb" BLOCK_SIZE="4096" TYPE="ext4"
  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 Dec 29 02:20 /mnt/uuidtest
  6. Temporarily mount the partition by UUID to confirm the mount point and filesystem type.
    $ sudo mount -t ext4 UUID=4bb9a2c6-c8ee-46f7-9bf4-50dea6b8bffb /mnt/uuidtest
    $ df -h | grep uuidtest
    /dev/loop1      488M   24K  452M   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=4bb9a2c6-c8ee-46f7-9bf4-50dea6b8bffb   /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/loop1 ext4   rw,relatime