Skip to main content

lsblk — List Block Devices

lsblk prints a tree view of your disks, partitions, and mount points. Use it before you mount/unmount a volume, resize a disk, or troubleshoot "disk full" incidents so you know exactly which device backs /, /var/www, /var/lib/mysql, or /mnt/backups. The -p flag is especially useful because it prints full device paths (for copy/paste safety).

Quick Summary

Run lsblk -p -f to see full device paths plus filesystem type and UUID, then confirm your WordPress paths with df -h /var/www/html and findmnt -T /var/www/html.

Mental Model

block-device-tree.txt
/dev/sda (disk)
└─/dev/sda1 (partition) -> mounted at /
/dev/sdb (disk)
└─/dev/sdb1 (partition) -> mounted at /mnt/backups

Prerequisites

lsblk is provided by the util-linux package and is installed by default on most Linux servers.

Verify it exists:

verify-lsblk-installed.sh
which lsblk
lsblk --version

Core Syntax

lsblk-syntax.sh
lsblk [OPTIONS] [DEVICE...]
  • If you omit DEVICE, lsblk lists all block devices.
  • Use -p to print /dev/... paths (recommended for operational work).

Key Options

OptionWhat it doesExampleWordPress / VPS use case
-pPrint full device pathslsblk -pCopy/paste safe device names
-fShow filesystem info (type, UUID)lsblk -fPrepare /etc/fstab entries
-o COLSChoose output columnslsblk -o NAME,SIZE,TYPE,MOUNTPOINTSCleaner troubleshooting view
-aInclude empty deviceslsblk -aSee devices even if not mounted
-rRaw output (no tree)lsblk -rGrep/parse-friendly output
-nNo headerlsblk -n -o NAME,SIZEScript output without headings
-JJSON outputlsblk -J -o NAME,SIZE,MOUNTPOINTSProgrammatic parsing
-PKEY="VALUE" outputlsblk -P -o NAME,SIZE,MOUNTPOINTSShell parsing with awk/xargs

Examples (Commands + Expected Output)

Output varies

Device names and sizes are examples. Your VPS may use vda (VirtIO) instead of sda.

List all disks and partitions

lsblk-basic.sh
lsblk

Expected output:

example-output-lsblk-basic.txt
NAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINTS
sda 8:0 0 50G 0 disk
└─sda1 8:1 0 50G 0 part /
sdb 8:16 0 200G 0 disk
└─sdb1 8:17 0 200G 0 part /mnt/backups

Use case: Get a quick map of storage and mounts.

lsblk-print-full-paths.sh
lsblk -p

Expected output:

example-output-lsblk-p.txt
NAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINTS
/dev/sda 8:0 0 50G 0 disk
└─/dev/sda1 8:1 0 50G 0 part /

Use case: Avoid ambiguity when you run commands like mount /dev/sdb1 /mnt/backups.

Show filesystem type and UUID (great for fstab)

lsblk-filesystem-info.sh
lsblk -p -f

Expected output:

example-output-lsblk-f.txt
NAME FSTYPE FSVER LABEL UUID FSAVAIL FSUSE% MOUNTPOINTS
/dev/sda1 ext4 1.0 11111111-2222-3333-4444-555555555555 40G 20% /
/dev/sdb1 ext4 1.0 BACKUP 66666666-7777-8888-9999-000000000000 150G 25% /mnt/backups

Use case: Copy the UUID into /etc/fstab to mount reliably across reboots.

Focus on a single disk

lsblk-single-device.sh
lsblk -p /dev/sdb

Expected output:

example-output-lsblk-single-disk.txt
NAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINTS
/dev/sdb 8:16 0 200G 0 disk
└─/dev/sdb1 8:17 0 200G 0 part /mnt/backups

Use case: Validate the disk you plan to format/mount.

Show only the columns you care about

lsblk-custom-columns.sh
lsblk -p -o NAME,SIZE,FSTYPE,UUID,MOUNTPOINTS

Expected output:

example-output-lsblk-custom-columns.txt
NAME SIZE FSTYPE UUID MOUNTPOINTS
/dev/sda1 50G ext4 11111111-2222-3333-4444-555555555555 /
/dev/sdb1 200G ext4 66666666-7777-8888-9999-000000000000 /mnt/backups

Use case: A clean view for runbooks and incident notes.

JSON output for automation

lsblk-json-output.sh
lsblk -J -o NAME,SIZE,TYPE,MOUNTPOINTS

Expected output:

example-output-lsblk-json.txt
{"blockdevices":[{"name":"sda","size":"50G","type":"disk","mountpoints":[null]},{"name":"sda1","size":"50G","type":"part","mountpoints":["/"]}]}

Use case: Parse block device information in scripts.

WordPress VPS Use Cases

SituationWhat you need to knowCommandWhy it helps
Disk is filling upWhich device backs /lsblk -p -fTells you which disk/partition to resize
Backups failingBackup mount device and sizelsblk -p -fConfirms backup volume is present and mounted
Moving uploads to another diskTarget device + filesystemlsblk -p -fPrevents mounting the wrong partition
Editing /etc/fstabUUID and filesystem typelsblk -p -fStable mounts across reboots

Troubleshooting

ProblemLikely causeFix
A disk is not listedNot attached or not recognizedVerify in your provider panel; rescan or reboot
MOUNTPOINTS is emptyPartition is not mountedUse mount or findmnt to confirm, then mount it
UUID missingNo filesystem on the partitionFormat the partition (carefully) before mounting
You see loop devicesSnap packages / loop mountsUsually normal; filter with custom columns

Best Practices

  • Use lsblk -p when you plan to copy/paste device names.
  • Use lsblk -p -f before touching /etc/fstab.
  • Confirm mounts with findmnt -T PATH before assuming where data lives.
Cheat Sheet
lsblk-cheat-sheet.sh
lsblk
lsblk -p
lsblk -p -f
lsblk -p -o NAME,SIZE,FSTYPE,UUID,MOUNTPOINTS
lsblk -J -o NAME,SIZE,TYPE,MOUNTPOINTS
lsblk -p /dev/sdb

What's Next