在Linux下可以使用blkid命令查看块设备(包括交换分区)的文件系统类型、LABEL、UUID、挂载目录等信息。
直接使用blkid可列出当前系统中所以已挂载文件系统的类型。
zhangnq@hdslave3:/data2$ sudo blkid /dev/sda1: UUID="a85fc8c2-2d7c-4da9-a414-d374ea668ea7" TYPE="ext4" /dev/sda2: UUID="0463965f-dd67-41ca-a29b-770fe59ce9db" TYPE="swap" /dev/sda3: UUID="b24abcf4-b6a5-4aa2-b713-c7f423d35da6" TYPE="ext4" /dev/sda5: UUID="8bcb6585-0c62-4770-952d-7b43f4936e63" TYPE="ext4" /dev/sda6: UUID="e2158acf-458c-4243-a41e-f4b4bd1d1eaf" TYPE="ext4" /dev/sda7: UUID="e2179a7a-ad3e-4005-8680-88c5f612a95a" TYPE="ext4" /dev/sda8: UUID="606edb07-4ad9-4af2-956d-4a14020b4113" TYPE="ext4" /dev/sda9: UUID="60fb265b-b0ab-41dc-9c3c-a6fbb4a2f8a3" TYPE="ext4" /dev/sdb1: UUID="cda52f13-9c6b-4b0e-98cd-ef7b112fb824" TYPE="ext4" /dev/mapper/36782bcb041f13100169fee0c13bb4ea3-part1: UUID="cda52f13-9c6b-4b0e-98cd-ef7b112fb824" TYPE="ext4" /dev/sdd1: UUID="540eb885-1bd7-455e-a2cc-2d8bc641dc37" TYPE="ext4" /dev/sdc1: UUID="3c110161-24d0-4621-87dc-c63bc1b211f2" TYPE="ext4" /dev/sde1: UUID="50237c19-2a30-42be-9934-39fb7a4f3db6" TYPE="ext4" /dev/mapper/36782bcb000447e50000002e54f0ce147-part1: UUID="3c110161-24d0-4621-87dc-c63bc1b211f2" TYPE="ext4" /dev/mapper/36782bcb000447e50000002dd4f0ce0d2-part1: UUID="540eb885-1bd7-455e-a2cc-2d8bc641dc37" TYPE="ext4" /dev/mapper/36782bcb000447e50000002e14f0ce0fd-part1: UUID="50237c19-2a30-42be-9934-39fb7a4f3db6" TYPE="ext4"
当然,也可以查看指定设备(如/dev/sda1)所采用的文件系统类型。
zhangnq@hdslave3:/data2$ sudo blkid /dev/sda1 /dev/sda1: UUID="a85fc8c2-2d7c-4da9-a414-d374ea668ea7" TYPE="ext4"
blkid的主要参数
-c <file> 指定cache文件(default: /etc/blkid.tab, /dev/null = none) -d don't encode non-printing characters -h 显示帮助信息 -g garbage collect the blkid cache -o <format> 指定输出格式 -k list all known filesystems/RAIDs and exit -s <tag> 显示指定信息,默认显示所有信息 -t <token> find device with a specific token (NAME=value pair) -l look up only first device with token specified by -t -L <label> convert LABEL to device name -U <uuid> convert UUID to device name -v 显示版本信息 -w <file> write cache to different file (/dev/null = no write) <dev> specify device(s) to probe (default: all devices) Low-level probing options: -p low-level superblocks probing (bypass cache) -i gather information about I/O limits -S <size> overwrite device size -O <offset> probe at the given offset -u <list> filter by "usage" (e.g. -u filesystem,raid) -n <list> filter by filesystem type (e.g. -n vfat,ext3)
blkid的应用实例
1、列出当前系统中所有已挂载文件系统的类型
sudo blkid
2、显示指定设备 UUID
sudo blkid -s UUID /dev/sda5
3、显示所有设备 UUID
sudo blkid -s UUID
4、显示指定设备 LABEL
sudo blkid -s LABEL /dev/sda5
5、显示所有设备 LABEL
sudo blkid -s LABEL
6、显示所有设备文件系统
sudo blkid -s TYPE
7、显示所有设备
sudo blkid -o device
8、以列表方式查看详细信息
sudo blkid -o list
获取linux raid存储盘符和挂载点的关系
如果服务器挂载了存储,使用df -lh可能很难发现存储盘符(sda, sdb, sdc…)与挂载点的对应关系。这里可以先使用blkid找到某个盘符的uuid,然后查找fstab即可找到对应的挂载点。
zhangnq@hdslave3:/data2$ sudo blkid /dev/sdd1 /dev/sdd1: UUID="540eb885-1bd7-455e-a2cc-2d8bc641dc37" TYPE="ext4" zhangnq@hdslave3:/data2$ grep "540eb885-1bd7-455e-a2cc-2d8bc641dc37" /etc/fstab UUID=540eb885-1bd7-455e-a2cc-2d8bc641dc37 /data2 ext4 atime,data=writeback,barrier=0,nobh,nobootwait,errors=remount-ro 0 2
如上所示,可以清楚的知道/data2这个目录是挂载到/dev/sdd1这个存储设备上的。
参考链接:http://www.cnblogs.com/dkblog/archive/2011/08/30/2159630.html