UUID为系统中的存储设备提供唯一的标识字符串,在 /etc/fstab 文件中会用到 UUID,用于硬盘的挂载。如果你在系统中启动的时候,使用盘符挂载时,可能找不到设备而加载失败,而使用UUID挂载时,则不会有这样的问题。 [[email protected] ~]# cat /etc/fstab # # /etc/fstab # Created by anaconda on Mon Apr 17 17:18:23 2017 # # Accessible filesystems, by reference, are maintained under ‘/dev/disk‘ # See man pages fstab(5), findfs(8), mount(8) and/or blkid(8) for more info # UUID=145e78f2-a12c-4221-848e-f6deee8bd4ed / ext4 defaults 1 1 UUID=37450e3e-9017-4517-88bc-6a38d8819f03 /boot ext4 defaults 1 2 UUID=7f382385-308c-4684-a8d3-651ee16836f7 swap swap defaults 0 0 tmpfs /dev/shm tmpfs defaults 0 0 devpts /dev/pts devpts gid=5,mode=620 0 0 sysfs /sys sysfs defaults 0 0 proc /proc proc defaults 0 0 LABEL=/data2 /data2 ext4 defaults 0 0 那么怎么知道相应设备的 UUID 呢? 1、blkid命令查看: [[email protected] ~]# blkid /dev/sda3: UUID="356d4065-9613-490e-a22f-f7c1a7b85d84" TYPE="ext4" /dev/sda1: UUID="cb053b9d-9ef8-48e3-8227-683c62d937f6" TYPE="ext4" /dev/sdb1: LABEL="/data2" UUID="29762eb6-8c19-484d-a46b-424c4050a47b" TYPE="ext4" 另一台服务器: [[email protected] ~]# sudo blkid /dev/sda3:UUID="145e78f2-a12c-4221-848e-f6deee8bd4ed" TYPE="ext4" /dev/sdb1: LABEL="/data2"UUID="608befbb-c55a-4a48-9a2e-9bc64407a85f" TYPE="ext4" /dev/sda1:UUID="37450e3e-9017-4517-88bc-6a38d8819f03" TYPE="ext4" /dev/sda2:UUID="7f382385-308c-4684-a8d3-651ee16836f7" TYPE="swap" 2、文件方式式查看:ls -l /dev/disk/by-uuid [[email protected] ~]# ls -l /dev/disk/by-uuid total 0 lrwxrwxrwx 1 root root 10 Apr 18 14:20 145e78f2-a12c-4221-848e-f6deee8bd4ed -> ../../sda3 lrwxrwxrwx 1 root root 10 Apr 18 14:20 37450e3e-9017-4517-88bc-6a38d8819f03 -> ../../sda1 lrwxrwxrwx 1 root root 10 Apr 18 14:20 608befbb-c55a-4a48-9a2e-9bc64407a85f -> ../../sdb1 lrwxrwxrwx 1 root root 10 Apr 18 14:20 7f382385-308c-4684-a8d3-651ee16836f7 -> ../../sda2 3、命令查看:tune2fs -l /dev/sda1 (需要一个一个设备查看) [[email protected] ~]# tune2fs -l /dev/sda1 tune2fs 1.41.12 (17-May-2010) Filesystem volume name: <none> Last mounted on: /boot Filesystem UUID: cb053b9d-9ef8-48e3-8227-683c62d937f6 Filesystem magic number: 0xEF53 Filesystem revision #: 1 (dynamic) Filesystem features: has_journal ext_attr resize_inode dir_index filetype needs_recovery extent flex_bg sparse_super huge_file uninit_bg dir_nlink extra_isize Filesystem flags: signed_directory_hash Default mount options: user_xattr acl Filesystem state: clean Errors behavior: Continue Filesystem OS type: Linux Inode count: 76912 Block count: 307200 Reserved block count: 15360 Free blocks: 250470 Free inodes: 76873 First block: 1 Block size: 1024 Fragment size: 1024 Reserved GDT blocks: 256 Blocks per group: 8192 Fragments per group: 8192 Inodes per group: 2024 Inode blocks per group: 253 Flex block group size: 16 Filesystem created: Mon Apr 17 10:16:56 2017 Last mount time: Mon Apr 17 14:45:47 2017 Last write time: Mon Apr 17 14:45:47 2017 Mount count: 5 Maximum mount count: -1 Last checked: Mon Apr 17 10:16:56 2017 Check interval: 0 (<none>) Lifetime writes: 50 MB Reserved blocks uid: 0 (user root) Reserved blocks gid: 0 (group root) First inode: 11 Inode size: 128 Journal inode: 8 Default directory hash: half_md4 Directory Hash Seed: 6bf9c3ca-7632-41b1-ad64-375f0623d35c Journal backup: inode blocks
时间: 2024-09-28 17:33:40