lsblk Command

List Block Devices in Tree Format

lsblk [options] [device...]

Overview

The lsblk command lists information about all available or specified block devices in a tree-like format. It reads the sysfs filesystem and udev database to gather information about block devices. This command is invaluable for understanding disk layouts, partition schemes, mount points, and the relationships between physical devices, partitions, and logical volumes.

Key Features

  • Tree Structure: Shows parent-child relationships between devices and partitions
  • Comprehensive Information: Displays size, type, mount points, filesystem types, and more
  • Customizable Output: Select specific columns and output formats
  • Works with All Device Types: Physical disks, partitions, LVM, RAID, loopback devices
  • Non-destructive: Read-only operation, safe to run anytime

When to Use lsblk

  • Quick overview of disk layout and partitions
  • Identifying device names (especially for NVMe, which uses different naming)
  • Checking mount points and filesystem types
  • Verifying LVM logical volume structure
  • Finding which partition is mounted where
  • Troubleshooting storage issues
  • Scripting and automation (JSON/pairs output)

Related Commands

  • fdisk -l - More detailed partition table information
  • blkid - Display block device attributes (UUID, LABEL, TYPE)
  • df - Show filesystem disk space usage
  • mount - Show currently mounted filesystems
  • parted -l - List partition tables
  • lsscsi - List SCSI devices
  • lvdisplay - Display LVM logical volumes

Common Options

Option Description
-a, --all Print all devices including empty ones
-b, --bytes Print sizes in bytes rather than human-readable format
-d, --nodeps Don't print slave/holder devices (only show top-level devices)
-e, --exclude Exclude devices by major number (e.g., RAM disks)
-f, --fs Output filesystem information
-i, --ascii Use ASCII characters for tree formatting
-J, --json Output in JSON format
-l, --list Produce output in list format (no tree)
-m, --perms Output information about permissions
-n, --noheadings Don't print column headings
-o, --output Specify which columns to output (comma-separated)
-O, --output-all Output all available columns
-p, --paths Print full device paths
-P, --pairs Produce output in key="value" pairs format
-r, --raw Produce output in raw format
-S, --scsi Output information about SCSI devices
-t, --topology Output information about topology

Available Columns

Use lsblk --help to see all available columns. Common ones include:

Column Description
NAME Device name
KNAME Internal kernel device name
MAJ:MIN Major:minor device numbers
FSTYPE Filesystem type
MOUNTPOINT Where the device is mounted
LABEL Filesystem label
UUID Filesystem UUID
SIZE Size of the device
TYPE Device type (disk, part, lvm, etc.)
RO Read-only device (0=rw, 1=ro)
RM Removable device (0=no, 1=yes)
MODEL Device model
SERIAL Device serial number
VENDOR Device vendor
STATE State of the device
OWNER User name of the device owner
GROUP Group name of the device owner
MODE Device node permissions

Detailed Examples

Example 1: Basic lsblk Output - Understanding the Tree Structure

The most common usage shows the hierarchical relationship between devices.

$ lsblk
NAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINT 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 ├─ol-root 253:0 0 50G 0 lvm / ├─ol-swap 253:1 0 15.7G 0 lvm [SWAP] └─ol-home 253:2 0 398.6G 0 lvm /home sdb 8:16 0 1.8T 0 disk └─sdb1 8:17 0 1.8T 0 part /data nvme0n1 259:0 0 1.8T 0 disk ├─nvme0n1p1 259:1 0 500G 0 part /mnt/nvme1 └─nvme0n1p2 259:2 0 1.3T 0 part /mnt/nvme2 sr0 11:0 1 1024M 0 rom
Explanation:
  • NAME: Shows device hierarchy with tree characters (├─, └─)
  • MAJ:MIN: Major:minor device numbers used by the kernel
  • RM: Removable device indicator (0=fixed, 1=removable)
  • SIZE: Human-readable size of the device/partition
  • RO: Read-only status (0=read-write, 1=read-only)
  • TYPE: Device type (disk, part, lvm, rom, etc.)
  • MOUNTPOINT: Where the device is currently mounted (if anywhere)

