What it does
lsblk reads /sys and shows every block device and what sits on it: partitions, LVM logical volumes, RAID, encrypted volumes. With -f it adds the file system type, label, UUID and free space. It is the first command before you touch a disk.
How to write it
lsblk [OPTION]... [DEVICE]...Options 33
Most used
What to show
Format
Nothing matches this filter.
Examples 11
$ run as a normal user# run as root (or with sudo)
1All disks and partitions
lsblk NAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINTS vda 252:0 0 20G 0 disk ├─vda1 252:1 0 1G 0 part /boot └─vda2 252:2 0 19G 0 part ├─rhel-root 253:0 0 17G 0 lvm / └─rhel-swap 253:1 0 2G 0 lvm [SWAP] vdb 252:16 0 10G 0 diskvdb has no partitions: a new disk.
2File systems and UUIDs
lsblk -fFSTYPE, LABEL, UUID, FSAVAIL, FSUSE%, MOUNTPOINTS.
3Only the disks
lsblk -d -o NAME,SIZE,MODEL,TRANModel and connection (sata, nvme, usb).
4One disk with full paths
lsblk -p /dev/vdbCopy the paths for the next commands.
5Choose columns
lsblk -o NAME,SIZE,TYPE,FSTYPE,UUID,MOUNTPOINTSJust what you need.
6Find empty disks
lsblk -dn -o NAME,TYPE,SIZE | awk '$2=="disk"' ; lsblk -fA disk with no children and no FSTYPE is unused.
7JSON for scripts
lsblk -J -o NAME,SIZE,MOUNTPOINTS | jq '.blockdevices[].name'Machine-readable.
8Check SSD TRIM support
lsblk -DDISC-GRAN not 0 = discard works (fstrim.timer can use it).
9Who owns a device file
lsblk -m /dev/vdbOwner, group and mode of the device node.
10See the device under a mount point
lsblk -s /dev/mapper/rhel-rootInverse tree: from the LV down to the disk.
11Find USB disks that are plugged in (security)
lsblk -o NAME,TRAN,SIZE,MOUNTPOINTS | grep usbCheck for unknown removable storage.
Nothing matches this filter.
Exit codes
0 :: Done. 1 :: Error. 32 :: No device found. 64 :: Some devices worked, some failed.