Disks and filesystems
lsblk
List block devices (disks, partitions, LVM volumes, loop devices) as a tree, with sizes and mount points.
lsblk [OPTION...] [DEVICE...]
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
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
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
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) '
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'
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
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 andlsblk -fUUIDs, never by name alone.lsblkwithout root can leave some columns empty (filesystem details on some systems);sudo lsblk -ffills them in.A
SIZEof0Bfor aloopor 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).
lsblkis Linux-only (util-linux). On macOS usediskutil list; on FreeBSD,geom disk listorgpart show.
Options worth knowing
A selection, described in our own words. For the full list, see lsblk(8) or lsblk --help.
| Option | What it does |
|---|---|
-f, --fs | Show filesystem columns: type, label, UUID, usage. |
-o, --output LIST | Print the listed columns. |
-O, --output-all | Print every available column. |
-H, --list-columns | List the available columns and exit. |
-a, --all | Include empty devices too. |
-d, --nodeps | Do not list partitions or holders, just whole devices. |
-l, --list | Plain list instead of a tree. |
-J, --json | Print JSON. |
-P, --pairs | Print KEY="value" pairs. |
-r, --raw | Raw output: space-separated, no tree. |
-n, --noheadings | Omit the header line. |
-p, --paths | Print full device paths. |
-b, --bytes | Print sizes in bytes. |
-S, --scsi | List SCSI devices only, with vendor and serial. |
-e, --exclude LIST | Exclude devices by major number, e.g. 7 for loop. |
-t, --topology | Show alignment and I/O size columns. |
-m, --perms | Show owner, group and mode of each device. |
Related
findmntShow mounted filesystems as a tree, or look up which filesystem a path is on and how it is mounted.dfReport how much space is used and free on mounted filesystems.mountAttach a filesystem (a disk partition, image, network share or tmpfs) to a directory, or list what is mounted.ddCopy bytes between files or devices in fixed-size blocks, with optional offsets and conversions.duShow how much disk space files and directories use, totalled per directory.