In this example, you can see:

  • sda is a 465.8GB disk with three partitions, where sda3 contains LVM volumes
  • sdb is a 1.8TB disk with one large partition mounted at /data
  • nvme0n1 is an NVMe drive with two partitions
  • sr0 is an optical drive (rom type)

Example 2: Filesystem Information Display

Show detailed filesystem information including types, labels, and UUIDs.

$ lsblk -f
NAME FSTYPE LABEL UUID MOUNTPOINT sda ├─sda1 vfat EFI A1B2-C3D4 /boot/efi ├─sda2 xfs BOOT 12345678-1234-1234-1234-123456789abc /boot └─sda3 LVM2_member 98765432-4321-4321-4321-cba987654321 ├─ol-root xfs abcdef01-2345-6789-abcd-ef0123456789 / ├─ol-swap swap fedcba98-7654-3210-fedc-ba9876543210 [SWAP] └─ol-home xfs 11111111-2222-3333-4444-555555555555 /home sdb └─sdb1 xfs DATA 66666666-7777-8888-9999-000000000000 /data nvme0n1 ├─nvme0n1p1 ext4 NVME1 aaaaaaaa-bbbb-cccc-dddd-eeeeeeeeeeee /mnt/nvme1 └─nvme0n1p2 ext4 NVME2 ffffffff-eeee-dddd-cccc-bbbbbbbbbbbb /mnt/nvme2 sr0
Explanation: The -f option shows filesystem-specific information:
  • FSTYPE: Filesystem type (xfs, ext4, vfat, swap, LVM2_member)
  • LABEL: Filesystem label (useful for identifying purpose)
  • UUID: Unique identifier for the filesystem (used in /etc/fstab)

This is particularly useful when:

  • Setting up /etc/fstab entries (use UUID for stability)
  • Identifying filesystems after hardware changes
  • Verifying filesystem types before mounting
  • Finding LVM physical volumes (LVM2_member type)

Example 3: Custom Column Selection

Display only the columns you need for specific troubleshooting or documentation.

$ lsblk -o NAME,SIZE,TYPE,FSTYPE,MOUNTPOINT,MODEL
NAME SIZE TYPE FSTYPE MOUNTPOINT MODEL sda 465.8G disk Samsung SSD 860 ├─sda1 512M part vfat /boot/efi ├─sda2 1G part xfs /boot └─sda3 464.3G part LVM2_member ├─ol-root 50G lvm xfs / ├─ol-swap 15.7G lvm swap [SWAP] └─ol-home 398.6G lvm xfs /home sdb 1.8T disk WDC WD20EFRX-68 └─sdb1 1.8T part xfs /data nvme0n1 1.8T disk Samsung SSD 980 ├─nvme0n1p1 500G part ext4 /mnt/nvme1 └─nvme0n1p2 1.3T part ext4 /mnt/nvme2
Explanation: The -o option lets you specify exactly which columns to display. This example adds MODEL information, which helps identify:
  • Specific drive models for warranty tracking
  • Drive performance characteristics
  • Which physical drive is which device name

Common column combinations:

  • -o NAME,SIZE,TYPE,MOUNTPOINT - Quick overview
  • -o NAME,UUID,LABEL,FSTYPE - For fstab work
  • -o NAME,SIZE,VENDOR,MODEL,SERIAL - Hardware inventory
  • -o NAME,MAJ:MIN,RM,RO,STATE - Device status check

Example 4: List Format Without Tree Structure

Display devices in a flat list format, easier for parsing or when tree structure isn't needed.

