3 Ways to Get the Hard Drive’s Universally Unique Identifiers (UUIDs)

UUID goes for Universally Unique Identifier. The latest versions of Unix and Linux Systems use the UUID to refer to hard drive partitions, instead of using the block device file.

Watch Free Movies

Example: the hard drive representation from the /etc/fstab.

So, next I will show you 3 ways to find out the Hard Disk’s UUIDs.

1. Find the UUIDs with blkid:

By default, blkid used without any arguments gives you all the UUIDs.

# blkid
/dev/sda1: UUID="e0421779-fb36-4460-9162-f56c4eff7add" TYPE="swap"
/dev/sda2: UUID="03c82a88-bd92-452f-a7de-6c92602bc383" TYPE="ext4"
/dev/sda3: UUID="02611b0d-b32e-49a6-9b1b-a7354dac4f20" TYPE="ext4"

To get the UUID for a certain drive, use blkid /path/to/drive:

# blkid /dev/sda1
/dev/sda1: UUID="e0421779-fb36-4460-9162-f56c4eff7add" TYPE="swap"
# blkid /dev/sda2
/dev/sda2: UUID="03c82a88-bd92-452f-a7de-6c92602bc383" TYPE="ext4"

2. Find the UUIDs by listing /dev/disk/by-uuid:

# ls -l /dev/disk/by-uuid/
total 0
lrwxrwxrwx 1 root root 10 May 23 22:50 02611b0d-b32e-49a6-9b1b-a7354dac4f20 -> ../../sda3
lrwxrwxrwx 1 root root 10 May 23 22:50 03c82a88-bd92-452f-a7de-6c92602bc383 -> ../../sda2
lrwxrwxrwx 1 root root 10 May 23 22:50 e0421779-fb36-4460-9162-f56c4eff7add -> ../../sda1

3. Find the UUIDs by using the udevadm command:

# udevadm info -q all -n /dev/sda2 | grep -i uuid | egrep "^S:"
S: disk/by-uuid/03c82a88-bd92-452f-a7de-6c92602bc383

This gives me the UUID for /dev/sda2. Replace the /dev/sda2 with the path of the drive you want to get the UUID.

Scroll to Top