How to find the UUID of a disk drive in Linux

There are two ways I know of which will print the UUID of all disk drives attached to the current system:

blkid

/dev/sr0: UUID="2014-12-02-19-30-23-00" LABEL="CDROM" TYPE="iso9660" 
/dev/sda1: UUID="ae55a647-3c57-4ab5-9651-1389703fe6fe" TYPE="ext4" 
/dev/sda2: UUID="bMtCfO-zpDU-7U1t-DcHg-Fe9p-Cy1K-Se0e1I" TYPE="LVM2_member" 
/dev/sdb1: UUID="0982ce66-537a-497b-baaf-99136594f3e8" TYPE="ext4" 
/dev/mapper/VolGroup-lv_swap: UUID="8f0652a8-d79b-453f-aa2d-0ff0b5d0ae7b" TYPE="swap" 
/dev/mapper/VolGroup-lv_root: UUID="5afc1b25-e6cd-45b2-ad20-69f0fed323b9" TYPE="ext4" 
/dev/mapper/VolGroup-lv_home: UUID="94e15e98-1cff-49a9-b76a-a8f3a948e2ea" TYPE="ext4" 

or

ls -la /dev/disk/by-uuid

total 0
drwxr-xr-x. 2 root root 160 Mar 25 00:24 .
drwxr-xr-x. 5 root root 100 Mar 25 00:24 ..
lrwxrwxrwx. 1 root root  10 Mar 25 00:24 0982ce66-537a-497b-baaf-99136594f3e8 -> ../../sdb1
lrwxrwxrwx. 1 root root   9 Mar 25 00:24 2014-12-02-19-30-23-00 -> ../../sr0
lrwxrwxrwx. 1 root root  10 Mar 25 00:24 5afc1b25-e6cd-45b2-ad20-69f0fed323b9 -> ../../dm-1
lrwxrwxrwx. 1 root root  10 Mar 25 00:24 8f0652a8-d79b-453f-aa2d-0ff0b5d0ae7b -> ../../dm-0
lrwxrwxrwx. 1 root root  10 Mar 25 00:24 94e15e98-1cff-49a9-b76a-a8f3a948e2ea -> ../../dm-2
lrwxrwxrwx. 1 root root  10 Mar 25 00:24 ae55a647-3c57-4ab5-9651-1389703fe6fe -> ../../sda1

The UUID is required to permanently mount specific disk drives in /etc/fstab.





Jay is the CEO and founder of WP Hosting, a boutique style managed WordPress hosting and support service. He has been working with Plesk since version 9 and is a qualified Parallels Automation Professional. In his spare time he likes to develop iOS apps and WordPress plugins, or draw on tablet devices. He blogs about his coding journey at http://wpguru.co.uk and http://pinkstone.co.uk.