Detailed explanation of block device view command lsblk under Linux

Introduction
Under Linux systems, the use of block devices is very common, especially some traditional commercial databases, such as Oracle and DB2, often use block devices. The lsblk command can be very convenient for you to get all block device information.

lsblk installation
If there is no lsblk command on your Linux system, it doesn’t matter, the installation is easy

yum install util-linux

Detailed explanation of common parameters of lsblk


[root@mysql ~]# lsblk --help
选项:
 -a, --all            打印所有设备
 -b, --bytes          以字节为单位而非易读的格式来打印 SIZE
 -d, --nodeps         不打印从属设备(slave)或占位设备(holder)
 -D, --discard        打印时丢弃能力
 -e, --exclude <列表> 根据主设备号排除设备(默认:内存盘)
 -I, --include <列表> 只显示有指定主设备号的设备
 -f, --fs             输出文件系统信息
 -h, --help           使用信息(此信息)
 -i, --ascii          只使用 ascii 字符
 -m, --perms          输出权限信息
 -l, --list           使用列表格式的输出
 -n, --noheadings     不打印标题
 -o, --output <列表>  输出列
 -p, --paths          打印完整设备路径
 -P, --pairs          使用 key=“value” 输出格式
 -r, --raw            使用原生输出格式
 -s, --inverse        反向依赖
 -t, --topology       输出拓扑信息
 -S, --scsi           输出有关 SCSI 设备的信息

 -h, --help     显示此帮助并退出
 -V, --version  输出版本信息并退出

Example of lsblk usage to
obtain block devices and display them in tree form


[mysql@mysql ~]$ lsblk
NAME            MAJ:MIN RM  SIZE RO TYPE MOUNTPOINT
sda               8:0    0  100G  0 disk
|-sda1            8:1    0    1G  0 part /boot
`-sda2            8:2    0   99G  0 part
  |-centos-root 253:0    0   87G  0 lvm  /
  |-centos-swap 253:1    0    2G  0 lvm  [SWAP]
  `-centos-home 253:2    0   10G  0 lvm  /home
sr0              11:0    1  4.3G  0 rom

Explain the meaning of important column names here. For more information, you can use lsblk --help to view by yourself.
1.MAJ:MIN: This column displays the major and minor device numbers.
2.RM: Displays removable devices. 0 means non-mobile device, 1 means removable device
3.RO: read-only, 0 means non-read-only, 1 means read-only

Obtain the full path and permissions of the block device


[mysql@mysql ~]$ lsblk -mp
NAME                         SIZE OWNER GROUP MODE
/dev/sda                     100G root  disk  brw-rw----
|-/dev/sda1                    1G root  disk  brw-rw----
`-/dev/sda2                   99G root  disk  brw-rw----
  |-/dev/mapper/centos-root   87G root  disk  brw-rw----
  |-/dev/mapper/centos-swap    2G root  disk  brw-rw----
  `-/dev/mapper/centos-home   10G root  disk  brw-rw----
/dev/sr0                     4.3G root  cdrom brw-rw----

From the above results, you can clearly see the users and groups that each block device belongs to, and the permissions

Get the IO scheduling algorithm of the block device


[mysql@mysql ~]$ lsblk -t
NAME            ALIGNMENT MIN-IO OPT-IO PHY-SEC LOG-SEC ROTA SCHED    RQ-SIZE   RA WSAME
sda                     0    512      0     512     512    1 deadline     128 4096   32M
|-sda1                  0    512      0     512     512    1 deadline     128 4096   32M
`-sda2                  0    512      0     512     512    1 deadline     128 4096   32M
  |-centos-root         0    512      0     512     512    1              128 4096   32M
  |-centos-swap         0    512      0     512     512    1              128 4096   32M
  `-centos-home         0    512      0     512     512    1              128 4096   32M
sr0                     0   2048      0    2048    2048    1 deadline     128  128    0B

I will not list the usages one by one here, and interested friends can study them carefully, and leave a comment if there are new usages.

Guess you like

Origin blog.51cto.com/15061930/2642095