Get UUID of Hard Disks [Update]

Short Tip: Get UUID of Hard Disks [Update]

There is an update to this post available: UUIDs and Linux: Everything you ever need to know.

The Universally Unique Identifier can be used to identify a device independent form its mount point or device name. This is more and more important as many devices today support hot-plugging or are external anyway. Therefore it makes sometimes sense to access a device (for example in fstab) not by device name but by the UUID.

There are several ways to get the UUID. The first one uses the /dev/ directory. While you are on is you might want to check other by-* directories, I never knew of them.

$ ls -l /dev/disk/by-uuid
lrwxrwxrwx 1 root root 10 11. Okt 18:02 53cdad3b-4b01-4a6c-a099-be1cdf1acf6d -> ../../sda2

Another way to get the uuid by usage of the tool blkid:

$ blkid /dev/sda1
/dev/sda1: LABEL="/" UUID="ee7cf0a0-1922-401b-a1ae-6ec9261484c0" SEC_TYPE="ext2" TYPE="ext3"

There you also get the label and other information. Quite usefule.

Btw., if you wonder how “unique” this unique is, here a quote from Wikipedia:

1 trillion UUIDs would have to be created every nanosecond for 10 billion years to exhaust the number of UUIDs.

Pretty unique.

Thanks to Linux By Examples for the initial howto.

0 (0)
Article Rating (No Votes)
Rate this article
There are no attachments for this article.
There are no comments for this article. Be the first to post a comment.
Full Name
Email Address
Security Code Security Code
Related Articles RSS Feed
Super Grub2 Disk
Viewed 1094 times since Wed, May 22, 2019
SSH: Execute Remote Command or Script – Linux
Viewed 716 times since Mon, Feb 18, 2019
RHEL7: Create and configure LUKS-encrypted partitions and logical volumes to prompt for password and mount a decrypted file system at boot.
Viewed 2717 times since Mon, Aug 6, 2018
10 nmap Commands Every Sysadmin Should Know
Viewed 1116 times since Wed, May 22, 2019
RHEL: Crash kernel dumps configuration and analysis on RHEL 5
Viewed 1628 times since Sat, Jun 2, 2018
ZPOOL: Create a new zpool for zfs filesystems
Viewed 1019 times since Sun, Jun 3, 2018
Logrotate Example for Custom Logs
Viewed 1306 times since Sun, Jan 12, 2020
10 Linux DIG Command Examples for DNS Lookup
Viewed 819 times since Sun, Sep 30, 2018
How To Create a Linux Swap File
Viewed 968 times since Fri, Jun 8, 2018
socat: Linux / UNIX TCP Port Forwarder
Viewed 2273 times since Tue, Aug 6, 2019