工作常用查看块设备命令lsblk详解

lsblk命令可以列出所有可用块设备的信息,比如我们说的逻辑磁盘,而df -h查看的是文件系统级别的信息。lsblk命令包含在util-linux包中,yum安装util-linux包即可,util-linux包含多个命令工具。

[root@localhost ~]# df -h
Filesystem               Size  Used Avail Use% Mounted on
/dev/mapper/centos-root   17G  1.2G   16G   7% /
devtmpfs                 482M     0  482M   0% /dev
tmpfs                    493M     0  493M   0% /dev/shm
tmpfs                    493M  6.8M  486M   2% /run
tmpfs                    493M     0  493M   0% /sys/fs/cgroup
/dev/sda1               1014M  125M  890M  13% /boot
tmpfs                     99M     0   99M   0% /run/user/0
[root@localhost ~]# lsblk
NAME            MAJ:MIN RM  SIZE RO TYPE MOUNTPOINT
fd0               2:0    1    4K  0 disk 
sda               8:0    0   20G  0 disk 
├─sda1            8:1    0    1G  0 part /boot
└─sda2            8:2    0   19G  0 part 
  ├─centos-root 253:0    0   17G  0 lvm  /
  └─centos-swap 253:1    0    2G  0 lvm  [SWAP]
sdb               8:16   0   20G  0 disk 
sr0              11:0    1  8.1G  0 rom

lsblk命令默认情况下将以树状列出所有块设备。
lsblk的参数

[root@localhost ~]# lsblk --help
Usage:
 lsblk [options] [<device> ...]
Options:
 -a, --all            print all devices #显示所有块设备,包括空块设备
 -b, --bytes          print SIZE in bytes rather than in human readable format #以bytes方式显示块设备大小
 -d, --nodeps         don't print slaves or holders #不显示salves或holders
 -D, --discard        print discard capabilities 
 -e, --exclude <list> exclude devices by major number (default: RAM disks) #排除设备
 -I, --include <list> show only devices with specified major numbers
 -f, --fs             output info about filesystems #显示文件系统信息
 -h, --help           usage information (this) #显示帮助信息
 -i, --ascii          use ascii characters only 
 -m, --perms          output info about permissions #显示权限信息
 -l, --list           use list format output #使用列表格式显示
 -n, --noheadings     don't print headings #不显示标题
 -o, --output <list>  output columns #输出列
 -p, --paths          print complate device path  
-P, --pairs          use key="value" output format #使用key=”value”格式显示
 -r, --raw            use raw output format #使用原始格式显示
 -s, --inverse        inverse dependencies
 -t, --topology       output info about topology #显示拓扑结构信息
 -S, --scsi           output info about SCSI devices

 -h, --help     display this help and exit
 -V, --version  output version information and exit #显示util-linux版本信息

lsblk栏目详解

[root@localhost ~]# lsblk 
NAME            MAJ:MIN RM  SIZE RO TYPE MOUNTPOINT
fd0               2:0    1    4K  0 disk 
sda               8:0    0   20G  0 disk 
├─sda1            8:1    0    1G  0 part /boot
└─sda2            8:2    0   19G  0 part 
  ├─centos-root 253:0    0   17G  0 lvm  /
  └─centos-swap 253:1    0    2G  0 lvm  [SWAP]
sdb               8:16   0   20G  0 disk 
sr0              11:0    1  8.1G  0 rom 

1、NAME:块设备名
2、MAJ:MIN:本栏显示主要和次要设备号
3、RM:显示可移动设备。0表示非移动设备,1表示可移动设备
4、SIZE:块设备的空间大小
5、RO:是否只读,0表示非只读,1表示只读
6、TYPE:块设备类型,比如disk磁盘,part分区,lvm逻辑卷,rom只读存储
7、MOUNTPOINT:设备挂载点

猜你喜欢

转载自blog.51cto.com/13691477/2318597