How to Use lsblk Command on Linux

Linux TLDR
Last Updated:
Reading time: 3 minutes

The lsblk (pronounced β€œL-S-block”) command is commonly used to get the list of all the block devices in your system with their information, such as size, type, mount point, etc.

If you are wondering, what are block devices? Then it’s basically files that represent the device connected to your system (except for ram disk).

In this article, you will learn how to list out and get information about all the block devices using the lsblk command and its options (with practical examples).

Tutorial Details

DescriptionLists Information about Block Devices.
Difficulty LevelLow
Root or Sudo PrivilegesNo
OS CompatibilityUbuntu, Manjaro, Fedora, etc.
Prerequisiteslsblk
Internet RequiredNo

Syntax of the lsblk Command

The lsblk command takes two arguments: one is the option, and the other is the block device name (both are optional).

$ lsblk [OPTION] [DEVICE...]

When you execute this command without any options or arguments, you will get the list of all the block devices in a tree-like format.

Output of the lsblk command

The following is an explanation of each field mentioned in the above output:

  • NAME: Device name
  • MAJ:MIN: Major and minor device numbers:
  • RM: Indicates the removable device with β€œ1” and non-removable device with β€œ0β€œ.
  • SIZE: Device size in human-readable format, i.e., K, M, G, T, etc.
  • RO: Indicates the read-only status with β€œ1” and not read-only status with β€œ0β€œ.
  • TYPE: Device type, i.e., disk, loopback device, partition, or LVM device.
  • MOUNTPOINT: Mount point to which the referenced device is mounted.

The following is an explanation of each device you will see in the output:

  • Loopback devices: It represents the ISO image, disk image, file system, or logical volume image and assign them in loop0, loop1, loop2, etc.
  • CD-ROM: It mainly indicates CD/DVD in the sr0 or sr1 format.
  • Disk partitions: It represents the disk partition in SDA and assign them in sda1, sda2, and sda3 formats.

If you want to check the information for a specific block device, then specify its mount path (let’s say β€œ/dev/sdaβ€œ) as an argument to this command.

πŸ“
Specify one block device mount path at a time.
$ lsblk /dev/sda

Output:

Details of a particular block device

Now, let’s see a few commonly used options with the lsblk command.

lsblk Command Options:

The lsblk command offers various options that can be used to add or remove columns from the output, print extra information about specific devices, hide the header, and much more.

Limited Columns in the Output

Using the β€œ-o” flag, you can manipulate the columns in the output by specifying each column with its name using a comma as a separator.

$ lsblk -o NAME,SIZE,MOUNTPOINT

Output:

Custom columns in the output

The following is a list of column names supported by this option.

  • NAME – device name
  • PATH – path to the device node
  • MAJ:MIN – major:minor device number
  • FSAVAIL – filesystem size available
  • FSSIZE – filesystem size
  • FSTYPE – filesystem type
  • FSUSED – filesystem size used
  • FSUSE% – filesystem use percentage
  • FSROOTS – mounted filesystem roots
  • MOUNTPOINT – where the device is mounted
  • LABEL – filesystem LABEL
  • UUID – filesystem UUID
  • PTTYPE – partition table type
  • PARTLABEL – partition LABEL
  • PARTUUID – partition UUID

Check the complete list using the β€œlsblk -h” command.

List Empty Block Devices

A block device with zero size is skipped in the output and can be included using the β€œ-a” flag.

$ lsblk -a

Output:

List block devices that have an empty size.

Print the Size Column in Bytes

The default format used to mention the block device size is in human-readable format, i.e., in K, M, G, T, etc. However, you can use the β€œ-b” flag to print the size in bytes rather than in a human-readable format.

$ lsblk -b

Output:

Size column in bytes

Print the Output in List Format

By default, the command output will be in tree-like format, which can be changed to list format using the β€œ-l” flag.

$ lsblk -l

Output:

Print the output in list format

Print the Output without a Header

The β€œ-n” flag will remove the header from the columns while showing the output.

$ lsblk -n

Output:

Output without header

Display Only the SCSI Devices

The β€œ-S” flag will only print the information about the SCSI devices, which are mostly your hard disk or CD/DVD.

$ lsblk -S

Output

Print the SCSI devices

Bonus Tip! Print All the Partitions and their UUID

Linux offers another command-line utility, blkid, that can be used to list all the recognized partitions and their Universally Unique Identifier (UUID).

$ blkid

Output:

List all devices with a UUID

Here comes the end of this article.

If you have any questions or queries related to this topic, then feel free to ask them in the comment section.

Till then, peace!

Join The Conversation

Users are always welcome to leave comments about the articles, whether they are questions, comments, constructive criticism, old information, or notices of typos. Please keep in mind that all comments are moderated according to our comment policy.