Home > File & Directory Management > lsblk

lsblk: Guide to Displaying Block Device Information

The lsblk command displays information about all block devices (hard disks, SSDs, USB drives, etc.) on the system in a tree-like format. It is useful for quickly understanding physical disk information such as device name, size, mount point, and type.

Overview

lsblk (list block devices) is a command that provides information about block devices (hard disks, SSDs, USBs, CD-ROMs, etc.) and their associated partitions. It visualizes all block devices, including file systems and logical volumes, in a hierarchical tree structure, making it easy to understand the structure of storage devices connected to the system. Unlike `df`, which shows file system usage, `lsblk` focuses on displaying the physical structure of the devices themselves.

Key Features

The key features of the lsblk command are as follows:

  • Displays all block devices and partitions in a tree structure.
  • Provides information such as device name (NAME), size (SIZE), and mount point (MOUNTPOINT).
  • Detailed information such as partition table type, and whether the device is rotational or non-rotational can be checked.
  • Also supports output in JSON format for easy use in scripts.

Key Options

The main options of the lsblk command are grouped by purpose.

1) Output Format Control

2) Filtering and Sorting

3) Help

Generated command:

Try combining the commands.

Description:

`lsblk` Executes the command.

Combine the above options to virtually execute commands with AI.

Usage Examples

Learn the functions of the lsblk command through various usage examples.

Display Basic Block Device Information

lsblk

The most basic usage, showing all block devices in a tree structure.

Display with File System Information

lsblk -f

Displays additional file system (FSTYPE), UUID, and LABEL information for the device to provide more detailed insights.

Display Specific Information Only

lsblk -o NAME,SIZE,MOUNTPOINT

Uses the `-o` option to display only the device name, size, and mount point.

Find Device with Root Directory

lsblk -o NAME,SIZE,MOUNTPOINT | grep '/'

Checks device information where the root directory (`MOUNTPOINT=/`) is mounted.

JSON Output for Script Usage

lsblk -J

Outputs command results in JSON format, making them easy to parse in scripts.

Tips & Cautions

Summarized important points to note when using the lsblk command.

Tips

  • lsblk is very useful for understanding disk status when used with `df`. It's a method of checking the physical device structure with `lsblk` and file system usage with `df`.
  • lsblk output can be viewed without `sudo` privileges, so there are few cases where information cannot be checked due to permission issues.
  • In a virtual environment, it shows information about virtual disks (`vda`, `sda`, etc.), which may differ from actual physical disks.

Related commands

These are commands that are functionally similar or are commonly used together.


Same category commands