$ lsblk -l
NAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINT 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 ol-root 253:0 0 50G 0 lvm / ol-swap 253:1 0 15.7G 0 lvm [SWAP] ol-home 253:2 0 398.6G 0 lvm /home sdb 8:16 0 1.8T 0 disk sdb1 8:17 0 1.8T 0 part /data nvme0n1 259:0 0 1.8T 0 disk nvme0n1p1 259:1 0 500G 0 part /mnt/nvme1 nvme0n1p2 259:2 0 1.3T 0 part /mnt/nvme2 sr0 11:0 1 1024M 0 rom
Explanation: The -l (list) option removes the tree structure and displays all devices in a flat list. This is useful for:
  • Scripting and parsing output with grep/awk
  • Counting devices: lsblk -l | wc -l
  • Finding specific devices: lsblk -l | grep nvme
  • Simplifying output when you don't need hierarchy
# Practical example: Find all mounted ext4 filesystems
$ lsblk -l -o NAME,FSTYPE,MOUNTPOINT | grep ext4
nvme0n1p1 ext4 /mnt/nvme1
nvme0n1p2 ext4 /mnt/nvme2

Example 5: Show Only Top-Level Block Devices

Display only the physical devices without partitions or holders.

$ lsblk -d
NAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINT sda 8:0 0 465.8G 0 disk sdb 8:16 0 1.8T 0 disk nvme0n1 259:0 0 1.8T 0 disk sr0 11:0 1 1024M 0 rom
Explanation: The -d (nodeps) option shows only the top-level devices without their dependencies (partitions, LVM volumes, etc.). This is useful for:
  • Getting a quick count of physical disks
  • Identifying which physical disks are in the system
  • Hardware inventory
  • Determining disk sizes before partitioning
# Add more detail about the physical disks
$ lsblk -d -o NAME,SIZE,TYPE,MODEL,VENDOR,SERIAL
NAME SIZE TYPE MODEL VENDOR SERIAL
sda 465.8G disk Samsung SSD 860 ATA S3Z9NB0K123456
sdb 1.8T disk WDC WD20EFRX-68 ATA WD-WCC4M123456
nvme0n1 1.8T disk Samsung SSD 980 Samsung S5GXNX0R123456
sr0 1024M rom DVD+-RW GH24NSC5 HL-DT-ST ABCD1234

Example 6: Show Specific Devices Only

Target specific block devices for detailed examination.

# Show only NVMe devices
$ lsblk /dev/nvme0n1
NAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINT
nvme0n1 259:0 0 1.8T 0 disk
├─nvme0n1p1 259:1 0 500G 0 part /mnt/nvme1
└─nvme0n1p2 259:2 0 1.3T 0 part /mnt/nvme2
# Show specific disk with filesystem info
$ lsblk -f /dev/sda
NAME FSTYPE LABEL UUID MOUNTPOINT
sda
├─sda1 vfat EFI A1B2-C3D4 /boot/efi
├─sda2 xfs BOOT 12345678-1234-1234-1234-123456789abc /boot
└─sda3 LVM2_member 98765432-4321-4321-4321-cba987654321
├─ol-root xfs abcdef01-2345-6789-abcd-ef0123456789 /
├─ol-swap swap fedcba98-7654-3210-fedc-ba9876543210 [SWAP]
└─ol-home xfs 11111111-2222-3333-4444-555555555555 /home
# Show multiple specific devices
$ lsblk /dev/sda /dev/sdb
NAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINT
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
├─ol-root 253:0 0 50G 0 lvm /
├─ol-swap 253:1 0 15.7G 0 lvm [SWAP]
└─ol-home 253:2 0 398.6G 0 lvm /home
sdb 8:16 0 1.8T 0 disk
└─sdb1 8:17 0 1.8T 0 part /data
Explanation: You can specify one or more device paths to examine only those devices. This is useful when:
  • Troubleshooting a specific disk
  • Documenting configuration of particular storage
  • Verifying changes to a specific device
  • Reducing output clutter in systems with many disks

Example 7: JSON Output for Scripting and Automation

Generate machine-readable JSON output for integration with scripts and tools.

