Linux: what is partition UUID and how to use it

This post is over 3 years old, so please keep in mind that some of its content might not be relevant anymore.

UUID stands for Universally Unique Identifier and is used to univocally identify a partition.
This is more reliable than /dev/hd* or /dev/sd* since it doesn’t change between system boots.

All filesystems should be specified by UUID=<id> (or also LABEL=<name>) for each partition.
Labels are very useful for external media devices like flash drives and USB hard drives since these are generally automounted by hal (Hardware Abstraction Layer). If a device has a label, it will be mounted at the /media/<label> location and appear with the label on the desktop.

UUID can be used in different system files. Probably the most common is the fstab (/etc/fstab in Ubuntu) and, for example, it can be used this way:

UUID=65b14742-9610-4289-8ea4-af8edcc5d8da /media/data ext4 defaults 0 2

How do you find partition’s UUID
The UUID of a single partition can be found with:

sudo vol_id -u /dev/sda2

supposing /dev/sda2 is the partition you are interested in.
If you want to list all UUID of all attached devices (mounted or not) you run:

sudo blkid

Alternatively you can list them from the file system with:

ls -l /dev/disk/by-uuid/

Some more resources about UUID can be found on the Ubuntu Community Help site.

Leave a Reply

Your email address will not be published. Required fields are marked *

%d bloggers like this: