List drives by UUID in Ubuntu
January 26th, 2009 | News
Hi! If you’re new here, you may want to subscribe to the Unix Tutorial RSS feed to get regular tips & tricks for all flavors of Unix. You can follow me on Twitter, too! Thanks for visiting!
Having used this tip a few times myself, I’d like to share it with you: a very simple way to list all the drives in your Ubuntu system using their UUID’s.
Disks by uuid in Ubuntu
Apart from blkid command, there’s another relatively easy way for you to confirm what each UUID on your system corresponds to. If you look in the /dev/disk/by-uuid directory, it contains symlinks which look like UUIDs and point to the real devices for each of your disks:
ubuntu# ls -al /dev/disk/by-uuid/*
lrwxrwxrwx 1 root root 10 Jan 12 04:25 /dev/disk/by-uuid/2596b3b4-9e54-47e2-bb45-89b3d4a0e7e3 -> ../../sda2
lrwxrwxrwx 1 root root 10 Jan 12 04:25 /dev/disk/by-uuid/d2ff8a06-74b7-4877-9d37-1873414e25b3 -> ../../sda1
Confirm disk device using its UUID
Knowing the /dev/disk/by-uuid directory, you can easily use this to look disks up by their UUID with the readlink command:
ubuntu# readlink /dev/disk/by-uuid/d2ff8a06-74b7-4877-9d37-1873414e25b3
That’s it! Have a great week!