lsblk command – list block device information

Photo of author

By rasho

lsblk command is used to list information about all available block devices, however, it does not list information about RAM disks. Examples of block devices are hard disk, flash drives, CD-ROM…

Install lsblk

Ubuntu and Linux Mint installation
The command lsblk comes in the package util-linux.

sudo apt-get install util-linux -y

Fedora and CentOS installation

sudo yum install util-linux-ng

How to use lsblk command

lsblk command by default will list all block devices in a tree-like format.
Example: Type lsblk in your terminal:

rasho@Gandalf ~ $ lsblk
NAME   MAJ:MIN RM   SIZE RO TYPE MOUNTPOINT
sda      8:0    0 465,8G  0 disk
├─sda1   8:1    0   100M  0 part
├─sda2   8:2    0    80G  0 part
├─sda3   8:3    0 297,9G  0 part
├─sda4   8:4    0     1K  0 part
├─sda5   8:5    0    28G  0 part /
├─sda6   8:6    0   3,7G  0 part [SWAP]
└─sda7   8:7    0  56,2G  0 part /home
sr0     11:0    1  1024M  0 rom

There are seven columns namely:
NAME: This is the device name.
MAJ:MIN: This column shows the major and minor device number.
RM: This column shows whether the device is removable or not.
SIZE: This is column give information on the size of the device.
RO: This indicates whether a device is read-only.
TYPE:This column shows information whether the block device is a disk or a partition(part) within a disk.
MOUNTPOINT: This column indicates mount point on which the device is mounted.
[ads]

List all devices

To show list all devices including empty devices use following command:

lsblk -a

Example output:

rasho@Gandalf ~ $ lsblk -a
NAME   MAJ:MIN RM   SIZE RO TYPE MOUNTPOINT
sda      8:0    0 465,8G  0 disk
├─sda1   8:1    0   100M  0 part
├─sda2   8:2    0    80G  0 part
├─sda3   8:3    0 297,9G  0 part
├─sda4   8:4    0     1K  0 part
├─sda5   8:5    0    28G  0 part /
├─sda6   8:6    0   3,7G  0 part [SWAP]
└─sda7   8:7    0  56,2G  0 part /home
sr0     11:0    1  1024M  0 rom
ram0     1:0    0    64M  0 disk
ram1     1:1    0    64M  0 disk
ram2     1:2    0    64M  0 disk
ram3     1:3    0    64M  0 disk
ram4     1:4    0    64M  0 disk
ram5     1:5    0    64M  0 disk
ram6     1:6    0    64M  0 disk
ram7     1:7    0    64M  0 disk
ram8     1:8    0    64M  0 disk
ram9     1:9    0    64M  0 disk
loop0    7:0    0         0 loop
loop1    7:1    0         0 loop
loop2    7:2    0         0 loop
loop3    7:3    0         0 loop
loop4    7:4    0         0 loop
loop5    7:5    0         0 loop
loop6    7:6    0         0 loop
loop7    7:7    0         0 loop
ram10    1:10   0    64M  0 disk
ram11    1:11   0    64M  0 disk
ram12    1:12   0    64M  0 disk
ram13    1:13   0    64M  0 disk
ram14    1:14   0    64M  0 disk
ram15    1:15   0    64M  0 disk

List Device Permissions and Owner

To display information related to the owner, group and mode of the block device, use the -m option.

rasho@Gandalf ~ $ lsblk -m
NAME     SIZE OWNER GROUP MODE
sda    465,8G root  disk  brw-rw----
├─sda1   100M root  disk  brw-rw----
├─sda2    80G root  disk  brw-rw----
├─sda3 297,9G root  disk  brw-rw----
├─sda4     1K root  disk  brw-rw----
├─sda5    28G root  disk  brw-rw----
├─sda6   3,7G root  disk  brw-rw----
└─sda7  56,2G root  disk  brw-rw----
sr0     1024M root  cdrom brw-rw----

Print the SIZE column in bytes

Use the -b option to achieve this :

rasho@Gandalf ~ $ lsblk -b
NAME   MAJ:MIN RM         SIZE RO TYPE MOUNTPOINT
sda      8:0    0 500107862016  0 disk
├─sda1   8:1    0    104857600  0 part
├─sda2   8:2    0  85878374400  0 part
├─sda3   8:3    0 319815680000  0 part
├─sda4   8:4    0         1024  0 part
├─sda5   8:5    0  29998710784  0 part /
├─sda6   8:6    0   3999268864  0 part [SWAP]
└─sda7   8:7    0  60298362880  0 part /home
sr0     11:0    1   1073741312  0 rom

Hide the information related to slaves

If you do not want to display slave related information, use the -d option.

rasho@Gandalf ~ $ lsblk -d
NAME MAJ:MIN RM   SIZE RO TYPE MOUNTPOINT
sda    8:0    0 465,8G  0 disk
sr0   11:0    1  1024M  0 rom

So you can see that the information related to slaves is not displayed in the output.
This command provides a lot of other options, read this man page for more options.

1 thought on “lsblk command – list block device information”

Leave a Comment