Swiss-army utility for inspecting Linux storage topology
lsblk (part of util-linux
) reads /sys
+ udev
DB to display block devices in a tree, optionally JSON, providing size, type, transport, mount-point, UUID, and more
Canonical pattern:
lsblk [options] [device…]
lsblk
(no args) to map every disk & partition.-f
or -t
to pull filesystem or topology detail.Tree vs list, human vs bytes
lsblk
displays all non-RAM devices in an ASCII hierarchy
lsblk -l
(one row per device)
lsblk -f
adds FS, LABEL, UUID info.
lsblk --bytes
avoids 4K/MB human abbreviations; critical for JSON math
Craft custom views or machine-readable output
lsblk --output NAME,SIZE,MODEL
lsblk --json
⇢ parse with jq
lsblk --pairs
⇢ key="value" per line
lsblk -n
(no header row)
Env var LSBLK_COLUMNS
defines default column set.
Include / exclude specific types or majors
lsblk -d
(no partitions) or lsblk -o NAME,TYPE | grep disk
lsblk -S
show SCSI / NVMe model, serial.
lsblk --exclude 1,7
skip RAM (1) and loop (7)
lsblk --include 8
show block major 8 (SCSI disks).
How disks connect & what features they offer
lsblk -t
adds rota (SSD?), sched, rq-size, phy-sec.
Column ALIGNMENT
reports misaligned partitions → performance hints.
Column HCTL
shows host:channel:target:lun for SCSI.
Understand what’s in use before tinkering
lsblk -f -o NAME,FSTYPE,MOUNTPOINT
Non-root sees everything but some fields blank if udev
inaccessible
Parse safely; avoid text-fragility
lsblk --json --bytes | jq '.blockdevices[] | select(.type==\"disk\")'
--nodeps
to target parents only.Handy one-liners for daily ops
Goal | Command |
---|---|
List removable USBs only | lsblk -o NAME,RM,SIZE,MOUNTPOINT | awk '$2==1' |
Find orphaned partitions | lsblk -f | grep -v '/' |
JSON inventory for CMDB | lsblk --json --bytes > /var/tmp/disks.json |
Check for 4 KiB mis-aligned starts | lsblk -o NAME,PHY-SEC,LOG-SEC,START | awk '$4%8' |
Keep data safe & scripts stable
--bytes
when parsing numbers programmatically.--json
over awk/grep to survive util-linux updates.dm-crypt
/ LVM hide parents; inspect with -p
.--all
requested.ZONED
Manual pages & technical notes