
Data Structure
Networking
RDBMS
Operating System
Java
MS Excel
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
How to find a list of block devices information
lsblk command is used to display a list of information about all available block devices. However, it does not give a list of information about RAM disks. Examples of block devices are hard disk, flash drives, CD-ROM. This article explains about how to find a list of block devices in Linux Machine.
To install lsblk for Fedora and CentOS ,use the following command –
$ sudo yum install util-linux-ng
To install lsblk for Ubuntu and Linux Mint ,use the following command –
$ sudo apt-get install util-linux -y
To find the default list of all blocks, use the following command –
$ lsblk
The sample output should be like this –
NAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINT sda 8:0 0 931.5G 0 disk ??sda1 8:1 0 500M 0 part /boot/efi ??sda2 8:2 0 40M 0 part ??sda3 8:3 0 128M 0 part ??sda4 8:4 0 750M 0 part ??sda5 8:5 0 462.1G 0 part ??sda6 8:6 0 452.1G 0 part / ??sda7 8:7 0 8G 0 part ? ??vol_grp1-logical_vol1 (dm-0) 252:0 0 100M 0 lvm ??sda8 8:8 0 7.9G 0 part [SWAP] sr0
The clear information about the above result is shown below –
NAME − It indicates the device name.
MAJ:MIN − It gives the major and minor device number information.
RM − This column shows whether the device is removable or not.
SIZE − This gives information on the size of the device.
RO − It 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.
To show a list of all devices including empty devices, use the following command –
$ lsblk -a
The sample output should be like this –
sda 8:0 0 931.5G 0 disk ??sda1 8:1 0 500M 0 part /boot/efi ??sda2 8:2 0 40M 0 part ??sda3 8:3 0 128M 0 part ??sda4 8:4 0 750M 0 part ??sda5 8:5 0 462.1G 0 part ??sda6 8:6 0 452.1G 0 part / ??sda7 8:7 0 8G 0 part ? ??vol_grp1-logical_vol1 (dm-0) 252:0 0 100M 0 lvm ??sda8 8:8 0 7.9G 0 part [SWAP] 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
To display information related to the owner, group and mode of the block device, use the following command –
$ lsblk -m
The sample output should be like this –
NAME SIZE OWNER GROUP MODE sda 931.5G root disk brw-rw---- ??sda1 500M root disk brw-rw---- ??sda2 40M root disk brw-rw---- ??sda3 128M root disk brw-rw---- ??sda4 750M root disk brw-rw---- ??sda5 462.1G root disk brw-rw---- ??sda6 452.1G root disk brw-rw---- ??sda7 8G root disk brw-rw---- ? ??vol_grp1-logical_vol1 (dm-0) 100M root disk brw-rw---- ??sda8 7.9G root disk brw-rw---- sr0
To find the size of columns in bytes, use the following command –
$ lsblk -b
The sample output should be like this –
NAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINT sda 8:0 0 1000204886016 0 disk ??sda1 8:1 0 524288000 0 part /boot/efi ??sda2 8:2 0 41943040 0 part ??sda3 8:3 0 134217728 0 part ??sda4 8:4 0 786432000 0 part ??sda5 8:5 0 496196648960 0 part ??sda6 8:6 0 485453987840 0 part / ??sda7 8:7 0 8576000000 0 part ? ??vol_grp1-logical_vol1 (dm-0) 252:0 0 104857600 0 lvm ??sda8 8:8 0 8489271296 0 part [SWAP] sr0
If you do not want to display slave related information, use the following command –
$ lsblk -d
The sample output should be like this –
NAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINT sda 8:0 0 931.5G 0 disk sr0 11:0 1 1024M 0 rom
Congratulations! Now, you know “How to find a list of block devices information ”. We’ll learn more about these types of commands in our next Linux post. Keep reading!