Get UUID of Hard Disks [Update]

Short Tip: Get UUID of Hard Disks [Update]

shell.png
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.

1
2
$ 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:

1
2
$ 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
Attachments
There are no attachments for this article.
Comments
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
20 IPtables Examples For New SysAdmins
Viewed 2180 times since Fri, May 15, 2020
haproxy linux
Viewed 2472 times since Sun, Dec 6, 2020
YUM CRON Enabling automatic updates in Centos 7 and RHEL 7
Viewed 11919 times since Fri, Oct 26, 2018
How to Analyze or Read OS Watcher Output in three easy steps -- With Example ?
Viewed 41624 times since Thu, Jun 21, 2018
6 rsync Examples to Exclude Multiple Files and Directories using exclude-from
Viewed 4909 times since Wed, Oct 31, 2018
Extending Linux LVM partitions - scripts
Viewed 6531 times since Sun, May 20, 2018
An easier way to manage disk decryption at boot with Red Hat Enterprise Linux 7.5 using NBDE
Viewed 7543 times since Mon, Aug 6, 2018
Exclude multiple files and directories with rsync
Viewed 2515 times since Wed, Oct 31, 2018
How to Register and Enable Red Hat Subscription, Repositories and Updates for RHEL 7.0 Server
Viewed 12479 times since Mon, Oct 29, 2018
How to automate SSH login with password? ssh autologin
Viewed 2700 times since Fri, Jun 8, 2018