lsblk

lsblk lists the block devices on the system and their relationships — disks, their partitions, and the device-mapper and loop devices layered on top. It is the device-oriented companion to mount: where mount with no arguments shows what is mounted, lsblk shows what is available to mount and what filesystem sits on each device.

lsblk [options] [DEVICE...]

By default it prints a tree, one row per device with children indented beneath their parent. Given one or more DEVICE operands (a name like sda, a full path like /dev/sda, or anything resolving to a device node), it re-roots the output at those devices.

Where the data comes from #

Each column is sourced from one of four places, and any that cannot be read degrades to an empty cell rather than aborting the run:

  • sysfs (/sys/block) — the device tree, sizes, and the topology/hardware columns. Peios leaves /sys/block unpatched, so this is the standard no-udev path.
  • libblkid — filesystem identity: FSTYPE, FSVER, UUID, LABEL, and the partition-table columns. libblkid is opened at runtime.
  • The device node's security descriptorOWNER and MODE, read the same way ls -l reads them.
  • The /dev/disk/by-* symlink farmID-LINK. Populated by the device manager once it has run; there is deliberately no /run/udev/data parser, so the column reads the links themselves and is empty in the initramfs, where no device manager runs.

Output modes #

The mode selects how the rows are formatted; it does not change which columns are shown.

FlagMode
(default)Indented tree.
-l, --listFlat list — the same columns, no tree glyphs.
-J, --jsonJSON. Flag columns render as bare booleans and MOUNTPOINTS as an array; children nest under a children key.
-P, --pairsKEY="value" pairs, one device per line.
-r, --rawRaw, space-separated. Values that could contain a space or control character are hex-escaped (\xNN) so fields stay parseable.
-T, --tree[=COLUMN]Force tree output even alongside -l, optionally attaching the tree glyphs to COLUMN instead of NAME.

Columns #

With no column flag, lsblk prints the default set: NAME, MAJ:MIN, RM, SIZE, RO, TYPE, MOUNTPOINTS. Three flags swap in a preset, and -o names an explicit list (which wins over all of them):

FlagColumn set
-o, --output LISTExactly the comma-separated columns named (case-insensitive; an unknown name is a usage error).
-O, --output-allEvery available column.
-f, --fsFilesystem view: NAME, FSTYPE, FSVER, LABEL, UUID, MOUNTPOINTS.
-m, --permsPermissions view: NAME, SIZE, OWNER, MODE.

The available columns are NAME, KNAME, PATH, MAJ:MIN, FSTYPE, FSVER, LABEL, UUID, PTUUID, PTTYPE, PARTTYPE, PARTLABEL, PARTUUID, MOUNTPOINT, MOUNTPOINTS, SIZE, RO, RM, HOTPLUG, TYPE, OWNER, MODE, MODEL, VENDOR, REV, SERIAL, TRAN, HCTL, ALIGNMENT, MIN-IO, OPT-IO, PHY-SEC, LOG-SEC, STATE, ROTA, SCHED, PKNAME, and ID-LINK.

The OWNER and MODE columns #

OWNER and MODE describe the device node, not the filesystem on it, and they mirror ls -l exactly — there is no GROUP column and no POSIX permission bits, because access to a device node is governed by its security descriptor, not by a mode. OWNER is the owner SID (S-1-…); MODE is a three-character [type][x][+]: the device-type character (b for a block device, c for a character device), an x slot (never set for a block device), and a + when the DACL is inheritance-protected. When the SD cannot be read — for instance on a non-Peios host with no KACS syscalls — OWNER shows ? and MODE degrades honestly.

Filtering, sorting and shaping #

FlagEffect
-a, --allInclude empty (zero-size) devices, which are hidden by default.
-d, --nodepsDo not print a device's holders or slaves (drop the children).
-I, --include LISTShow only devices with these major numbers (comma-separated).
-e, --exclude LISTExclude devices by major number. The default is 1 (RAM disks); an explicit -e replaces that default, and -a clears exclusions entirely.
-s, --inversePrint dependencies in inverse order (holders above the devices they depend on).
-M, --mergeCollapse a subtree shared by several parents (a multipath device) to a single occurrence.
-E, --dedup COLUMNDrop rows whose COLUMN value duplicates an earlier one.
-x, --sort COLUMNSort siblings by COLUMN (numeric columns sort by value, not text).

Formatting #

FlagEffect
-b, --bytesPrint SIZE as an exact byte count instead of a human-readable value.
-p, --pathsPrint full /dev paths in the NAME column.
-n, --noheadingsOmit the header row.
-i, --asciiDraw the tree with ASCII characters instead of box-drawing glyphs.
-y, --shellRender column keys shell-safe (MAJ:MIN becomes MAJ_MIN).
-w, --width NUMTruncate each table row to NUM columns wide.
--sysroot DIRRead sysfs, the mount table and /dev from DIR instead of / (chiefly for testing against a fixture).
-h, --help / -V, --versionStandard.

Exit status #

CodeMeaning
0Success.
1Incorrect invocation (an unknown column, a malformed major-number or width value) or a failed run (for example, /sys/block is unreadable).

lsblk uses this single non-zero code, matching util-linux. A per-device read failure is not fatal: it degrades the affected columns to empty or ? and the run continues. A broken output pipe (piping into head, for instance) is treated as success.

Edit this page