Skip to content

lsblk

Learn how to use the lsblk command to list Linux block devices, disks, and partitions. Includes practical examples for filesystems, UUIDs, sizes, JSON output, scripting, and hardware inspection


Shows a tree view of disks, partitions, and mount points.

lsblk

Include filesystem type, UUID, and labels

  • Useful for identifying filesystems and matching them with /etc/fstab.
lsblk -f

Show sizes in bytes (exact values)

lsblk -b

Show only top-level disks (no partitions)

  • Good for detecting physical disks without clutter from partitions.
lsblk -d

Output in a script-friendly format

lsblk -o NAME,SIZE,TYPE,MOUNTPOINT

Show permissions and ownership

lsblk -m

List block devices

lsblk -o name,type,fstype,label,partlabel,model,mountpoint,size

Detect partitions

lsblk -o NAME,TYPE,FSTYPE,LABEL,SIZE,MODEL,MOUNTPOINT

Quick and dirty hardware summary

echo -e "\nCPU\n";      lscpu
echo -e "\nMEMORY\n";   free -h
echo -e "\nDISKS\n";    lsblk
echo -e "\nPCI\n";      lspci
echo -e "\nUSB\n";      lsusb
echo -e "\nNETWORK\n";  ifconfig
} | less

Display disk partition sizes

lsblk | grep -v part | awk '{print $1 "\t" $4}'

Show drive names next to their full serial number

lsblk -do name,model,serial

Filter by device type (e.g., disks only)

lsblk -o NAME,SIZE,TYPE | grep disk

Show major/minor device numbers

lsblk -o NAME,MAJ:MIN,SIZE,TYPE

JSON output (excellent for automation)

lsblk -J

Show all devices, including empty ones

lsblk -a

Print total spaces of drives connected in json format

  • app-misc/jq is required to be installed
lsblk --json | jq -c '.blockdevices[]|[.name,.size]'

Display disk partition sizes

lsblk -o name,size

Displayu disk partition sizes

lsblk | grep -v part | awk '{print $1 "\t" $4}'