Never Ending Security

It starts all here

Get the uuid of devices on linux

Unique identifier for each storage device

UUID is the “universally unique identifier” that is assigned to devices on a linux system for the purpose of identification. For example if your hard disk has 3 partitions then each partition is a device and has a uuid. Similarly cd/dvd, usb drives etc all are assigned a uuid.

On a ubuntu system for example you might find that a partition is mounted at a location like this


Now the part after media/ is the uuid and used as the directory name where a certain device has been mounted. To find the uuid of devices connected to a system use the following commands

$ ls -l /dev/disk/by-uuid/
total 0
lrwxrwxrwx 1 root root 10 Mar  3 09:45 14348F74348F581E -> ../../sda9
lrwxrwxrwx 1 root root 10 Mar  3 09:45 2A64794864791831 -> ../../sda1
lrwxrwxrwx 1 root root 10 Mar  3 09:45 2edfb41d-54f4-478e-8cc0-0fe9864596a8 -> ../../sda8
lrwxrwxrwx 1 root root 10 Mar  3 09:45 31a6807b-3b3e-4f9d-95c2-ead64d0c7009 -> ../../sda6
lrwxrwxrwx 1 root root 10 Mar  3 09:45 9de0aab4-e64c-49c8-af55-cc7375a97dd6 -> ../../sda5
lrwxrwxrwx 1 root root 10 Mar  3 09:45 eba07f1f-b287-456a-b3d6-1c40d7b28a60 -> ../../sda7
lrwxrwxrwx 1 root root 10 Mar  3 12:20 fc474ef9-60b7-4cf8-b42a-7feb63eeb64c -> ../../sdb1

The ls command has been used to get a list of all devices along with the uuids. The big uuids are ext4 or swap type partitions. Whereas the short uuid are ntfs type partitions.


Another command that can be used to perform the same task is blkid. Here are some quick examples on using it.

$ sudo blkid
/dev/sda1: UUID="2A64794864791831" TYPE="ntfs" 
/dev/sda5: UUID="9de0aab4-e64c-49c8-af55-cc7375a97dd6" TYPE="ext4" 
/dev/sda6: UUID="31a6807b-3b3e-4f9d-95c2-ead64d0c7009" TYPE="swap" 
/dev/sda7: UUID="eba07f1f-b287-456a-b3d6-1c40d7b28a60" TYPE="ext4" 
/dev/sda8: UUID="2edfb41d-54f4-478e-8cc0-0fe9864596a8" TYPE="ext4" 
/dev/sda9: UUID="14348F74348F581E" TYPE="ntfs" 
/dev/sdb1: UUID="fc474ef9-60b7-4cf8-b42a-7feb63eeb64c" TYPE="ext4"

The output of blkid clearly shows the device, its uuid and the format type. Useful information. To get the uuid of a specific device, simply put the device name next to blkid like this

$ sudo blkid /dev/sda1
/dev/sda1: UUID="2A64794864791831" TYPE="ntfs"

Leave a Reply

Please log in using one of these methods to post your comment: 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