How to Mount Partitions using UUID in Linux

Last updated: June 26, 2022

If you use lots of disks that are regularly changed or moved, it's preferred to mount the partition using UUID. This is because OS may change device names in some situations like adding another disk. This may end with issues with booting. UUID is unique and independent from the actual device names.

In this tutorial, we are going to learn how to mount partitions using UUID in a Linux system.

Mount by UUID

Firstly, find UUID of the device partition that is going to be mounted. You can use the following command to find the UUID of the partitions.

sudo blkid
List partition's UUID

Or to print UUID for a specific disk or partition, use:

sudo blkid /dev/sdb -sUUID -ovalue

Create a directory or use an existing directory to mount the partition. Here I am creating a directory named dir1.

sudo mkdir -p /mnt/dir1

To temporarily mount the partition using UUID, type:

sudo mount UUID=af406bcd-cddb-4095-8456-fdf8dfe37665 /mnt/dir1

How to add UUID in fstab

You can add UUID in fstab file to mount the partition permanently.

Open the /etc/fstab file using your favorite text editor.

sudo vi /etc/fstab

Then, append the following line at the end of the file.

UUID=af406bcd-cddb-4095-8456-fdf8dfe37665  /var/www  ext4  defaults 0  0

Run mount -a to mount all filesystems or perform a reboot command to reflect the changes.

Once mounted, run the following command to check whether the partition is mounted correctly.

df -h

The output shows that the partition /dev/sdb has been mounted at /mnt/dir1.


In this tutorial, we have learned how to mount a partition in Linux using UUID. Also, learned about why we use UUID and how to find the UUID of partitions. Any feedback and response will be highly appreciated.



Please add comments below to provide the author your ideas, appreciation and feedback.

Leave a Reply

Leave a Comment