$ lsblk -J
{ "blockdevices": [ {"name": "sda", "maj:min": "8:0", "rm": false, "size": "465.8G", "ro": false, "type": "disk", "mountpoint": null, "children": [ {"name": "sda1", "maj:min": "8:1", "rm": false, "size": "512M", "ro": false, "type": "part", "mountpoint": "/boot/efi"}, {"name": "sda2", "maj:min": "8:2", "rm": false, "size": "1G", "ro": false, "type": "part", "mountpoint": "/boot"}, {"name": "sda3", "maj:min": "8:3", "rm": false, "size": "464.3G", "ro": false, "type": "part", "mountpoint": null, "children": [ {"name": "ol-root", "maj:min": "253:0", "rm": false, "size": "50G", "ro": false, "type": "lvm", "mountpoint": "/"}, {"name": "ol-swap", "maj:min": "253:1", "rm": false, "size": "15.7G", "ro": false, "type": "lvm", "mountpoint": "[SWAP]"}, {"name": "ol-home", "maj:min": "253:2", "rm": false, "size": "398.6G", "ro": false, "type": "lvm", "mountpoint": "/home"} ] } ] }, {"name": "sdb", "maj:min": "8:16", "rm": false, "size": "1.8T", "ro": false, "type": "disk", "mountpoint": null, "children": [ {"name": "sdb1", "maj:min": "8:17", "rm": false, "size": "1.8T", "ro": false, "type": "part", "mountpoint": "/data"} ] } ]
Explanation: The -J option outputs data in JSON format, which is ideal for:
  • Parsing with jq or Python scripts
  • Integration with configuration management tools
  • Building automated inventory systems
  • Web API responses
# Example: Extract all mounted partitions using jq
$ lsblk -J | jq -r '.blockdevices[].children[]? | select(.mountpoint != null) | "\(.name): \(.mountpoint)"'
sda1: /boot/efi
sda2: /boot
ol-root: /
ol-swap: [SWAP]
ol-home: /home
sdb1: /data

# Get total disk space
$ lsblk -J -b | jq '[.blockdevices[] | select(.type=="disk") | .size | tonumber] | add / 1073741824 | floor'
3902 # Total GB across all disks

Example 8: Pairs Format for Shell Scripting

Output in key="value" format that's easy to source in shell scripts.

$ lsblk -P -o NAME,SIZE,TYPE,FSTYPE,MOUNTPOINT
NAME="sda" SIZE="465.8G" TYPE="disk" FSTYPE="" MOUNTPOINT="" NAME="sda1" SIZE="512M" TYPE="part" FSTYPE="vfat" MOUNTPOINT="/boot/efi" NAME="sda2" SIZE="1G" TYPE="part" FSTYPE="xfs" MOUNTPOINT="/boot" NAME="sda3" SIZE="464.3G" TYPE="part" FSTYPE="LVM2_member" MOUNTPOINT="" NAME="ol-root" SIZE="50G" TYPE="lvm" FSTYPE="xfs" MOUNTPOINT="/" NAME="ol-swap" SIZE="15.7G" TYPE="lvm" FSTYPE="swap" MOUNTPOINT="[SWAP]" NAME="ol-home" SIZE="398.6G" TYPE="lvm" FSTYPE="xfs" MOUNTPOINT="/home" NAME="sdb" SIZE="1.8T" TYPE="disk" FSTYPE="" MOUNTPOINT="" NAME="sdb1" SIZE="1.8T" TYPE="part" FSTYPE="xfs" MOUNTPOINT="/data"
Explanation: The -P (pairs) option outputs data in a format that can be directly sourced in shell scripts. Each line contains all the requested fields for one device.
#!/bin/bash
# Example script using lsblk pairs output

lsblk -P -o NAME,SIZE,FSTYPE,MOUNTPOINT | while read line; do
eval "$line"

# Process only mounted xfs filesystems
if [[ "$FSTYPE" == "xfs" && -n "$MOUNTPOINT" && "$MOUNTPOINT" != "[SWAP]" ]]; then
echo "XFS filesystem $NAME ($SIZE) mounted at $MOUNTPOINT"
fi
done

# Output:
# XFS filesystem sda2 (1G) mounted at /boot
# XFS filesystem ol-root (50G) mounted at /
# XFS filesystem ol-home (398.6G) mounted at /home
# XFS filesystem sdb1 (1.8T) mounted at /data

Example 9: Display Topology Information

Show device topology details including alignment and minimum I/O size.

$ lsblk -t
NAME ALIGNMENT MIN-IO OPT-IO PHY-SEC LOG-SEC ROTA SCHED RQ-SIZE RA WSAME sda 0 512 0 512 512 0 mq-deadline 1024 128 0B ├─sda1 0 512 0 512 512 0 mq-deadline 1024 128 0B ├─sda2 0 512 0 512 512 0 mq-deadline 1024 128 0B └─sda3 0 512 0 512 512 0 mq-deadline 1024 128 0B ├─ol-root 0 512 0 512 512 0 128 128 0B ├─ol-swap 0 512 0 512 512 0 128 128 0B └─ol-home 0 512 0 512 512 0 128 128 0B sdb 0 4096 0 4096 512 0 mq-deadline 1024 128 0B └─sdb1 0 4096 0 4096 512 0 mq-deadline 1024 128 0B nvme0n1 0 512 0 512 512 0 none 256 128 128M ├─nvme0n1p1 0 512 0 512 512 0 none 256 128 128M └─nvme0n1p2 0 512 0 512 512 0 none 256 128 128M
Explanation: The -t (topology) option displays low-level device characteristics:
  • ALIGNMENT: Alignment offset (bytes)
  • MIN-IO: Minimum I/O size
  • OPT-IO: Optimal I/O size (0 means not specified)
  • PHY-SEC: Physical sector size
  • LOG-SEC: Logical sector size
  • ROTA: Rotational device (0=SSD, 1=spinning disk)
  • SCHED: I/O scheduler in use
  • RQ-SIZE: Request queue size
  • RA: Read-ahead in KB
  • WSAME: Write same max bytes

This information is crucial for:

  • Identifying SSD vs HDD (ROTA field)
  • Verifying proper 4K alignment
  • Checking I/O scheduler configuration
  • Performance tuning and troubleshooting
  • Understanding sector size for advanced formatting
Note on NVMe I/O Schedulers: NVMe devices often use "none" scheduler because the NVMe protocol handles queuing efficiently at the hardware level, making traditional I/O scheduling less beneficial.

Example 10: Comprehensive System Storage Report

Combine multiple options to create a detailed storage inventory report.

# Detailed report with all relevant information
$ lsblk -o NAME,SIZE,TYPE,FSTYPE,MOUNTPOINT,LABEL,UUID,MODEL,SERIAL,VENDOR,RO,RM,ROTA
NAME SIZE TYPE FSTYPE MOUNTPOINT LABEL UUID MODEL SERIAL VENDOR RO RM ROTA sda 465.8G disk Samsung SSD 860 S3Z9NB0K123456 ATA 0 0 0 ├─sda1 512M part vfat /boot/efi EFI A1B2-C3D4 0 0 0 ├─sda2 1G part xfs /boot BOOT 12345678-1234-1234-1234-123456789abc 0 0 0 └─sda3 464.3G part LVM2_member 98765432-4321-4321-4321-cba987654321 0 0 0 ├─ol-root 50G lvm xfs / abcdef01-2345-6789-abcd-ef0123456789 0 0 0 ├─ol-swap 15.7G lvm swap [SWAP] fedcba98-7654-3210-fedc-ba9876543210 0 0 0 └─ol-home 398.6G lvm xfs /home 11111111-2222-3333-4444-555555555555 0 0 0 sdb 1.8T disk WDC WD20EFRX-68 WD-WCC4M123456 ATA 0 0 0 └─sdb1 1.8T part xfs /data DATA 66666666-7777-8888-9999-000000000000 0 0 0 nvme0n1 1.8T disk Samsung SSD 980 S5GXNX0R123456 Samsung 0 0 0 ├─nvme0n1p1 500G part ext4 /mnt/nvme1 NVME1 aaaaaaaa-bbbb-cccc-dddd-eeeeeeeeeeee 0 0 0 └─nvme0n1p2 1.3T part ext4 /mnt/nvme2 NVME2 ffffffff-eeee-dddd-cccc-bbbbbbbbbbbb 0 0 0
# Alternative: Create a formatted report script
#!/bin/bash

echo "=================================="
echo "System Storage Report"
echo "Generated: $(date)"
echo "Hostname: $(hostname)"
echo "=================================="
echo ""

echo "Physical Disks:"
lsblk -d -o NAME,SIZE,TYPE,MODEL,VENDOR,SERIAL,ROTA | grep disk
echo ""

echo "Mounted Filesystems:"
lsblk -l -o NAME,SIZE,FSTYPE,MOUNTPOINT,LABEL,UUID | grep -v "^$" | grep -v "MOUNTPOINT$" | awk '$4 != ""'
echo ""

echo "Storage by Type:"
echo " SSDs (ROTA=0):"
lsblk -d -o NAME,SIZE,MODEL | grep -B100 "ROTA" | awk 'NR>1'
echo ""

echo "Total Disk Space:"
lsblk -d -b -o SIZE | awk 'NR>1 {sum+=$1} END {print " " sum/1024/1024/1024 " GB"}'
echo ""

echo "LVM Volumes:"
lsblk -l | grep lvm
echo ""
Explanation: This comprehensive example demonstrates how to combine lsblk with other tools to create detailed storage reports. Such reports are invaluable for:
  • System documentation
  • Capacity planning
  • Hardware inventory
  • Audit compliance
  • Troubleshooting reference

The custom columns provide everything needed to understand the storage configuration at a glance, including hardware details (MODEL, SERIAL, VENDOR) and software configuration (FSTYPE, LABEL, UUID, MOUNTPOINT).

Practical Use Cases

1. Finding a Device for Mounting

# You just inserted a USB drive - find it
$ lsblk -p | tail -5
│ └─/dev/sda3 464.3G part LVM2_member
│ ├─/dev/mapper/ol-root 50G lvm xfs /
│ ├─/dev/mapper/ol-swap 15.7G lvm swap [SWAP]
│ └─/dev/mapper/ol-home 398.6G lvm xfs /home
/dev/sdc 14.9G disk
└─/dev/sdc1 14.9G part vfat

# Mount it
$ sudo mount /dev/sdc1 /mnt/usb

2. Verifying Partition Layout Before Installation

# Check target disk before OS installation
$ lsblk -f /dev/sda

# Verify it's the right disk and empty
$ lsblk -d -o NAME,SIZE,MODEL /dev/sda

3. Finding UUID for /etc/fstab

# Get UUID of a specific partition
$ lsblk -no UUID /dev/sdb1
66666666-7777-8888-9999-000000000000

# Or with more context
$ lsblk -f /dev/sdb1
NAME FSTYPE LABEL UUID MOUNTPOINT
sdb1 xfs DATA 66666666-7777-8888-9999-000000000000 /data

4. Checking LVM Structure

# See LVM layout clearly
$ lsblk | grep -E "disk|lvm|LVM"
sda 465.8G disk
└─sda3 464.3G part LVM2_member
├─ol-root 50G lvm xfs /
├─ol-swap 15.7G lvm swap [SWAP]
└─ol-home 398.6G lvm xfs /home

5. Identifying NVMe Devices and Namespaces

# List all NVMe devices
$ lsblk | grep nvme
nvme0n1 259:0 0 1.8T 0 disk
├─nvme0n1p1 259:1 0 500G 0 part /mnt/nvme1
└─nvme0n1p2 259:2 0 1.3T 0 part /mnt/nvme2

# Get detailed info on NVMe devices
$ lsblk -o NAME,SIZE,MODEL,SERIAL /dev/nvme*
NAME SIZE MODEL SERIAL
nvme0n1 1.8T Samsung SSD 980 S5GXNX0R123456
├─nvme0n1p1 500G
└─nvme0n1p2 1.3T

Tips and Best Practices

Performance Considerations

  • lsblk is very fast - it reads from sysfs, not directly from devices
  • Safe to run anytime without impacting system performance
  • Does not require root privileges for basic information
  • Some detailed info (SERIAL, etc.) may require root access

Common Pitfalls

  • Device Names Can Change: Use UUID or LABEL in /etc/fstab, not device names
  • Tree Structure Can Be Misleading: Physical relationships don't always match logical hierarchy
  • Empty Mountpoint Doesn't Mean Unused: Swap and LVM PVs show no mountpoint
  • Size May Not Match Exactly: Filesystem overhead means usable space is less than shown

Combining with Other Commands

# Get block device info with filesystem usage
$ lsblk && df -h

# Show devices and their SMART status
$ lsblk -d -o NAME,SIZE,MODEL | while read name size model; do
if [[ $name != "NAME" ]]; then
echo "$name: $model"
sudo smartctl -H /dev/$name | grep overall
fi
done

# Find all unmounted partitions
$ lsblk -ln -o NAME,MOUNTPOINT | awk '$2 == "" {print $1}'

# List all devices with their I/O schedulers
$ for dev in $(lsblk -d -n -o NAME); do
echo "$dev: $(cat /sys/block/$dev/queue/scheduler | grep -o '\[.*\]' | tr -d '[]')"
done

Aliases for Common Tasks

# Add to ~/.bashrc or ~/.bash_aliases

# Quick block device overview
alias lsb='lsblk -o NAME,SIZE,TYPE,FSTYPE,MOUNTPOINT'

# Show all disk details
alias lsbd='lsblk -d -o NAME,SIZE,MODEL,VENDOR,SERIAL'

# Filesystem info
alias lsbf='lsblk -f'

# List unmounted partitions
alias lsbu='lsblk -ln -o NAME,SIZE,FSTYPE,MOUNTPOINT | grep -v swap | awk "\$4 == \"\" && \$3 != \"\""'

Troubleshooting Scenarios

Problem: Can't Find Newly Added Disk

# Rescan SCSI bus
$ echo "- - -" | sudo tee /sys/class/scsi_host/host*/scan

# Check if it appears now
$ lsblk

# If still missing, check dmesg
$ dmesg | tail -50 | grep -i "sd[a-z]"

Problem: Device Shows Wrong Size

# Check partition table type (MBR limited to 2TB)
$ sudo parted /dev/sdb print

# Verify actual disk size
$ sudo blockdev --getsize64 /dev/sdb

# Compare with lsblk
$ lsblk -b -d -o NAME,SIZE /dev/sdb

Problem: Mountpoint Not Showing in lsblk

# Check if actually mounted
$ mount | grep sdb1

# Try full path
$ lsblk /dev/sdb1

# Check if it's a bind mount
$ findmnt /mnt/point

Summary

The lsblk command is an essential tool for Linux system administrators, providing a clear, hierarchical view of all block devices. Unlike older tools like fdisk -l, lsblk presents information in an intuitive tree format that makes understanding device relationships straightforward.

Key Takeaways

  • Use lsblk without options for a quick storage overview
  • Add -f to see filesystem information including UUIDs
  • Use -d to see only top-level physical devices
  • Customize output with -o to show exactly what you need
  • Use -J or -P for scriptable output formats
  • Specify device paths to focus on specific disks
  • Combine with other tools for comprehensive storage analysis
  • Create aliases for frequently used combinations

Further Reading

  • Man page: man lsblk
  • Related: man blkid, man findmnt
  • sysfs documentation: /usr/share/doc/kernel-doc-*/Documentation/filesystems/sysfs.txt
  • util-linux project: https://github.com/util-linux/util-linux