本文打印版下载地址

[山外问道]Linux_UUID的查询方法-打印版.pdf

一、查询存储设备的UUID

1、使用blkid命令查看

(1)查询所有存储设备的UUID:blkid

(2)查询指定设备的UUID:blkid /dev/sda5

# blkid
/dev/sda1: UUID="9ADAAB4DDAAB250B" TYPE="ntfs"
/dev/sdb1: UUID="B2FCDCFBFCDCBAB5" TYPE="ntfs"
/dev/sdb5: UUID="46FC5C74FC5C5FEB" TYPE="ntfs"
/dev/sdb6: TYPE="swap" UUID="2cec6109-5bcf-45a3-ba1b-978b041c037f"
/dev/sdb8: UUID="9ee6f22d-b394-422c-9b4a-1525a3220942" SEC_TYPE="ext2" TYPE="ext3"
/dev/sdb7: UUID="4bcb9381-6e25-4304-8743-f882039ff3ad" TYPE="ext3"
2、使用vol_id查看
vol_id /dev/sda1
ID_FS_USAGE=filesystem
ID_FS_TYPE=reiserfs
ID_FS_VERSION=3.6
ID_FS_UUID=be6d8295-a1c4-48e9-b68d-f4b043cd5f2c
ID_FS_UUID_ENC=be6d8295-a1c4-48e9-b68d-f4b043cd5f2c
ID_FS_LABEL=
ID_FS_LABEL_ENC=
ID_FS_LABEL_SAFE=
3、查看by_uuid目录
ls -l /dev/disk/by-uuid
lrwxrwxrwx 1 root root 10 2008-05-15 22:37 2cec6109-5bcf-45a3-ba1b-978b041c037f -> ../../sdb6
lrwxrwxrwx 1 root root 10 2008-05-15 22:37 46FC5C74FC5C5FEB -> ../../sdb5
lrwxrwxrwx 1 root root 10 2008-05-15 22:37 4bcb9381-6e25-4304-8743-f882039ff3ad -> ../../sdb7
lrwxrwxrwx 1 root root 10 2008-05-15 22:37 9ee6f22d-b394-422c-9b4a-1525a3220942 -> ../../sdb8

二、查询网卡的UUID

1、使用nmcli命令查询

(1)安装NetworkManager依赖包:yum -y install NetworkManager

(2)启动NetworkManager服务:service NetworkManager start

(3)查看网卡的UUID:nmcli con

2、查看/etc/sysconfig/network-scripts/ifcfg-eth0文件查询UUID

通过查看/etc/sysconfig/network-scripts/ifcfg-eth0文件查询UUID,只有当ifcfg-eth0文件能正常查看时才有效。

cat /etc/sysconfig/network-scripts/ifcfg-eth0 | grep UUID

版权声明:本文为davidesun原创文章,遵循 CC 4.0 BY-SA 版权协议,转载请附上原文出处链接和本声明。
本文链接:https://www.cnblogs.com/davidesun/p/12765278.html