lsblk命令用来查看block设备的信息.
主要应用场景: 获取wwnid,获取块设备列表,获取块设备类型(ssd,hdd),获取块设备的size等信息.
数据来源: /sys/dev/block
返回码:
0: success
1: failure
32: 找不到所有指定设备
64: 一些设备找到了,一些设备没找到
类似的命令:
findmnt , blkid, ls
帮助信息:
➜ ~ lsblk --help
Usage:
lsblk [options] [<device> ...]
List information about block devices.
选项:
-a, --all print all devices
-b, --bytes print SIZE in bytes rather than in human readable format
-d, --nodeps don't print slaves or holders
-D, --discard print discard capabilities
-e, --exclude <list> exclude devices by major number (default: RAM disks)
-f, --fs output info about filesystems
-i, --ascii use ascii characters only
-I, --include <list> show only devices with specified major numbers
-J, --json use JSON output format
-l, --list use list format output
-m, --perms output info about permissions
-n, --noheadings don't print headings
-o, --output <list> output columns
-O, --output-all output all columns
-p, --paths print complete device path
-P, --pairs use key="value" output format
-r, --raw use raw output format
-s, --inverse inverse dependencies
-S, --scsi output info about SCSI devices
-t, --topology output info about topology
-x, --sort <column> sort output by <column>
-h, --help display this help and exit
-V, --version output version information and exit
Available columns (for --output):
NAME device name
KNAME internal kernel device name
MAJ:MIN major:minor device number
FSTYPE filesystem type
MOUNTPOINT where the device is mounted
LABEL filesystem LABEL
UUID filesystem UUID
PARTTYPE partition type UUID
PARTLABEL partition LABEL
PARTUUID partition UUID
PARTFLAGS partition flags
RA read-ahead of the device
RO read-only device
RM removable device
HOTPLUG removable or hotplug device (usb, pcmcia, ...)
MODEL device identifier
SERIAL disk serial number
SIZE size of the device
STATE state of the device
OWNER user name
GROUP group name
MODE device node permissions
ALIGNMENT alignment offset
MIN-IO minimum I/O size
OPT-IO optimal I/O size
PHY-SEC physical sector size
LOG-SEC logical sector size
ROTA rotational device, 0是不可旋转(ssd),1是可旋转(hdd)
SCHED I/O scheduler name
RQ-SIZE request queue size
TYPE device type
DISC-ALN discard alignment offset
DISC-GRAN discard granularity
DISC-MAX discard max bytes
DISC-ZERO discard zeroes data
WSAME write same max bytes
WWN unique storage identifier
RAND adds randomness
PKNAME internal parent kernel device name
HCTL Host:Channel:Target:Lun for SCSI
TRAN device transport type
SUBSYSTEMS de-duplicated chain of subsystems
REV device revision
VENDOR device vendor
lsblk 命令输出 default 参数是-a, --all
➜ ~ lsblk
NAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINT
loop1 7:1 0 55.8M 1 loop /snap/kata-containers/288
sdd 8:48 0 1.8T 0 disk
└─sdd1 8:49 0 1.8T 0 part
sdb 8:16 0 119.2G 0 disk
├─sdb2 8:18 0 915M 0 part
└─sdb1 8:17 0 118.4G 0 part
loop4 7:4 0 69.8M 1 loop /snap/kata-containers/352
sr0 11:0 1 1024M 0 rom
loop2 7:2 0 89.4M 1 loop /snap/core/6818
loop0 7:0 0 88.4M 1 loop /snap/core/6964
sde 8:64 0 1.8T 0 disk
├─sde2 8:66 0 1.8T 0 part
└─sde1 8:65 0 128M 0 part
sdc 8:32 0 477G 0 disk
├─sdc2 8:34 0 372G 0 part /home
├─sdc5 8:37 0 9.5G 0 part [SWAP]
├─sdc3 8:35 0 1K 0 part
└─sdc1 8:33 0 95.4G 0 part /
loop3 7:3 0 89.3M 1 loop /snap/core/6673
lsblk -b , --bytes ,输出单位为字节
➜ ~ lsblk -b
NAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINT
loop1 7:1 0 58478592 1 loop /snap/kata-containers/288
sdd 8:48 0 2000398934016 0 disk
└─sdd1 8:49 0 2000397795328 0 part
sdb 8:16 0 128035676160 0 disk
├─sdb2 8:18 0 959447040 0 part
└─sdb1 8:17 0 127071901696 0 part
loop4 7:4 0 73129984 1 loop /snap/kata-containers/352
sr0 11:0 1 1073741312 0 rom
loop2 7:2 0 93720576 1 loop /snap/core/6818
loop0 7:0 0 92733440 1 loop /snap/core/6964
sde 8:64 0 2000398934016 0 disk
├─sde2 8:66 0 2000263577600 0 part
└─sde1 8:65 0 134217728 0 part
sdc 8:32 0 512110190592 0 disk
├─sdc2 8:34 0 399469707264 0 part /home
├─sdc5 8:37 0 10239344640 0 part [SWAP]
├─sdc3 8:35 0 1024 0 part
└─sdc1 8:33 0 102398689280 0 part /
loop3 7:3 0 93581312 1 loop /snap/core/6673
lsblk -D , --discard, 打印discard信息, (没详细查),针对SSD盘,trim相关
➜ ~ lsblk -D
NAME DISC-ALN DISC-GRAN DISC-MAX DISC-ZERO
loop1 0 4K 4G 0
sdd 0 4K 2G 0
└─sdd1 0 4K 2G 0
sdb 0 512B 2G 0
├─sdb2 0 512B 2G 0
└─sdb1 0 512B 2G 0
loop4 0 4K 4G 0
sr0 0 0B 0B 0
loop2 0 4K 4G 0
loop0 0 4K 4G 0
sde 0 0B 0B 0
├─sde2 0 0B 0B 0
└─sde1 0 0B 0B 0
sdc 0 512B 2G 0
├─sdc2 0 512B 2G 0
├─sdc5 0 512B 2G 0
├─sdc3 0 512B 2G 0
└─sdc1 0 512B 2G 0
loop3 0 4K 4G 0
DISC-GRAN DISC-MAX 非0说明支持fstrim
lsblk -d [/dev/sdx], --nodeps ,打印指定设备的信息,或者打印所有设备的信息
➜ ~ lsblk -d
NAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINT
loop1 7:1 0 55.8M 1 loop /snap/kata-containers/288
sdd 8:48 0 1.8T 0 disk
sdb 8:16 0 119.2G 0 disk
loop4 7:4 0 69.8M 1 loop /snap/kata-containers/352
sr0 11:0 1 1024M 0 rom
loop2 7:2 0 89.4M 1 loop /snap/core/6818
loop0 7:0 0 88.4M 1 loop /snap/core/6964
sde 8:64 0 1.8T 0 disk
sdc 8:32 0 477G 0 disk
loop3 7:3 0 89.3M 1 loop /snap/core/6673
➜ ~ lsblk -d /dev/sdc
NAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINT
sdc 8:32 0 477G 0 disk
lsblk -e, --exclude list , 排除major id列表
➜ ~ lsblk -e 7
NAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINT
sdd 8:48 0 1.8T 0 disk
└─sdd1 8:49 0 1.8T 0 part
sdb 8:16 0 119.2G 0 disk
├─sdb2 8:18 0 915M 0 part
└─sdb1 8:17 0 118.4G 0 part
sr0 11:0 1 1024M 0 rom
sde 8:64 0 1.8T 0 disk
├─sde2 8:66 0 1.8T 0 part
└─sde1 8:65 0 128M 0 part
sdc 8:32 0 477G 0 disk
├─sdc2 8:34 0 372G 0 part /home
├─sdc5 8:37 0 9.5G 0 part [SWAP]
├─sdc3 8:35 0 1K 0 part
└─sdc1 8:33 0 95.4G 0 part /
➜ ~ lsblk -e 7,8
NAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINT
sr0 11:0 1 1024M 0 rom
lsblk -f, --fs , 输出设备的文件系统信息
同lsblk -o NAME,FSTYPE,LABEL,UUID,MOUNTPOINT
➜ ~ lsblk -f
NAME FSTYPE LABEL UUID MOUNTPOINT
loop1 squashfs /snap/kata-containers/288
sdd
└─sdd1 ntfs Volume2 CA9015A6901599D1
sdb
├─sdb2 ntfs 30EAC3FEEAC3BE7A
└─sdb1 ntfs OS_WIN10 0600EC5800EC4FEB
loop4 squashfs /snap/kata-containers/352
sr0
loop2 squashfs /snap/core/6818
loop0 squashfs /snap/core/6964
sde
├─sde2 ntfs 专用存储 B6D47A52D47A1539
└─sde1
sdc
├─sdc2 ext4 53842090-4ad6-4472-ad35-53b4d7b33bf8 /home
├─sdc5 swap 382e4b22-503e-4911-bf2f-1167af3f3cda [SWAP]
├─sdc3
└─sdc1 ext4 6b5618d0-a2b0-41f3-a3a5-9eb5a524b0a8 /
loop3 squashfs /snap/core/6673
lsblk -I , --include list ,打印major id列表
➜ ~ lsblk -I 7,8
NAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINT
loop1 7:1 0 55.8M 1 loop /snap/kata-containers/288
sdd 8:48 0 1.8T 0 disk
└─sdd1 8:49 0 1.8T 0 part
sdb 8:16 0 119.2G 0 disk
├─sdb2 8:18 0 915M 0 part
└─sdb1 8:17 0 118.4G 0 part
loop4 7:4 0 69.8M 1 loop /snap/kata-containers/352
loop2 7:2 0 89.4M 1 loop /snap/core/6818
loop0 7:0 0 88.4M 1 loop /snap/core/6964
sde 8:64 0 1.8T 0 disk
├─sde2 8:66 0 1.8T 0 part
└─sde1 8:65 0 128M 0 part
sdc 8:32 0 477G 0 disk
├─sdc2 8:34 0 372G 0 part /home
├─sdc5 8:37 0 9.5G 0 part [SWAP]
├─sdc3 8:35 0 1K 0 part
└─sdc1 8:33 0 95.4G 0 part /
loop3 7:3 0 89.3M 1 loop /snap/core/6673
lsblk -i , --ascii ,将输出信息的字符用ascii码打印
➜ ~ lsblk -i
NAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINT
loop1 7:1 0 55.8M 1 loop /snap/kata-containers/288
sdd 8:48 0 1.8T 0 disk
`-sdd1 8:49 0 1.8T 0 part
sdb 8:16 0 119.2G 0 disk
|-sdb2 8:18 0 915M 0 part
`-sdb1 8:17 0 118.4G 0 part
loop4 7:4 0 69.8M 1 loop /snap/kata-containers/352
sr0 11:0 1 1024M 0 rom
loop2 7:2 0 89.4M 1 loop /snap/core/6818
loop0 7:0 0 88.4M 1 loop /snap/core/6964
sde 8:64 0 1.8T 0 disk
|-sde2 8:66 0 1.8T 0 part
`-sde1 8:65 0 128M 0 part
sdc 8:32 0 477G 0 disk
|-sdc2 8:34 0 372G 0 part /home
|-sdc5 8:37 0 9.5G 0 part [SWAP]
|-sdc3 8:35 0 1K 0 part
`-sdc1 8:33 0 95.4G 0 part /
loop3 7:3 0 89.3M 1 loop /snap/core/6673
lsblk -J , --json 用json格式输出
➜ ~ lsblk -J
{
"blockdevices": [
{"name": "loop1", "maj:min": "7:1", "rm": "0", "size": "55.8M", "ro": "1", "type": "loop", "mountpoint": "/snap/kata-containers/288"},
{"name": "sdd", "maj:min": "8:48", "rm": "0", "size": "1.8T", "ro": "0", "type": "disk", "mountpoint": null,
"children": [
{"name": "sdd1", "maj:min": "8:49", "rm": "0", "size": "1.8T", "ro": "0", "type": "part", "mountpoint": null}
]
},
{"name": "sdb", "maj:min": "8:16", "rm": "0", "size": "119.2G", "ro": "0", "type": "disk", "mountpoint": null,
"children": [
{"name": "sdb2", "maj:min": "8:18", "rm": "0", "size": "915M", "ro": "0", "type": "part", "mountpoint": null},
{"name": "sdb1", "maj:min": "8:17", "rm": "0", "size": "118.4G", "ro": "0", "type": "part", "mountpoint": null}
]
},
{"name": "loop4", "maj:min": "7:4", "rm": "0", "size": "69.8M", "ro": "1", "type": "loop", "mountpoint": "/snap/kata-containers/352"},
{"name": "sr0", "maj:min": "11:0", "rm": "1", "size": "1024M", "ro": "0", "type": "rom", "mountpoint": null},
{"name": "loop2", "maj:min": "7:2", "rm": "0", "size": "89.4M", "ro": "1", "type": "loop", "mountpoint": "/snap/core/6818"},
{"name": "loop0", "maj:min": "7:0", "rm": "0", "size": "88.4M", "ro": "1", "type": "loop", "mountpoint": "/snap/core/6964"},
{"name": "sde", "maj:min": "8:64", "rm": "0", "size": "1.8T", "ro": "0", "type": "disk", "mountpoint": null,
"children": [
{"name": "sde2", "maj:min": "8:66", "rm": "0", "size": "1.8T", "ro": "0", "type": "part", "mountpoint": null},
{"name": "sde1", "maj:min": "8:65", "rm": "0", "size": "128M", "ro": "0", "type": "part", "mountpoint": null}
]
},
{"name": "sdc", "maj:min": "8:32", "rm": "0", "size": "477G", "ro": "0", "type": "disk", "mountpoint": null,
"children": [
{"name": "sdc2", "maj:min": "8:34", "rm": "0", "size": "372G", "ro": "0", "type": "part", "mountpoint": "/home"},
{"name": "sdc5", "maj:min": "8:37", "rm": "0", "size": "9.5G", "ro": "0", "type": "part", "mountpoint": "[SWAP]"},
{"name": "sdc3", "maj:min": "8:35", "rm": "0", "size": "1K", "ro": "0", "type": "part", "mountpoint":
lsblk命令用来查看block设备的信息.
主要应用场景: 获取wwnid,获取块设备列表,获取块设备类型(ssd,hdd),获取块设备的size等信息.
数据来源: /sys/dev/block
返回码:
0: success
1: failure
32: 找不到所有指定设备
64: 一些设备找到了,一些设备没找到
类似的命令:
findmnt , blkid, ls
帮助信息:
➜ ~ lsblk --help
Usage:
lsblk [options] [<device> ...]
List information about block devices.
选项:
-a, --all print all devices
-b, --bytes print SIZE in bytes rather than in human readable format
-d, --nodeps don't print slaves or holders
-D, --discard print discard capabilities
-e, --exclude <list> exclude devices by major number (default: RAM disks)
-f, --fs output info about filesystems
-i, --ascii use ascii characters only
-I, --include <list> show only devices with specified major numbers
-J, --json use JSON output format
-l, --list use list format output
-m, --perms output info about permissions
-n, --noheadings don't print headings
-o, --output <list> output columns
-O, --output-all output all columns
-p, --paths print complete device path
-P, --pairs use key="value" output format
-r, --raw use raw output format
-s, --inverse inverse dependencies
-S, --scsi output info about SCSI devices
-t, --topology output info about topology
-x, --sort <column> sort output by <column>
-h, --help display this help and exit
-V, --version output version information and exit
Available columns (for --output):
NAME device name
KNAME internal kernel device name
MAJ:MIN major:minor device number
FSTYPE filesystem type
MOUNTPOINT where the device is mounted
LABEL filesystem LABEL
UUID filesystem UUID
PARTTYPE partition type UUID
PARTLABEL partition LABEL
PARTUUID partition UUID
PARTFLAGS partition flags
RA read-ahead of the device
RO read-only device
RM removable device
HOTPLUG removable or hotplug device (usb, pcmcia, ...)
MODEL device identifier
SERIAL disk serial number
SIZE size of the device
STATE state of the device
OWNER user name
GROUP group name
MODE device node permissions
ALIGNMENT alignment offset
MIN-IO minimum I/O size
OPT-IO optimal I/O size
PHY-SEC physical sector size
LOG-SEC logical sector size
ROTA rotational device, 0是不可旋转(ssd),1是可旋转(hdd)
SCHED I/O scheduler name
RQ-SIZE request queue size
TYPE device type
DISC-ALN discard alignment offset
DISC-GRAN discard granularity
DISC-MAX discard max bytes
DISC-ZERO discard zeroes data
WSAME write same max bytes
WWN unique storage identifier
RAND adds randomness
PKNAME internal parent kernel device name
HCTL Host:Channel:Target:Lun for SCSI
TRAN device transport type
SUBSYSTEMS de-duplicated chain of subsystems
REV device revision
VENDOR device vendor
lsblk 命令输出 default 参数是-a, --all
➜ ~ lsblk
NAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINT
loop1 7:1 0 55.8M 1 loop /snap/kata-containers/288
sdd 8:48 0 1.8T 0 disk
└─sdd1 8:49 0 1.8T 0 part
sdb 8:16 0 119.2G 0 disk
├─sdb2 8:18 0 915M 0 part
└─sdb1 8:17 0 118.4G 0 part
loop4 7:4 0 69.8M 1 loop /snap/kata-containers/352
sr0 11:0 1 1024M 0 rom
loop2 7:2 0 89.4M 1 loop /snap/core/6818
loop0 7:0 0 88.4M 1 loop /snap/core/6964
sde 8:64 0 1.8T 0 disk
├─sde2 8:66 0 1.8T 0 part
└─sde1 8:65 0 128M 0 part
sdc 8:32 0 477G 0 disk
├─sdc2 8:34 0 372G 0 part /home
├─sdc5 8:37 0 9.5G 0 part [SWAP]
├─sdc3 8:35 0 1K 0 part
└─sdc1 8:33 0 95.4G 0 part /
loop3 7:3 0 89.3M 1 loop /snap/core/6673
lsblk -b , --bytes ,输出单位为字节
➜ ~ lsblk -b
NAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINT
loop1 7:1 0 58478592 1 loop /snap/kata-containers/288
sdd 8:48 0 2000398934016 0 disk
└─sdd1 8:49 0 2000397795328 0 part
sdb 8:16 0 128035676160 0 disk
├─sdb2 8:18 0 959447040 0 part
└─sdb1 8:17 0 127071901696 0 part
loop4 7:4 0 73129984 1 loop /snap/kata-containers/352
sr0 11:0 1 1073741312 0 rom
loop2 7:2 0 93720576 1 loop /snap/core/6818
loop0 7:0 0 92733440 1 loop /snap/core/6964
sde 8:64 0 2000398934016 0 disk
├─sde2 8:66 0 2000263577600 0 part
└─sde1 8:65 0 134217728 0 part
sdc 8:32 0 512110190592 0 disk
├─sdc2 8:34 0 399469707264 0 part /home
├─sdc5 8:37 0 10239344640 0 part [SWAP]
├─sdc3 8:35 0 1024 0 part
└─sdc1 8:33 0 102398689280 0 part /
loop3 7:3 0 93581312 1 loop /snap/core/6673
lsblk -D , --discard, 打印discard信息, (没详细查),针对SSD盘,trim相关
➜ ~ lsblk -D
NAME DISC-ALN DISC-GRAN DISC-MAX DISC-ZERO
loop1 0 4K 4G 0
sdd 0 4K 2G 0
└─sdd1 0 4K 2G 0
sdb 0 512B 2G 0
├─sdb2 0 512B 2G 0
└─sdb1 0 512B 2G 0
loop4 0 4K 4G 0
sr0 0 0B 0B 0
loop2 0 4K 4G 0
loop0 0 4K 4G 0
sde 0 0B 0B 0
├─sde2 0 0B 0B 0
└─sde1 0 0B 0B 0
sdc 0 512B 2G 0
├─sdc2 0 512B 2G 0
├─sdc5 0 512B 2G 0
├─sdc3 0 512B 2G 0
└─sdc1 0 512B 2G 0
loop3 0 4K 4G 0
DISC-GRAN DISC-MAX 非0说明支持fstrim
lsblk -d [/dev/sdx], --nodeps ,打印指定设备的信息,或者打印所有设备的信息
➜ ~ lsblk -d
NAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINT
loop1 7:1 0 55.8M 1 loop /snap/kata-containers/288
sdd 8:48 0 1.8T 0 disk
sdb 8:16 0 119.2G 0 disk
loop4 7:4 0 69.8M 1 loop /snap/kata-containers/352
sr0 11:0 1 1024M 0 rom
loop2 7:2 0 89.4M 1 loop /snap/core/6818
loop0 7:0 0 88.4M 1 loop /snap/core/6964
sde 8:64 0 1.8T 0 disk
sdc 8:32 0 477G 0 disk
loop3 7:3 0 89.3M 1 loop /snap/core/6673
➜ ~ lsblk -d /dev/sdc
NAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINT
sdc 8:32 0 477G 0 disk
lsblk -e, --exclude list , 排除major id列表
➜ ~ lsblk -e 7
NAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINT
sdd 8:48 0 1.8T 0 disk
└─sdd1 8:49 0 1.8T 0 part
sdb 8:16 0 119.2G 0 disk
├─sdb2 8:18 0 915M 0 part
└─sdb1 8:17 0 118.4G 0 part
sr0 11:0 1 1024M 0 rom
sde 8:64 0 1.8T 0 disk
├─sde2 8:66 0 1.8T 0 part
└─sde1 8:65 0 128M 0 part
sdc 8:32 0 477G 0 disk
├─sdc2 8:34 0 372G 0 part /home
├─sdc5 8:37 0 9.5G 0 part [SWAP]
├─sdc3 8:35 0 1K 0 part
└─sdc1 8:33 0 95.4G 0 part /
➜ ~ lsblk -e 7,8
NAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINT
sr0 11:0 1 1024M 0 rom
lsblk -f, --fs , 输出设备的文件系统信息
同lsblk -o NAME,FSTYPE,LABEL,UUID,MOUNTPOINT
➜ ~ lsblk -f
NAME FSTYPE LABEL UUID MOUNTPOINT
loop1 squashfs /snap/kata-containers/288
sdd
└─sdd1 ntfs Volume2 CA9015A6901599D1
sdb
├─sdb2 ntfs 30EAC3FEEAC3BE7A
└─sdb1 ntfs OS_WIN10 0600EC5800EC4FEB
loop4 squashfs /snap/kata-containers/352
sr0
loop2 squashfs /snap/core/6818
loop0 squashfs /snap/core/6964
sde
├─sde2 ntfs 专用存储 B6D47A52D47A1539
└─sde1
sdc
├─sdc2 ext4 53842090-4ad6-4472-ad35-53b4d7b33bf8 /home
├─sdc5 swap 382e4b22-503e-4911-bf2f-1167af3f3cda [SWAP]
├─sdc3
└─sdc1 ext4 6b5618d0-a2b0-41f3-a3a5-9eb5a524b0a8 /
loop3 squashfs /snap/core/6673
lsblk -I , --include list ,打印major id列表
➜ ~ lsblk -I 7,8
NAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINT
loop1 7:1 0 55.8M 1 loop /snap/kata-containers/288
sdd 8:48 0 1.8T 0 disk
└─sdd1 8:49 0 1.8T 0 part
sdb 8:16 0 119.2G 0 disk
├─sdb2 8:18 0 915M 0 part
└─sdb1 8:17 0 118.4G 0 part
loop4 7:4 0 69.8M 1 loop /snap/kata-containers/352
loop2 7:2 0 89.4M 1 loop /snap/core/6818
loop0 7:0 0 88.4M 1 loop /snap/core/6964
sde 8:64 0 1.8T 0 disk
├─sde2 8:66 0 1.8T 0 part
└─sde1 8:65 0 128M 0 part
sdc 8:32 0 477G 0 disk
├─sdc2 8:34 0 372G 0 part /home
├─sdc5 8:37 0 9.5G 0 part [SWAP]
├─sdc3 8:35 0 1K 0 part
└─sdc1 8:33 0 95.4G 0 part /
loop3 7:3 0 89.3M 1 loop /snap/core/6673
lsblk -i , --ascii ,将输出信息的字符用ascii码打印
➜ ~ lsblk -i
NAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINT
loop1 7:1 0 55.8M 1 loop /snap/kata-containers/288
sdd 8:48 0 1.8T 0 disk
`-sdd1 8:49 0 1.8T 0 part
sdb 8:16 0 119.2G 0 disk
|-sdb2 8:18 0 915M 0 part
`-sdb1 8:17 0 118.4G 0 part
loop4 7:4 0 69.8M 1 loop /snap/kata-containers/352
sr0 11:0 1 1024M 0 rom
loop2 7:2 0 89.4M 1 loop /snap/core/6818
loop0 7:0 0 88.4M 1 loop /snap/core/6964
sde 8:64 0 1.8T 0 disk
|-sde2 8:66 0 1.8T 0 part
`-sde1 8:65 0 128M 0 part
sdc 8:32 0 477G 0 disk
|-sdc2 8:34 0 372G 0 part /home
|-sdc5 8:37 0 9.5G 0 part [SWAP]
|-sdc3 8:35 0 1K 0 part
`-sdc1 8:33 0 95.4G 0 part /
loop3 7:3 0 89.3M 1 loop /snap/core/6673
lsblk -J , --json 用json格式输出
➜ ~ lsblk -J
{
"blockdevices": [
{"name": "loop1", "maj:min": "7:1", "rm": "0", "size": "55.8M", "ro": "1", "type": "loop", "mountpoint": "/snap/kata-containers/288"},
{"name": "sdd", "maj:min": "8:48", "rm": "0", "size": "1.8T", "ro": "0", "type": "disk", "mountpoint": null,
"children": [
{"name": "sdd1", "maj:min": "8:49", "rm": "0", "size": "1.8T", "ro": "0", "type": "part", "mountpoint": null}
]
},
{"name": "sdb", "maj:min": "8:16", "rm": "0", "size": "119.2G", "ro": "0", "type": "disk", "mountpoint": null,
"children": [
{"name": "sdb2", "maj:min": "8:18", "rm": "0", "size": "915M", "ro": "0", "type": "part", "mountpoint": null},
{"name": "sdb1", "maj:min": "8:17", "rm": "0", "size": "118.4G", "ro": "0", "type": "part", "mountpoint": null}
]
},
{"name": "loop4", "maj:min": "7:4", "rm": "0", "size": "69.8M", "ro": "1", "type": "loop", "mountpoint": "/snap/kata-containers/352"},
{"name": "sr0", "maj:min": "11:0", "rm": "1", "size": "1024M", "ro": "0", "type": "rom", "mountpoint": null},
{"name": "loop2", "maj:min": "7:2", "rm": "0", "size": "89.4M", "ro": "1", "type": "loop", "mountpoint": "/snap/core/6818"},
{"name": "loop0", "maj:min": "7:0", "rm": "0", "size": "88.4M", "ro": "1", "type": "loop", "mountpoint": "/snap/core/6964"},
{"name": "sde", "maj:min": "8:64", "rm": "0", "size": "1.8T", "ro": "0", "type": "disk", "mountpoint": null,
"children": [
{"name": "sde2", "maj:min": "8:66", "rm": "0", "size": "1.8T", "ro": "0", "type": "part", "mountpoint": null},
{"name": "sde1", "maj:min": "8:65", "rm": "0", "size": "128M", "ro": "0", "type": "part", "mountpoint": null}
]
},
{"name": "sdc", "maj:min": "8:32", "rm": "0", "size": "477G", "ro": "0", "type": "disk", "mountpoint": null,
"children": [
{"name": "sdc2", "maj:min": "8:34", "rm": "0", "size": "372G", "ro": "0", "type": "part", "mountpoint": "/home"},
{"name": "sdc5", "maj:min": "8:37", "rm": "0", "size": "9.5G", "ro": "0", "type": "part", "mountpoint": "[SWAP]"},
{"name": "sdc3", "maj:min": "8:35", "rm": "0", "size": "1K", "ro": "0", "type": "part", "mountpoint":