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).
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
/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:
which lsblk
lsblk --version
Core Syntax
lsblk [OPTIONS] [DEVICE...]
- If you omit
DEVICE,lsblklists all block devices. - Use
-pto print/dev/...paths (recommended for operational work).
Key Options
| Option | What it does | Example | WordPress / VPS use case |
|---|---|---|---|
-p | Print full device paths | lsblk -p | Copy/paste safe device names |
-f | Show filesystem info (type, UUID) | lsblk -f | Prepare /etc/fstab entries |
-o COLS | Choose output columns | lsblk -o NAME,SIZE,TYPE,MOUNTPOINTS | Cleaner troubleshooting view |
-a | Include empty devices | lsblk -a | See devices even if not mounted |
-r | Raw output (no tree) | lsblk -r | Grep/parse-friendly output |
-n | No header | lsblk -n -o NAME,SIZE | Script output without headings |
-J | JSON output | lsblk -J -o NAME,SIZE,MOUNTPOINTS | Programmatic parsing |
-P | KEY="VALUE" output | lsblk -P -o NAME,SIZE,MOUNTPOINTS | Shell parsing with awk/xargs |
Examples (Commands + Expected Output)
Device names and sizes are examples. Your VPS may use vda (VirtIO) instead of sda.
List all disks and partitions
lsblk
Expected output:
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.
Print full device paths (recommended)
lsblk -p
Expected output:
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 -p -f
Expected output:
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 -p /dev/sdb
Expected output:
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 -p -o NAME,SIZE,FSTYPE,UUID,MOUNTPOINTS
Expected output:
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 -J -o NAME,SIZE,TYPE,MOUNTPOINTS
Expected output:
{"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
| Situation | What you need to know | Command | Why it helps |
|---|---|---|---|
| Disk is filling up | Which device backs / | lsblk -p -f | Tells you which disk/partition to resize |
| Backups failing | Backup mount device and size | lsblk -p -f | Confirms backup volume is present and mounted |
| Moving uploads to another disk | Target device + filesystem | lsblk -p -f | Prevents mounting the wrong partition |
Editing /etc/fstab | UUID and filesystem type | lsblk -p -f | Stable mounts across reboots |
Troubleshooting
| Problem | Likely cause | Fix |
|---|---|---|
| A disk is not listed | Not attached or not recognized | Verify in your provider panel; rescan or reboot |
MOUNTPOINTS is empty | Partition is not mounted | Use mount or findmnt to confirm, then mount it |
| UUID missing | No filesystem on the partition | Format the partition (carefully) before mounting |
You see loop devices | Snap packages / loop mounts | Usually normal; filter with custom columns |
Best Practices
- Use
lsblk -pwhen you plan to copy/paste device names. - Use
lsblk -p -fbefore touching/etc/fstab. - Confirm mounts with
findmnt -T PATHbefore assuming where data lives.
Cheat Sheet
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