As a Linux system administrator, you should know how to view the UUID of a partition or the UUID of a file system. Because most Linux systems now use UUID to mount partitions. You can verify it in the / etc/fstab} file.
There are many utilities available to view UUIDs. In this article, we will show you a variety of ways to view UUIDs, and you can choose a method suitable for you.
What is UUID?
UUID means universal unique identifier, which can help Linux system identify a disk partition rather than a block device file.
From kernel 2.15 Since 1, libuuid is a part of util Linux ng package, which is installed in Linux system by default. The UUID is generated by the library. It can be reasonably considered that the UUID is unique in one system and unique in all systems.
This is a 128 bit number used to identify information in the computer system. UUID was originally used in Apollo Network Computing System (NCS), and then it was standardized by the Open Software Foundation (OSF) and became part of the Distributed Computing Environment (DCE).
UUID is represented by 32 hexadecimal digits and is divided into 5 groups by hyphens. The format of a total of 36 characters is 8-4-4-4-12 (32 letters or numbers and 4 hyphens).
For example: d92fa769-e00f-4fd7-b6ed-ecf7224af7fa
Example 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 use the following seven commands to view.
- blkid} command: locate or print the attributes of the block device.
- lsblk} command: lists information about all available or specified block devices.
- hwinfo command: hardware information tool. It is another good practical tool for querying the existing hardware in the system.
- udevadm; command: udev management tool
- tune2fs} command: adjust tunable file system parameters on ext2/ext3/ext4 file systems.
- Dump2fs} command: query the information of ext2/ext3/ext4 file system.
- Use {by UUID} path: this directory contains UUID and actual block device files, and UUID is linked with the actual block device files.
How to use the blkid command to view the UUID of a disk partition or file system in Linux?
blkid} is a command line utility that locates or prints block device properties. It uses the libblkid library to obtain the UUID of the disk partition in the 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 use the lsblk command to view the UUID of a disk partition or file system in Linux?
Lsblk{lists all information about available or specified block devices. The lsblk} command reads the sysfs file system and udev database to collect information.
If the udev database is not available or the compiled lsblk does not support udev, it attempts to read the volume label, UUID, and file system type from the block device. In this case, you must run as root. This command will print out all block devices (except RAM disk) 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 use the by UUID path to view the UUID of a disk partition or file system in Linux?
This directory contains the UUID and the actual block device file, and the UUID is linked with the actual block device file.
# 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 use hwinfo command to view UUID of disk partition or file system in Linux?
hwinfo [1] It means hardware information tool, which is another good practical tool. It is used to detect the existing hardware in the system and display the details of various hardware components in a 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 use the udevadm command to view the UUID of a disk partition or file system in Linux?
udevadm requires commands and command specific actions. It controls the runtime behavior of SYSTEMd udevd, requests kernel events, manages event queues, and provides a simple debugging mechanism.
# udevadm info -q all -n /dev/sdc1 | grep -i by-uuid | head -1 S: disk/by-uuid/d17e3c31-e2c9-4f11-809c-94a549bc43b7
How to use the tune2fs command to view the UUID of a disk partition or file system in Linux?
tune2fs allows system administrators to adjust various adjustable file system parameters in Linux's ext2, ext3, ext4 file systems. The current values of these options can be displayed using option -l#.
# tune2fs -l /dev/sdc1 | grep UUID Filesystem UUID: d17e3c31-e2c9-4f11-809c-94a549bc43b7
How to use the dump2fs command to view the UUID of a disk partition or file system in Linux?
Dump2fs prints information about superblocks and block groups that appear in the device file system.
# dumpe2fs /dev/sdc1 | grep UUID dumpe2fs 1.43.5 (04-Aug-2017) Filesystem UUID: d17e3c31-e2c9-4f11-809c-94a549bc43b7
via: https://www.2daygeek.com/check-partitions-uuid-filesystem-uuid-universally-unique-identifier-linux/