Article Categories
- All Categories
-
Data Structure
-
Networking
-
RDBMS
-
Operating System
-
Java
-
MS Excel
-
iOS
-
HTML
-
CSS
-
Android
-
Python
-
C Programming
-
C++
-
C#
-
MongoDB
-
MySQL
-
Javascript
-
PHP
-
Economics & Finance
How to find a list of block devices information
The lsblk command is used to display a list of information about all available block devices in Linux systems. However, it does not list information about RAM disks by default. Examples of block devices include hard disks, flash drives, and CD-ROM drives. This article explains how to find and display block device information on Linux machines.
Installing lsblk
For Fedora and CentOS systems, use the following command −
$ sudo yum install util-linux-ng
For Ubuntu and Linux Mint systems, use the following command −
$ sudo apt-get install util-linux -y
Basic Usage
To find the default list of all block devices, 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
Understanding the Output
The output columns provide the following information −
NAME − Indicates the device name.
MAJ:MIN − Shows the major and minor device number information.
RM − Shows whether the device is removable (1) or not (0).
SIZE − Displays the size of the device.
RO − Indicates whether a device is read-only (1) or not (0).
TYPE − Shows whether the block device is a disk, partition (part), or other type like LVM.
MOUNTPOINT − Indicates the mount point where the device is mounted.
Common lsblk Options
Display All Devices Including Empty Ones
To show a list of all devices including empty devices and RAM disks, use the following command −
$ lsblk -a
This will display additional devices like loop devices and RAM disks that are normally hidden.
Display Ownership and Permissions
To display information related to the owner, group, and mode of the block device, use the following command −
$ lsblk -m
The sample output includes ownership details −
NAME SIZE OWNER GROUP MODE sda 931.5G root disk brw-rw---- ??sda1 500M root disk brw-rw---- ??sda2 40M root disk brw-rw---- ??sda6 452.1G root disk brw-rw---- ??sda8 7.9G root disk brw-rw----
Display Size in Bytes
To find the size of devices in bytes rather than human-readable format, use the following command −
$ lsblk -b
Hide Slave/Holder Information
If you do not want to display slave devices or partition information, use the following command −
$ lsblk -d
The sample output shows only top-level devices −
NAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINT sda 8:0 0 931.5G 0 disk sr0 11:0 1 1024M 0 rom
Comparison of Key Options
| Option | Description | Use Case |
|---|---|---|
lsblk |
Default output with tree view | General device overview |
lsblk -a |
Show all devices including empty | Complete device inventory |
lsblk -m |
Show ownership and permissions | Security and access control |
lsblk -b |
Display sizes in bytes | Precise size calculations |
lsblk -d |
Show only parent devices | Simplified device list |
Conclusion
The lsblk command is an essential tool for displaying block device information in Linux systems. Its various options allow you to customize the output to show device hierarchies, ownership details, exact sizes, or simplified device lists depending on your specific needs.
