How to get the UUID of a disk or partition in Ubuntu

Sometimes it can be very useful, and even necessary, to know the UUID (Universally Unique Identifier) of a disk or partition in Linux.

Nowadays the configuration for mounting disk partitions on linux (the file /etc/fstab) uses the UUID instead of the device name (/dev/hda1, /dev/sda1 …).

If you need to know which is the UUID of a particular device you can run the blkid command. E.g:

$ sudo blkid /dev/sda1
/dev/sda1: UUID="8b6ec31c-1f41-49f3-82da-d2ab0f0fa312" TYPE="ext3"

If you don’t like this command, or you think you cannot remember it, there is another way of knowing the UUID. If you have udev in your system (I think is udev the one that updates the list), you can go to  /dev/disks/by-uuid/ folder and run a list command (ls). E.g:

$ ls -l /dev/disks/by-uuid/
lrwxrwxrwx 1 root root 10 2009-11-19 07:56 8b6ec31c-1f41-49f3-82da-d2ab0f0fa312 -> ../../sda1
lrwxrwxrwx 1 root root 10 2009-11-19 07:56 626adc53-3478-4eb1-9f68-dc0b6f9308e7 -> ../../sda2
lrwxrwxrwx 1 root root 10 2009-11-19 07:56 9cfc5c6d-f343-411e-ac59-31eee6b12a9b -> ../../sda3

The advantage of this command is that we don’t need administrator privileges, and it’s easier to remember 🙂

Trackback URL

, , ,

Comments are closed.