Get the UUID with blkid

If you need a quick way to find the UUID of your storage devices in Linux, try blkid.

A Universally Unique Identifier (UUID) is a 128-bit value that is supposed to uniquely identify hardware devices. With each device having its own unique 128-bit identifier, the system can access that device without confusing it with something else. Hopefully, no two devices will share the same UUID given that 128 bits provides over 320 undecillion possible combinations.

The UUID is useful for identifying hard drives in a Linux system when other factors used to locate them might change. For example, look at fstab combined with some motherboards.

With some motherboards, I have found that /dev/sda (the system drive) might become /dev/sdb after an extra SATA drive is installed. If fstab is set to boot from /dev/sda, then the system no longer boots due to the added drive now being reported as /dev/sda. Strangely, this does not happen with all motherboards.

A UUID solves this problem. Instead of specifying /dev/sda or /dev anything in /etc/fstab, use the hard drive’s UUID. The UUIDs are automatically assigned when formatted, and they remain constant for their devices until reformatted. You do not choose UUIDs yourself.
To find the UUIDs of all hard drives (block devices) connected to a running Linux system, open a terminal and enter sudo blkid at the command prompt. You should see something like this:

sudo blkid
/dev/sda1: UUID="2e2be99d-5a55-4da1-8665-219a405a8f97" TYPE="ext4" 
/dev/sda5: UUID="c2f99f78-bbc9-410a-bf72-186620a8e051" TYPE="swap" 
/dev/sdb1: LABEL="new" UUID="ac3ed2c8-91f1-4d31-a601-28db9a36f53a" TYPE="ext4" 
/dev/sdc1: LABEL="porta" UUID="F1A5-B5DE" TYPE="vfat"

Here, we see four storage devices and their UUIDs.

  • /dev/sda1 is the system drive.
  • /dev/sda5 is the Linux swap partition.
  • /dev/sdb1 is a spare hard drive.
  • /dev/sdc1 is an external USB drive formatted as FAT32 (vfat).

Notice that each has a UUID. In the case of the FAT32 USB device, its UUID is not 128 bits. It uses UUID=”F1A5-B5DE”, which is all that is allowed with FAT32 formatting. However, you would still use this identifier where a UUID is required.

blkid is installed with Linux by default, and it requires superuser privileges. You must use sudo in Ubuntu-based distributions.


  1. Leave a comment

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: