Work common view block device command lsblk details

The lsblk command can list information about all available block devices, such as logical disks, while df -h looks at file system level information. Lsblk command is included in util Linux package. Install util Linux package from yum, and util Linux contains multiple command tools.

[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

The lsblk command lists all block devices in a tree by default.
Parameters of lsblk

[root@localhost ~]# lsblk --help
Usage:
 lsblk [options] [<device> ...]
Options:
 -a, --all            print all devices #Display all block devices, including empty block devices
 -b, --bytes          print SIZE in bytes rather than in human readable format #Display block device size in bytes
 -d, --nodeps         don't print slaves or holders #Don't show salves or holders
 -D, --discard        print discard capabilities 
 -e, --exclude <list> exclude devices by major number (default: RAM disks) #Exclude equipment
 -I, --include <list> show only devices with specified major numbers
 -f, --fs             output info about filesystems #Display file system information
 -h, --help           usage information (this) #display help information
 -i, --ascii          use ascii characters only 
 -m, --perms          output info about permissions #Display permission information
 -l, --list           use list format output #Display in list format
 -n, --noheadings     don't print headings #Don't show title
 -o, --output <list>  output columns #Output column
 -p, --paths          print complate device path  
-P, --pairs          use key="value" output format #Display in key = "value" format
 -r, --raw            use raw output format #Display in original format
 -s, --inverse        inverse dependencies
 -t, --topology       output info about topology #Display topology information
 -S, --scsi           output info about SCSI devices

 -h, --help     display this help and exit
 -V, --version  output version information and exit #Display util Linux version information

Detailed explanation of lsblk column

[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: block device NAME
2. MAJ:MIN: this column displays the primary and secondary equipment numbers
3. RM: display the mobile device. 0 for non mobile devices, 1 for mobile devices
4. SIZE: space SIZE of block device
5. RO: read only, 0 means not read-only, 1 means read-only
6. TYPE: block device TYPE, such as disk disk, part partition, lvm logical volume, rom read-only storage
7. Mount: device mount point

Keywords: Linux CentOS Mobile ascii

Added by trukfixer on Sat, 07 Dec 2019 09:03:59 +0200