The UUID of a partition is required mainly for mounting the partitions correctly in a computer system where hundreds of hard drives are installed. If you mount the hard drives or SSDs using UUIDs, there is almost zero changes of the wrong hard drive getting mounted and causing serious data loss.
Our usual computers and laptops where mostly 1 or 2 hard drives are installed and we need limited number of partitions won’t benefit much from UUIDs.
In this article, I will show you how to find the UUID of storage devices such as hard drive or SSD partitions in Linux. So, let’s get started.
Finding UUID with blkid:
You can find the UUID of all the disk partitions on your Linux system with the blkid command. The blkid command is available by default on most modern Linux distributions.
To find the UUIDs of your disk partitions, run the following command:
As you can see, the filesystems that has UUID are displayed. A lot of loop devices are also listed.
In the earlier output, you have seen a lot of unnecessary loop devices. If you want to only list the filesystems that has UUID set, you may filter the output of the blkid command as follows:
You should be able to get a clean filtered output. Only the filesystems that has UUID set are listed.
Finding UUID with ls:
In Linux, all the devices including the storage devices are represented as files. So, the partitions with UUID set are also represented as files. You can list all these files with the ls command.
To list all the partitions and their UUIDs, run the following command:
As you can see, the partition name (i.e. sda1, sda2) and their UUIDs are listed.
Finding UUID with lsblk:
You can also list the UUID of your partitions with the lsblk command:
For example, to list UUID of your partitions with the lsblk command, run lsblk as follows:
As you can see, the UUIDs of the partitions are listed.
You can filter out all the loop devices to make the output cleaner as well. To do that, run the lsblk command as follows:
As you can see, only the partitions with UUID are listed. The output is now much cleaner.
Where to Go Next:
Now that you know how to find the UUID of the storage devices in Linux, you can learn how to mount the partitions with UUID. I have written a dedicated article on how to mount partitions with UUID using the /etc/fstab file. You can read it at https://linuxhint.com/mount_partition_uuid_label_linux/
So, that’s how you find the UUID of storage devices in Linux. Thanks for reading this article.