opscape

Disks and filesystems

lsblk

List block devices (disks, partitions, LVM volumes, loop devices) as a tree, with sizes and mount points.

lsblk [OPTION...] [DEVICE...]

2 of 6 examples run in Debian 13.7 on 2026-10-31 · util-linux 2.41.5-0+deb13u1 · manual: lsblk(8)

lsblk answers "what disks does this machine have, how are they partitioned, and where is each piece mounted?". It reads the kernel's view of block devices from /sys and draws disks with their partitions, LVM volumes and RAID members indented below them. It needs no root for the basic listing.

Its most important job is safety: before you partition, format, or dd onto a device, run lsblk to be sure that /dev/sdb is the USB stick and not your backup disk. Plug the device in, run it again, and the new entry is the one to use.

The columns are configurable with -o; -f switches to filesystem columns (type, label, UUID, free space). For mounted filesystems rather than devices, findmnt is the counterpart, and df shows how full they are.

The examples on this page that list devices are not run: this site's sandbox is a container, and listing devices there would describe the build server's own disks. The ones that run show the tool's behavior without touching real devices.

Examples

List disks and partitions

lsblk
explain

Not run in the sandbox: lists the host machine's real disks; run it on your own system. No output is shown because none was captured.

Each disk (TYPE disk) is followed by its partitions (part), drawn as a tree, with SIZE, whether it is removable (RM) or read-only (RO), and MOUNTPOINTS. Snap packages and disk images show up as loop devices.

Filesystems, labels and UUIDs

lsblk -f
explain

Not run in the sandbox: lists the host machine's real disks; run it on your own system. No output is shown because none was captured.

-f shows FSTYPE, LABEL, UUID, free space and use percentage for each device. The UUID is what you put in /etc/fstab so mounts do not depend on device names like /dev/sdb1, which can change between boots.

Choose the columns

lsblk -o NAME,SIZE,TYPE,FSTYPE,MOUNTPOINTS,MODEL
explain

Not run in the sandbox: lists the host machine's real disks; run it on your own system. No output is shown because none was captured.

-o takes a comma-separated list. MODEL shows the drive's model name, which helps tell two disks of the same size apart.

See which columns exist

lsblk --list-columns | grep -E '^ *(NAME|SIZE|TYPE|FSTYPE|UUID|LABEL|MOUNTPOINTS|MODEL|ROTA|TRAN) '
explain
output
      FSTYPE <string>        filesystem type
       LABEL <string>        filesystem LABEL
       MODEL <string>        device identifier
        NAME <string>        device name
        ROTA <boolean>       rotational device
        SIZE <string|number> size of the device, use <number> if --bytes is given
 MOUNTPOINTS <string>        all locations where device is mounted
        TRAN <string>        device transport type
        TYPE <string>        device type
        UUID <string>        filesystem UUID

--list-columns (-H) prints every column lsblk knows, with its data type and a description; the grep keeps the ones most worth knowing. ROTA is 1 for spinning disks and 0 for SSDs, TRAN the transport (sata, nvme, usb).

Machine-readable output for scripts

lsblk -J -o NAME,SIZE,TYPE,MOUNTPOINTS | jq -r '.blockdevices[] | select(.type == "disk") | .name'
explain

Not run in the sandbox: lists the host machine's real disks; run it on your own system. No output is shown because none was captured.

-J prints JSON, which jq can query reliably; this prints the name of each whole disk. For simpler parsing, -n drops the header, -r prints raw space-separated columns, -d leaves out partitions, and -p prints full /dev/... paths.

Asking about something that is not a block device

lsblk /dev/null
explain
outputexit 32
lsblk: /dev/null: not a block device

lsblk accepts device paths as arguments to show just those devices. /dev/null is a character device, so it is rejected; exit status 32 means "none of the devices was found".

Common pitfalls

  • Device names (sda, sdb, nvme0n1) are assigned in detection order and can change between boots or when a USB disk is plugged in. Identify disks by size, model and lsblk -f UUIDs, never by name alone.

  • lsblk without root can leave some columns empty (filesystem details on some systems); sudo lsblk -f fills them in.

  • A SIZE of 0B for a loop or card-reader device means nothing is attached, not an empty disk.

GNU vs BSD and macOS

The examples above ran the GNU/Linux version. These are the differences that matter on macOS and the BSDs (written from their documentation, not run here).

  • lsblk is Linux-only (util-linux). On macOS use diskutil list; on FreeBSD, geom disk list or gpart show.

Options worth knowing

A selection, described in our own words. For the full list, see lsblk(8) or lsblk --help.

OptionWhat it does
-f, --fsShow filesystem columns: type, label, UUID, usage.
-o, --output LISTPrint the listed columns.
-O, --output-allPrint every available column.
-H, --list-columnsList the available columns and exit.
-a, --allInclude empty devices too.
-d, --nodepsDo not list partitions or holders, just whole devices.
-l, --listPlain list instead of a tree.
-J, --jsonPrint JSON.
-P, --pairsPrint KEY="value" pairs.
-r, --rawRaw output: space-separated, no tree.
-n, --noheadingsOmit the header line.
-p, --pathsPrint full device paths.
-b, --bytesPrint sizes in bytes.
-S, --scsiList SCSI devices only, with vendor and serial.
-e, --exclude LISTExclude devices by major number, e.g. 7 for loop.
-t, --topologyShow alignment and I/O size columns.
-m, --permsShow owner, group and mode of each device.

Related