Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

How to get the UUID of hard disk partition or file system in Linux

2025-01-19 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >

Share

Shulou(Shulou.com)06/01 Report--

This article shows you how to get the UUID of the hard disk partition or file system in Linux. The content is concise and easy to understand, which will definitely brighten your eyes. I hope you can get something through the detailed introduction of this article.

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 UUID. In this article we will show you a variety of ways to view UUID, and you can choose one that is right for you.

What is UUID?

UUID means universal unique identifier Universally Unique Identifier, which helps Linux systems identify a disk partition rather than a block device file. Since kernel 2.15.1, libuuid has been part of the util-linux-ng package and is installed on Linux systems by default. UUID is generated by this library, and it is reasonable to think that UUID is unique in one system and unique in all systems. This is a 128-bit number used to identify information in a computer system. UUID was originally used in the network computer system Apollo Network Computing System (NCS), and then UUID was standardized by the Open Software Foundation Open Software Foundation (OSF) and became a part of the distributed computing environment Distributed Computing Environment (DCE).

UUID is represented by 32 hexadecimal numbers and is divided into 5 groups of hyphens. The total 36 characters are in the format of 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 1UUID=a2092b92-af29-4760-8e68-7a201922573b swap swap defaults,noatime 0 2

We can use the following seven commands to see.

Blkid command: locate or print the attributes of a block device.

Lsblk command: lists information for all available or specified block devices.

Hwinfo command: hardware information tool, another good utility for querying existing hardware in the system.

Udevadm command: udev management tool

Tune2fs command: adjusts the tunable file system parameters on the ext2/ext3/ext4 file system.

Dumpe2fs command: query information about the ext2/ext3/ext4 file system.

Use the by-uuid path: this directory contains the UUID and the actual block device file, and the UUID is linked to the actual block device file.

How can I 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 properties of block devices. It uses the libblkid library to obtain the UUID of 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 can I 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. By default, this command prints out all block devices (except RAM disks) in a tree-like format.

# lsblk-o name,mountpoint,size,uuidNAME MOUNTPOINT SIZE UUIDsda 30G └─ sda1 / 20G d92fa769-e00f-4fd7-b6ed-ecf7224af7fasdb 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 can I use the by-uuid path in Linux to view the UUID of a disk partition or file system?

This directory contains the UUID and the actual block device file, and the UUID is linked to the actual block device file.

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

How can I use the hwinfo command to view the UUID of a disk partition or file system in Linux?

Hwinfo, which means hardware information tool, is another good utility. It is used to detect the existing hardware in the system and to display the details of various hardware components in a readable format.

# hwinfo-- block | grep by-uuid | awk'{print $3 recording 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 can I 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-1s: disk/by-uuid/d17e3c31-e2c9-4f11-809c-94a549bc43b7

How can I use the tune2fs command to view the UUID of a disk partition or file system in Linux?

Tune2fs allows system administrators to adjust various tunable file system parameters in Linux's ext2, ext3, and ext4 file systems. The current values of these options can be displayed using the option-l.

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

How can I use the dumpe2fs command to view the UUID of a disk partition or file system in Linux?

Dumpe2fs prints information about super blocks and block groups that appear in the device file system.

# dumpe2fs / dev/sdc1 | grep UUIDdumpe2fs 1.43.5 (04-Aug-2017) Filesystem UUID: d17e3c31-e2c9-4f11-809c-94a549bc43b7 the above content is how to obtain the UUID of hard disk partition or file system in Linux. Have you learned any knowledge or skills? If you want to learn more skills or enrich your knowledge reserve, you are welcome to follow the industry information channel.

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Servers

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report