Skip to main content

Finding the UUID for Linux Drives

UPDATE: I use the term "Drives" here for two reasons. One, people coming from Windows understand a harddisk drive (generally C: or another "device" letter). Two, this is specific to harddrives and not other devices in Linux (like the terminal, printer or scanner).

The Universally Unique Identifier (UUID) is a good way to mount drives under Linux with SATA drives (or any drives, PATA or IDE). This ensures that when you have more than one harddrive, it always gets mounted to the same location specified in /etc/fstab. The reason is that SATA drives are mounted when they're found and on one reboot can come up as /dev/sda and the next time as /dev/sdb.

So in order to set up your file system table correctly, you should specify the UUID instead of the physcial device. So your /etc/fstab will look like this:

Ok, so if you want to use the UUID, how can you find it? We're assuming the drive is already mounted, of course!

One way is to use

$ ls -l /dev/disk/by-uuid
lrwxrwxrwx 1 root root 10 11. Okt 18:02 485554c3-e681-4254-9344-6f038c826fb8 -> ../../sda2

This will list all the devices by UUID and tell you where they're currently mounted. Another would be to use the blkid command.

# blkid /dev/sda1
/dev/sda1: LABEL="/" UUID="485554c3-e681-4254-9344-6f038c826fb8" SEC_TYPE="ext2" TYPE="ext3"

One problem with this is that the blkid command can only list one device at a time. A secondary problem is that the command blkid has to be run as the root user.

Additional information can be found by googling Linux and UUID.