Linux 系统lsblk和blkid命令
lsblk命令用于以树状的格式显示所有可用的块设备信息:
[root@rhel7 ~]# lsblk NAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINT sda 8:0 0 10G 0 disk ├─sda1 8:1 0 500M 0 part /boot └─sda2 8:2 0 9.5G 0 part ├─rhel-root 253:0 0 8.5G 0 lvm / └─rhel-swap 253:1 0 1G 0 lvm [SWAP] sdb 8:16 0 5G 0 disk ├─sdb1 8:17 0 500M 0 part /lxjtest └─sdb2 8:18 0 200M 0 part [SWAP] sr0 11:0 1 3.8G 0 rom /run/media/root/RHEL-7.2 Server.x86_64
NAME —— 设备的名称
MAJ:MIN —— Linux 操作系统中的每个设备都以一个文件表示,对块(磁盘)设备来说,这里用主次设备编号来描述设备。
RM —— 可移动设备。如果这是一个可移动设备将显示 1,否则显示 0。
TYPE —— 设备的类型
MOUNTPOINT —— 设备挂载的位置
RO —— 对于只读文件系统,这里会显示 1,否则显示 0。
SIZE —— 设备的容量
[root@rhel7 ~]# lsblk -m --查看设备所有者相关信息 NAME SIZE OWNER GROUP MODE sda 10G root disk brw-rw---- ├─sda1 500M root disk brw-rw---- └─sda2 9.5G root disk brw-rw---- ├─rhel-root 8.5G root disk brw-rw---- └─rhel-swap 1G root disk brw-rw---- sdb 5G root disk brw-rw---- ├─sdb1 500M root disk brw-rw---- └─sdb2 200M root disk brw-rw---- sr0 3.8G root cdrom brw-rw---- [root@rhel7 ~]# lsblk -l --以非树状图的形式输出 NAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINT sda 8:0 0 10G 0 disk sda1 8:1 0 500M 0 part /boot sda2 8:2 0 9.5G 0 part rhel-root 253:0 0 8.5G 0 lvm / rhel-swap 253:1 0 1G 0 lvm [SWAP] sdb 8:16 0 5G 0 disk sdb1 8:17 0 500M 0 part /lxjtest sdb2 8:18 0 200M 0 part [SWAP] sr0 11:0 1 3.8G 0 rom /run/media/root/RHEL-7.2 Server.x86_64 [root@rhel7 ~]# lsblk -ln --剔除表头 sda 8:0 0 10G 0 disk sda1 8:1 0 500M 0 part /boot sda2 8:2 0 9.5G 0 part rhel-root 253:0 0 8.5G 0 lvm / rhel-swap 253:1 0 1G 0 lvm [SWAP] sdb 8:16 0 5G 0 disk sdb1 8:17 0 500M 0 part /lxjtest sdb2 8:18 0 200M 0 part [SWAP] sr0 11:0 1 3.8G 0 rom /run/media/root/RHEL-7.2 Server.x86_64 [root@rhel7 ~]#
blkid 输出所有可用的设备、通用唯一识别码(UUID)、文件系统类型以及卷标
[root@rhel7 ~]# blkid /dev/sda1: UUID="4f396f9a-467e-4472-a654-836f2dc7d6ca" TYPE="xfs" /dev/sda2: UUID="9xAZf0-rSus-Nm2c-VJXR-a0jb-Vvvc-4F7DGF" TYPE="LVM2_member" /dev/sr0: UUID="2015-10-30-11-11-49-00" LABEL="RHEL-7.2 Server.x86_64" TYPE="iso9660" PTTYPE="dos" /dev/mapper/rhel-root: UUID="886109ea-eb04-49ed-ae1b-5f1372d02f17" TYPE="xfs" /dev/mapper/rhel-swap: UUID="6c591a1c-dbbb-47e3-9d05-214bdf687ee5" TYPE="swap" /dev/sdb1: UUID="f0aba00c-c58b-4522-85d3-636073cbd023" TYPE="xfs" /dev/sdb2: UUID="4746286f-4680-4a05-878d-118fff5904ac" TYPE="swap" [root@rhel7 ~]# blkid -s UUID /dev/sda2 #显示指定设备 UUID /dev/sda2: UUID="9xAZf0-rSus-Nm2c-VJXR-a0jb-Vvvc-4F7DGF" [root@rhel7 ~]# blkid -s UUID #所有所有设备的UUID /dev/sda1: UUID="4f396f9a-467e-4472-a654-836f2dc7d6ca" /dev/sda2: UUID="9xAZf0-rSus-Nm2c-VJXR-a0jb-Vvvc-4F7DGF" /dev/sr0: UUID="2015-10-30-11-11-49-00" /dev/mapper/rhel-root: UUID="886109ea-eb04-49ed-ae1b-5f1372d02f17" /dev/mapper/rhel-swap: UUID="6c591a1c-dbbb-47e3-9d05-214bdf687ee5" /dev/sdb1: UUID="f0aba00c-c58b-4522-85d3-636073cbd023" /dev/sdb2: UUID="4746286f-4680-4a05-878d-118fff5904ac" [root@rhel7 ~]# blkid -s LABEL #显示所有设备 LABEL /dev/sr0: LABEL="RHEL-7.2 Server.x86_64" [root@rhel7 ~]# blkid -s LABEL /dev/sr0 #显示指定设备 LABEL /dev/sr0: LABEL="RHEL-7.2 Server.x86_64" [root@rhel7 ~]# blkid -s TYPE #显示所有设备文件系统 /dev/sda1: TYPE="xfs" /dev/sda2: TYPE="LVM2_member" /dev/sr0: TYPE="iso9660" /dev/mapper/rhel-root: TYPE="xfs" /dev/mapper/rhel-swap: TYPE="swap" /dev/sdb1: TYPE="xfs" /dev/sdb2: TYPE="swap" [root@rhel7 ~]# blkid -o device #显示所有设备 /dev/sda1 /dev/sda2 /dev/sr0 /dev/mapper/rhel-root /dev/mapper/rhel-swap /dev/sdb1 /dev/sdb2 [root@rhel7 ~]# blkid -o list #以列表方式查看详细信息 device fs_type label mount point UUID ---------------------------------------------------------------------------------------------------------------------------------------------------------------------- /dev/sda1 xfs /boot 4f396f9a-467e-4472-a654-836f2dc7d6ca /dev/sda2 LVM2_member (in use) 9xAZf0-rSus-Nm2c-VJXR-a0jb-Vvvc-4F7DGF /dev/sr0 iso9660 RHEL-7.2 Server.x86_64 /run/media/root/RHEL-7.2 Server.x86_64 2015-10-30-11-11-49-00 /dev/mapper/rhel-root xfs / 886109ea-eb04-49ed-ae1b-5f1372d02f17 /dev/mapper/rhel-swap swap <swap> 6c591a1c-dbbb-47e3-9d05-214bdf687ee5 /dev/sdb1 xfs /lxjtest f0aba00c-c58b-4522-85d3-636073cbd023 /dev/sdb2 swap <swap> 4746286f-4680-4a05-878d-118fff5904ac [root@rhel7 ~]#
*******VICTORY LOVES PREPARATION*******