mirror of
https://github.com/LCTT/TranslateProject.git
synced 2024-12-26 21:30:55 +08:00
160 lines
7.0 KiB
Markdown
160 lines
7.0 KiB
Markdown
|
[#]: collector: (lujun9972)
|
|||
|
[#]: translator: ( )
|
|||
|
[#]: reviewer: ( )
|
|||
|
[#]: publisher: ( )
|
|||
|
[#]: url: ( )
|
|||
|
[#]: subject: (7 Methods To Identify Disk Partition/FileSystem UUID On Linux)
|
|||
|
[#]: via: (https://www.2daygeek.com/check-partitions-uuid-filesystem-uuid-universally-unique-identifier-linux/)
|
|||
|
[#]: author: (Magesh Maruthamuthu https://www.2daygeek.com/author/magesh/)
|
|||
|
|
|||
|
7 Methods To Identify Disk Partition/FileSystem UUID On 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 are 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 is another 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 Uusing 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 Uusing lsblk Command?
|
|||
|
|
|||
|
lsblk lists information about all available or the 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 Uusing 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 Uusing hwinfo Command?
|
|||
|
|
|||
|
**[hwinfo][1]** 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 Uusing 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 Uusing 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 Uusing 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
|
|||
|
```
|
|||
|
|
|||
|
--------------------------------------------------------------------------------
|
|||
|
|
|||
|
via: https://www.2daygeek.com/check-partitions-uuid-filesystem-uuid-universally-unique-identifier-linux/
|
|||
|
|
|||
|
作者:[Magesh Maruthamuthu][a]
|
|||
|
选题:[lujun9972][b]
|
|||
|
译者:[译者ID](https://github.com/译者ID)
|
|||
|
校对:[校对者ID](https://github.com/校对者ID)
|
|||
|
|
|||
|
本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出
|
|||
|
|
|||
|
[a]: https://www.2daygeek.com/author/magesh/
|
|||
|
[b]: https://github.com/lujun9972
|
|||
|
[1]: https://www.2daygeek.com/hwinfo-check-display-detect-system-hardware-information-linux/
|