Use blkid or lsblk to display UUID

Knowing the UUID (“Universally Unique Identifier”) of a device is important in the event of creating a permanent mount point using /etc/fstab. Of course, the name of the device may be used, however, using the UUID is the current trend. There are benefits to this trend. The identifier will likely not be used by anything else so that there will not be any name conflicts. Another benefit is that storage may be moved around without having to update the /etc/fstab.

The following commands had been executed on CentOS 6/7/8 and Rocky Linux (“RL”) 8, and should work on other RHEL, Oracle, Scientific distributions.

A quick glance at one /etc/fstab may reveal lines that resemble this:

UUID=7ae0fdb1-19f7-4e46-96ce-857e748828aa /boot ext4 defaults 1 2

To find the UUID of your devices, the blkid command may be used. Here the result of the command.

blkid
blkid

Alternately, the lsblk command, which may be issued with the “-f” switch to present the following result. If anything the layout with columns is easier on the eyes.

lsblk -f
lsblk-f

Something to consider from this example is the mount for swap. From the blkid, it is expressed as /dev/mapper/vg_centos6test-lv_swap; and from the lsblk -f command, it is vg_centos6test-lv_swap (dm-1).

Using the blkid command to determine the UUID of swap, it can be expressed as one of the following:

blkid /dev/mapper/vg_centos6test-lv_swap
/dev/mapper/vg_centos6test-lv_swap: UUID="eb18ba81-f89b-43c7-9819-1664b7547423" TYPE="swap"
blkid /dev/dm-1
/dev/dm-1: UUID="eb18ba81-f89b-43c7-9819-1664b7547423" TYPE="swap"

# Best Method
blkid -s UUID -o value /dev/mapper/vg_centos6test-lv_swap
eb18ba81-f89b-43c7-9819-1664b7547423

Using ls will show the symbolic link between the two

ls -l /dev/mapper
crw-rw----. 1 root root 10, 58 Mar 5 07:48 control
lrwxrwxrwx. 1 root root 7 Mar 5 07:48 vg_centos6test-lv_root -> ../dm-0
lrwxrwxrwx. 1 root root 7 Mar 5 07:48 vg_centos6test-lv_swap -> ../dm-1

Since these are one in the same, it is easier to remember or type out /dev/dm-1 than /dev/mapper/vg_centos6test-lv_swap.

Source(s)