The Boring Infra ▍

LINUX · STORAGE

How to list block devices with lsblk

17 November 2026 · 9 minute read

A node had a disk that df didn't know about. The filesystem was full, the numbers were small, and the extra volume sat there unpartitioned while every command I tried described only what was mounted. lsblk was the command that showed it, because it lists devices rather than filesystems, and a device with nothing mounted on it's exactly the thing df leaves out. It needs no root, it reads from sysfs, and it still works when half the machine is in a bad state.

Run lsblk with no arguments to print the block device tree. Add -f for filesystem type and UUID, -o to choose columns, -e 7 to leave out loop devices, and -J when a script needs to parse the output.

What lsblk prints

No arguments, and you get a tree of every block device with its size, type and mount points. Disks at the left, partitions indented under the disk they belong to.

$ lsblk
NAME        MAJ:MIN RM   SIZE RO TYPE MOUNTPOINTS
...
nvme0n1     259:0    0   3.7T  0 disk
├─nvme0n1p1 259:1    0   298M  0 part /boot/efi
└─nvme0n1p2 259:2    0   3.6T  0 part /

That box printed 28 lines, and 24 of them were loop devices holding snap packages. On a laptop that's noise. On a server you mostly want the disks, so the version of this command I actually type filters the loops out.

$ lsblk -e 7
NAME        MAJ:MIN RM  SIZE RO TYPE MOUNTPOINTS
nvme0n1     259:0    0  3.7T  0 disk
├─nvme0n1p1 259:1    0  298M  0 part /boot/efi
└─nvme0n1p2 259:2    0  3.6T  0 part /

7 is the major device number of loop devices, and -e takes a comma separated list of major numbers to leave out. The filter applies to top level devices only, so it drops the loop devices and leaves anything under them alone. That matters in -l output, where the tree is flattened and you can no longer see which device a row belonged to.

Disks, partitions, and mount points

Every row has a type, and the type is what tells you whether you're looking at hardware or at something carved out of it.

The other columns carry the state. RM is 1 for removable, which is how you spot a USB stick. RO is 1 for read only, and a disk that flips to read only under load is a failing disk, not a permissions problem. MAJ:MIN is the major and minor number the kernel uses, and it's the number -e takes.

Then the column that matters most. MOUNTPOINTS is empty when nothing is mounted, which is why this beats df. Empty MOUNTPOINTS means nothing is mounted, not that nothing is using it. On an LVM host a whole disk is a physical volume with no filesystem and no mount point, and it's very much in use. Check pvs and vgs before you call a device idle free space.

The name is plural on purpose. One filesystem can be mounted in several places, so MOUNTPOINTS prints every one of them in a cell that can run over multiple lines. The older MOUNTPOINT column shows only one, usually the last mount, which is why the current column list uses the plural and why the JSON output below comes back as an array.

Filesystem details with -f

-f replaces the default columns entirely, so there's no SIZE or TYPE in this view. It's equivalent to -o NAME,FSTYPE,FSVER,LABEL,UUID,FSAVAIL,FSUSE%,MOUNTPOINTS.

$ lsblk -f -e 7
NAME        FSTYPE FSVER LABEL UUID                                 FSAVAIL FSUSE% MOUNTPOINTS
nvme0n1 
├─nvme0n1p1 vfat   FAT32 EFI   1C4E-77A0                             284.7M     4% /boot/efi
└─nvme0n1p2 ext4   1.0   root  0f3a7c2e-51b4-4d8a-9c77-2b6d84e1a503    3.2T     4% /

This is the view you need before you touch /etc/fstab, because UUID is the identifier that survives a device being renamed. FSAVAIL and FSUSE% come free with it, so one command answers what is on the disk and how much room is left. FSTYPE being empty on nvme0n1 is correct and worth reading carefully. The disk itself has no filesystem. The partitions do.

Choose your own columns

The man page says the default output is subject to change, so anything you script should name its columns. -o takes a comma separated list.

