7 Methods to identify Disk Partition/FileSystem UUID in Linux

As a Linux administrator you should aware of that how do you check partition UUID or filesystem UUID.

Because most of the Linux systems are mount the partitions with UUID. The same has been verified in the /etc/fstab file.

There are many utilities available to check UUID. In this article we will show you how to check UUID in many ways and you can choose the one which is suitable for you.

What is UUID?

UUID stands for Universally Unique Identifier which helps Linux system to identify a hard drives partition instead of block device file.

libuuid is part of the util-linux-ng package since kernel version 2.15.1 and it’s installed by default in Linux system.

The UUIDs generated by this library can be reasonably expected to be unique within a system, and unique across all systems.

It’s a 128 bit number used to identify information in computer systems. UUIDs were originally used in the Apollo Network Computing System (NCS) and later UUIDs are standardized by the Open Software Foundation (OSF) as part of the Distributed Computing Environment (DCE).

UUIDs are represented as 32 hexadecimal (base 16) digits, displayed in five groups separated by hyphens, in the form 8-4-4-4-12 for a total of 36 characters (32 alphanumeric characters and four hyphens).

For example: d92fa769-e00f-4fd7-b6ed-ecf7224af7fa

Sample of my /etc/fstab file.

#  cat /etc/fstab

# /etc/fstab: static file system information.
#
# Use 'blkid' to print the universally unique identifier for a device; this may
# be used with UUID= as a more robust way to name devices that works even if
# disks are added and removed. See fstab(5).
#
#                    
UUID=69d9dd18-36be-4631-9ebb-78f05fe3217f /              ext4    defaults,noatime 0 1
UUID=a2092b92-af29-4760-8e68-7a201922573b swap           swap    defaults,noatime 0 2

We can check this using the following seven commands.

  • blkid Command: locate/print block device attributes.
  • lsblk Command: lsblk lists information about all available or the specified block devices.
  • hwinfo Command:  hwinfo stands for hardware information tool and great utility that used to probe for the hardware present in the system.
  • udevadm Command: udev management tool.
  • tune2fs Command: adjust tunable filesystem parameters on ext2/ext3/ext4 filesystems.
  • dumpe2fs Command: dump ext2/ext3/ext4 filesystem information.
  • Using by-uuid Path: The directory contains UUID and real block device files, UUIDs were symlink with real block device files.

How to check Disk Partition/FileSystem UUID in Linux using blkid Command?

blkid is a command-line utility to locate/print block device attributes. It uses libblkid library to get disk partition UUID in Linux system.

# blkid
/dev/sda1: UUID="d92fa769-e00f-4fd7-b6ed-ecf7224af7fa" TYPE="ext4" PARTUUID="eab59449-01"
/dev/sdc1: UUID="d17e3c31-e2c9-4f11-809c-94a549bc43b7" TYPE="ext2" PARTUUID="8cc8f9e5-01"
/dev/sdc3: UUID="ca307aa4-0866-49b1-8184-004025789e63" TYPE="ext4" PARTUUID="8cc8f9e5-03"
/dev/sdc5: PARTUUID="8cc8f9e5-05"

How to check Disk Partition/FileSystem UUID in Linux using lsblk Command?

lsblk lists information about all available or specified block devices. The lsblk command reads the sysfs filesystem and udev db to gather information.

If the udev db is not available or lsblk is compiled without udev support than it tries to read LABELs, UUIDs and filesystem types from the block device. In this case root permissions are necessary. The command prints all block devices (except RAM disks) in a tree-like format by default.

# lsblk -o name,mountpoint,size,uuid
NAME   MOUNTPOINT  SIZE UUID
sda                 30G 
└─sda1 /            20G d92fa769-e00f-4fd7-b6ed-ecf7224af7fa
sdb                 10G 
sdc                 10G 
├─sdc1               1G d17e3c31-e2c9-4f11-809c-94a549bc43b7
├─sdc3               1G ca307aa4-0866-49b1-8184-004025789e63
├─sdc4               1K 
└─sdc5               1G 
sdd                 10G 
sde                 10G 
sr0               1024M 

How to check Disk Partition/FileSystem UUID in Linux using by-uuid path?

The directory contains UUID and real block device files, UUIDs were symlink with real block device files.

# ls -lh /dev/disk/by-uuid/
total 0
lrwxrwxrwx 1 root root 10 Jan 29 08:34 ca307aa4-0866-49b1-8184-004025789e63 -> ../../sdc3
lrwxrwxrwx 1 root root 10 Jan 29 08:34 d17e3c31-e2c9-4f11-809c-94a549bc43b7 -> ../../sdc1
lrwxrwxrwx 1 root root 10 Jan 29 08:34 d92fa769-e00f-4fd7-b6ed-ecf7224af7fa -> ../../sda1

How to check Disk Partition/FileSystem UUID in Linux using hwinfo Command?

hwinfo stands for hardware information tool is another great utility that used to probe for the hardware present in the system and display detailed information about varies hardware components in human readable format.

# hwinfo --block | grep by-uuid | awk '{print $3,$7}'
/dev/sdc1, /dev/disk/by-uuid/d17e3c31-e2c9-4f11-809c-94a549bc43b7
/dev/sdc3, /dev/disk/by-uuid/ca307aa4-0866-49b1-8184-004025789e63
/dev/sda1, /dev/disk/by-uuid/d92fa769-e00f-4fd7-b6ed-ecf7224af7fa

How to check Disk Partition/FileSystem UUID in Linux using udevadm Command?

udevadm expects a command and command specific options. It controls the runtime behavior of systemd-udevd, requests kernel events, manages the event queue, and provides simple debugging mechanisms.

udevadm info -q all -n /dev/sdc1 | grep -i by-uuid | head -1
S: disk/by-uuid/d17e3c31-e2c9-4f11-809c-94a549bc43b7

How to check Disk Partition/FileSystem UUID in Linux using tune2fs Command?

tune2fs allows the system administrator to adjust various tunable filesystem parameters on Linux ext2, ext3, or ext4 filesystems. The current values of these options can be displayed by using the -l option.

# tune2fs -l /dev/sdc1 | grep UUID
Filesystem UUID:          d17e3c31-e2c9-4f11-809c-94a549bc43b7

How to check Disk Partition/FileSystem UUID in Linux using dumpe2fs Command?

dumpe2fs prints the super block and blocks group information for the filesystem present on device.

# dumpe2fs /dev/sdc1 | grep UUID
dumpe2fs 1.43.5 (04-Aug-2017)
Filesystem UUID:          d17e3c31-e2c9-4f11-809c-94a549bc43b7

About Magesh Maruthamuthu

Love to play with all Linux distribution

View all posts by Magesh Maruthamuthu

Leave a Reply

Your email address will not be published. Required fields are marked *