How to Inspect Block Devices and Storage Topologies in Linux Using lsblk

Storage management in Linux demands clear visibility into physical drives, virtual disks, software RAID configurations, Logical Volume Manager (LVM) volumes, and active mount points. While legacy utilities like fdisk -l or df -h provide partial slices of storage information, they often obscure parent-child relationships between physical NVMe/SATA disks, partition slices, volume groups, and cryptographic LUKS containers. Furthermore, unstructured textual outputs complicate automated scripting and programmatic hardware parsing.

The lsblk (list block devices) command is the universal, modern standard for block storage enumeration across all Linux distributions. Part of the core util-linux package, lsblk reads directly from the sysfs filesystem and udev database to render intuitive tree structures of all storage hierarchies. This comprehensive guide covers everything from standard tree inspection and custom column filtering to SSD discard auditing, topology discovery, and structured JSON output for sysadmins and DevOps engineers.

Basic Usage: Rendering the Default Storage Tree

To inspect all recognized block storage devices connected to your Linux machine, execute lsblk without arguments:

lsblk

This outputs an intuitive hierarchical tree illustrating how physical storage volumes are partitioned:

NAME        MAJ:MIN RM   SIZE RO TYPE MOUNTPOINTS
sda           8:0    0 465.8G  0 disk 
├─sda1        8:1    0   512M  0 part /boot/efi
├─sda2        8:2    0     1G  0 part /boot
└─sda3        8:3    0 464.3G  0 part 
  └─ubuntu--vg-ubuntu--lv 252:0 0 100G  0 lvm  /
nvme0n1     259:0    0 931.5G  0 disk 
└─nvme0n1p1 259:1    0 931.5G  0 part /data

Understanding the Default Columns:

  • NAME: The device node name seated under /dev/.
  • MAJ:MIN: Major and minor device numbers used by the kernel to assign driver subsystems.
  • RM: Removable device flag (1 indicates removable media such as USB drives or SD cards; 0 indicates fixed internal media).
  • SIZE: The formatted capacity of the block device.
  • RO: Read-only indicator (1 for write-protected media or CD-ROMs; 0 for read-write).
  • TYPE: Device classification (such as disk, part (partition), lvm, crypt, or rom).
  • MOUNTPOINTS: Current filesystem mount paths.

Inspecting Filesystem Types, Labels, and UUIDs

When preparing partitions or configuring persistent mounting in /etc/fstab, querying filesystem metadata and Universally Unique Identifiers (UUIDs) is essential. Rather than running separate blkid commands, use the -f flag:

lsblk -f

This populates crucial filesystem parameters:

NAME        FSTYPE FSVER LABEL       UUID                                 FSAVAIL FSUSE% MOUNTPOINTS
sda                                                                                      
├─sda1      vfat   FAT32 BOOT        6C21-7A9B                             505.8M     1% /boot/efi
├─sda2      ext4   1.0               a27c18b5-3fa1-4cb7-8e6f-4a0b5b08e2f1  742.3M    20% /boot
└─sda3      LVM2_m LVM2              kF9Z1l-Qv4B-83P0-Kx8Y-3U2J-54mN-09pQ2            
  └─vg-lv   ext4   1.0   rootfs      189a24d0-6bc2-4c6e-984e-3f7cb49b2918   58.2G    38% /

If you recently resized a volume or formatted an array, you can sync the kernel partition table directly by consulting our tutorial on how to force the Linux kernel to reread partition tables without rebooting using partprobe and partx.

Customising Output with Specific Columns

You can construct tailored reports by specifying required field headers using the -o (output) flag:

lsblk -o NAME,SIZE,FSTYPE,LABEL,MODEL,SERIAL,MOUNTPOINTS

To inspect all available columns supported by your installed util-linux version, execute:

lsblk --help

Filtering Out Empty Devices and Loopbacks

Modern Linux systems running Snap packages often clutter lsblk outputs with dozens of virtual /dev/loop devices. To suppress loop devices and display only physical disks and their child partitions, use the -e (exclude) flag targeting major number 7 (loop devices):

lsblk -e 7

Auditing SSD Discard and TRIM Support

Solid-state drives (SSDs) and NVMe storage rely on TRIM/discard commands to communicate freed memory blocks to the storage controller, preventing write degradation over time. You can verify whether your hardware and filesystem configuration support discard operations using the -D flag:

lsblk -D

Inspect the output columns:

  • DISC-GRAN: Discard granularity.
  • DISC-MAX: Maximum discard bytes supported in a single operation. If this displays 0B, discard/TRIM is disabled or unsupported by the hardware or driver.
  • DISC-ZERO: Indicates whether zeroing occurs upon discard.

Inspecting Device Topologies and Queue Alignments

For high-throughput enterprise servers and databases, aligning block I/O requests with physical sector sizes prevents costly write amplification. Inspect block topology parameters using the -t flag:

lsblk -t

This exposes physical sector sizes (PHY-SEC), logical sector sizes (LOG-SEC), minimum I/O sizes (MIN-IO), and optimal alignment boundaries (OPT-IO).

If you are aggregating multiple disks into redundant storage pools, compare your topology outputs against our guide on how to create and manage a software RAID 1 array in Linux using mdadm, or format advanced volumes by reviewing how to format and label a Btrfs filesystem in Linux.

Generating Programmatic JSON and Key-Value Outputs for Scripts

Parsing raw tabular command output in bash or Python with regex or awk is fragile. lsblk provides native, machine-readable formats out of the box:

JSON Formatting

lsblk -J -o NAME,SIZE,TYPE,MOUNTPOINTS

This yields a validated JSON object containing nested child objects for all partitions and volume groups, ideal for ingest into Python, Node.js, or Ansible automation plays.

Pairs (Key-Value) Formatting

lsblk -P -o NAME,FSTYPE,UUID

Outputs key-value pairs formatted as NAME="sda1" FSTYPE="vfat" UUID="6C21-7A9B", designed for straightforward eval and environmental assignment in shell scripts.

Troubleshooting Common lsblk Queries

1. Device Not Appearing in lsblk

If an attached USB drive, SAS disk, or NVMe storage unit does not show up in lsblk:

  • Check kernel ring buffer logs for hardware connection events: dmesg | grep -i scsi or dmesg | grep -i nvme.
  • Verify that the host bus adapter or USB controller recognized the physical connection using lsusb or lspci.
  • Rescan the SCSI bus if hot-plugging without rebooting:
    echo "- - -" | sudo tee /sys/class/scsi_host/host*/scan

2. Mount Points Showing Empty After Mounting

If a partition is mounted inside an isolated container or private mount namespace, standard system-wide lsblk queries may show an empty MOUNTPOINTS field. Execute findmnt or query within the target process namespace to view isolated mounts.

Get the best tech tips delivered straight to your inbox.

Join thousands of readers mastering Apple, Google, Microsoft, and Linux.