$ lsblk -o NAME,SIZE,FSTYPE,MOUNTPOINTS -e 7
NAME         SIZE FSTYPE MOUNTPOINTS
nvme0n1      3.7T
├─nvme0n1p1  298M vfat   /boot/efi
└─nvme0n1p2  3.6T ext4   /

lsblk --help prints every column this version supports, and the list differs between util-linux releases. From util-linux 2.40 there's also --list-columns for the same list, and on 2.39 the option doesn't exist, so the help output is the safe thing to reach for. Two other forms do different jobs. -d is --nodeps, printing each device without its holders or slaves, which on a plain machine amounts to the disks without their partitions. -p prints full device paths, so the output can be pasted straight into another command.

$ lsblk -d -e 7
NAME    MAJ:MIN RM  SIZE RO TYPE MOUNTPOINTS
nvme0n1 259:0    0  3.7T  0 disk

$ lsblk -p -e 7
NAME             MAJ:MIN RM  SIZE RO TYPE MOUNTPOINTS
/dev/nvme0n1     259:0    0  3.7T  0 disk
├─/dev/nvme0n1p1 259:1    0  298M  0 part /boot/efi
└─/dev/nvme0n1p2 259:2    0  3.6T  0 part /

JSON for scripts

Reading a table with awk works until a label has a space in it. -J is the honest form for anything that parses, though it needs jq to be worth it and a minimal RHEL install doesn't ship that. -P prints key=value pairs a shell loop can read with nothing installed.

$ lsblk -J -o NAME,SIZE,TYPE,MOUNTPOINTS -e 7
{
   "blockdevices": [
      {
         "name": "nvme0n1",
         "size": "3.7T",
         "type": "disk",
         "mountpoints": [
             null
         ],
         "children": [
            {
               "name": "nvme0n1p1",
               "size": "298M",
               "type": "part",
               "mountpoints": [
                   "/boot/efi"
               ]
            },{
               "name": "nvme0n1p2",
               "size": "3.6T",
               "type": "part",
               "mountpoints": [
                   "/"
               ]
            }
         ]
      }
   ]
}

The tree becomes a children array, which is the structure your code wants anyway. One warning from the man page. The tree and the children array only appear when NAME is in the output. Pass -J with -o and leave NAME out, and you get a flat set of devices with no parents.

df versus lsblk

One caveat before the comparison. Inside a container lsblk reads the host's sysfs, so it shows the node's disks with empty mount points while the only paths it can name belong to the container. In a pod, findmnt -T / tells you what your root actually is, usually an overlay, and the disk list is the node's problem, not yours.

Two commands, two questions. lsblk answers what hardware exists and how it's carved up. df answers how much room a mounted filesystem has left, and du adds up what is using it.

$ df -h | head -4
Filesystem      Size  Used Avail Use% Mounted on
tmpfs            13G  3.0M   13G   1% /run
efivarfs        256K   23K  234K   9% /sys/firmware/efi/efivars
/dev/nvme0n1p2  3.6T  157G  3.3T   5% /

Notice what df lists that lsblk never will. tmpfs isn't a device, and efivarfs isn't either. Going the other way, a disk with no partition and no mount point appears in lsblk with an empty mount point and never appears in df at all. That gap is the one that had me hunting for a volume that plainly existed.

The two commands also disagree on the percentage, and neither is wrong. On this box lsblk -f called the root filesystem 4% used with 3.2T free, while df said 5% and 3.3T. Neither is wrong, and the free space is the same. df computes the percentage against what a user can actually write and rounds up, while lsblk divides by the whole filesystem and rounds down. Read df when you care how much a user can write, and read lsblk when you care which devices exist.

Which one to use, at a glance

