UUID (Universally Unique Identifier) is utilized for the unique identification of partition disks in the operating system. The UUID is mainly considered in scenarios when the user has a bunch of hard drives installed and wants to extend, mount or delete any particular disk partition.
This post will cover the different methods to view all UUIDs of the disks in the Linux operating system.
- Method 1: Through the blkid Command
- Method 2: Through the lsblk Command
- Method 3: Through the ls Command
- Method 4: Through the hwinfo Command
- Method 5: Through udevadm Command | Name Specific
- Method 6: Through the tune2fs Command | Name Specific
- Method 7: Through the dumpe2fs Command | Name Specific
Method 1: Through the blkid Command
The user can consider the blkid command in order to view the UUID of all the disk partitions. The blkid is a utility used for listing the available block devices with information such as filesystem type, name, UUID, block size, etc. To view all UUIDs for all available devices, run the blkid command in the terminal:
$ blkid
The /dev/sda3 has the unique UUID=“9264bdd7-252d-4e9f-be1c-f8511eef789c”, /dev/sr0 has UUID=”2023-02-25-17-53-58-00” while the /dev/sda2 has UUID= “63A5-7890”.
If the user wants to only display the UUID-related information, match the grep pattern of UUID as shown:
$ blkid | grep UUID
The UUID pattern is matched and UUID for all available disks is listed.
Method 2: Through the lsblk Command
The lsblk is the utility that also lists the information of all the available block devices with name, type, mount point, UUID, etc. The following lsblk command displays the only “name”, “mount point”, size, and UUID column:
$ lsblk -o name,mountpoint,size,uuid
The UUID for /dev/sda2 is “63A5-7890”, /dev/sda3 is “9264bdd7-252d-4e9f-be1c-f8511eef789c”. /dev/sr0 is “2023-02-25-17-53-58-00” and /dev/sr1 is “2022-04-19-10-23-19-00”.
Method 3: Through the ls Command
In Linux, all devices, as well as storage devices, are treated as files that are symbolically linked. So their partitions and UUIDs are also treated as files. The user can list them Through the ls command to view the UUIDs of all available disks. To do so, run the below-given command:
$ ls -l /dev/disk/by-uuid
The user can clearly see the UUID for the partition “sr1” is “2022-04-19-10-23-19-00”, “sr0” is “2023-02-25-17-53-58-00”, “sda2” is “63A5-7890” and “sda3” is “9264bdd7-252d-4e9f-be1c-f8511eef789c”.
Method 4: Through the hwinfo Command
The “hwinfo” is the command considered for getting the hardware information of the system. To install it in the operating system, run the given command based on the Linux distribution:
$ sudo apt install hwinfo #Debian/Ubuntu
$ sudo yum install hwinfo #RHEL/CentOS
$ sudo dnf install hwinfo #Fedora
$ sudo pacman -s hwinfo #Manjora/Arch
To display the UUID for all available disks, run the “hwinfo” command with “block” flag for the block devices and grep command to match the pattern “by-uuid”:
$ hwinfo --block | grep by-uuid
The UUIDs for all the disk partitions are listed as highlighted in the above image.
Method 5: Through udevadm Command | Name Specific
The “udevadm” is run as a daemon of Linux that listens to the user events that the Kernel sends out when the new device is initialized or removed. For this, use the “udevadm” command to obtain the UUID of the particular disk partition “/dev/sda2” as below:
$ udevadm info -q all -n /dev/sda2 | grep -i by-uuid | head -1
The above command has displayed the UUID for the device “/dev/sda2” which is “63A5-7890”.
Likewise, in order to obtain the UUID for the partitions “/dev/sda3”, the following command is carried out:
$ udevadm info -q all -n /dev/sda3 | grep -i by-uuid | head -1
The UUID for the partition “/dev/sda3” is “9264bdd7-252d-4e9f-be1c-f8511eef789c”.
Method 6: Through the tune2fs Command | Name Specific
The “tune2fs” is the Linux command used for changing the file system parameters (ext2, ext3, and ext4 only) of the disk partitions. The UUID for the particular partition can be obtained by defining the partition name as “/dev/sda3” with the “l” flag and grep command to match the pattern:
$ sudo tune2fs -l /dev/sda3 | grep UUID
The UUID for the partition /dev/sda3 is “9264bdd7-252d-4e9f-be1c-f8511eef789c”.
Method 7: Through the dumpe2fs Command | Name Specific
The last method that the user can consider to view UUIDs for all available disks is to use the “dumpe2fs” command. It is utilized for displaying the superblock and group information of the file system available on the device. Run the “dumpe2fs” command with sudo permission and specify the name of the disk partition as defined below:
$ sudo dumpe2fs /dev/sda3 | grep UUID
The UUID for disk partition “/dev/sda3” is “9264bdd7-252d-4e9f-be1c-f8511eef789c”.
Conclusion
To view all UUIDs for all available disks on the Linux operating system, use the “blkid”, “lsblk”, “ls”, “hwinfo”, “udevadm”, “tune2fs”, “dumpe2fs” commands. The “hwinfo” command can be installed manually while “udevadm”, “tune2fs”, and “dumpe2fs” are built-in commands of Linux.
This write-up has illuminated all the possible methods to view UUIDs of the partition disk available in the Linux operating system.