CommandWhat it doesReach for it when
lsblkPrints the full device treeYou want the whole picture
lsblk -e 7Leaves out loop devicesSnap or image loops are burying the real disks
lsblk -fAdds filesystem, label and UUIDYou're about to edit fstab
lsblk -dDisks only, no partitionsYou want to count hardware
lsblk -o NAME,SIZE,TYPEYour own columnsYou're printing it in a script
lsblk -pFull device pathsYou're piping the paths onward
lsblk -JJSON outputCode needs to parse it
df -hSpace left per mounted filesystemThe question is free space, not hardware

Verify it works

$ lsblk | wc -l
28

$ lsblk -e 7 | wc -l
4

$ lsblk -d -e 7
NAME    MAJ:MIN RM  SIZE RO TYPE MOUNTPOINTS
nvme0n1 259:0    0  3.7T  0 disk

$ lsblk -f -e 7 | awk 'NR>1 {print $1, $2}'
nvme0n1 
├─nvme0n1p1 vfat
└─nvme0n1p2 ext4

The line counts show what -e 7 removed. The disk only view gives you one line per physical device, and the last one prints just the name and filesystem type, which is the shape most scripts actually need. The first row of that last block looks short because the disk itself has no filesystem, so there's no second field to print.

The honest caveat

Everything here reads the kernel's view of the devices, not the devices themselves. lsblk reads sysfs and the udev database, so a filesystem it reports as ext4 is what the metadata said the last time it was read. If the partition table was rewritten five minutes ago, the answer can be stale until the kernel reads the table again.

Labels, UUIDs and filesystem types come from udev. When udev is unavailable, or the build of lsblk has no udev support, the command falls back to reading the block device directly, and that does need root. That's the reason lsblk -f shows empty UUIDs on some minimal images and fills them in on others. Same command, different privileges, so check rather than assume.

On the nodes I run, lsblk -o NAME,SIZE,TYPE,MOUNTPOINT is the first thing I type after an instance comes up, before any filesystem work. It takes a second and it tells you which volume is attached and whether the image actually mounted it where you planned. The number of times that has caught a volume attached to the wrong node isn't small.

The boring conclusion

lsblk answers what devices exist, which is a different question from df, and the two disagree on purpose. Run it plain for the tree, add -f for UUIDs, -e 7 to silence the loops, and -J when something else has to read it.

What's the disk that turned up attached to the wrong box?

Frequently asked questions

What does lsblk do?

lsblk lists the block devices on the machine. It reads the sysfs filesystem and the udev database and prints disks, partitions and loop devices in a tree with their sizes, types and mount points.

How do I show filesystem types and UUIDs?

Run lsblk -f. It adds FSTYPE, FSVER, LABEL, UUID, FSAVAIL and FSUSE% to the default output, which is the view you want before editing fstab or mounting by UUID.

How do I get lsblk output as JSON?

Run lsblk -J. It prints the same tree as JSON, with a children array per device. Add -o and -J together to control which columns end up in the JSON.

Why is df missing a disk that lsblk shows?

Because df only lists mounted filesystems and lsblk lists devices. A disk with no partition and no mount point shows up in lsblk with an empty MOUNTPOINTS column and never in df.

What are the loop devices in the lsblk output?

They are files mounted as block devices, usually snaps or container images. They aren't real disks. Run lsblk -e 7 to leave them out, which filters by the major device number of loop devices.

Does lsblk need root?

Usually not. It reads the udev database for labels, UUIDs and filesystem types. If udev is unavailable and lsblk has to read the device itself, root permissions are required.

Why does the default lsblk output change between versions?

The man page says the default output is subject to change. Scripts should always name their columns with -o and use -J or --pairs instead of parsing the table.

Resources

The manual pages below are what the command documents, including the warning about parsing the default output.

  • lsblk(8) on man7.org. Every column and option, plus the note that the default output can change between versions.
  • blkid(8) on man7.org. The library behind the fallback that lsblk -f uses when the udev database has no answer. blkid's own page points the other way, recommending lsblk for scripting because unprivileged blkid returns cached, unverified values.

This builds on how to remove a directory on linux. Next up is filling a disk before you mount it, which starts with fdisk.

When a device fills up, the next two questions are answered by df and du.