lsblk — inspect block device structure
💬 "lsblk command"
lsblk shows the disk and partition structure attached to the server in a tree. It is an essential check before adding or mounting disks.
While df shows the file system perspective, lsblk shows the device perspective.
- Concept: Displays block devices (disks, partitions, LVM volumes) and mount points in a hierarchy.
- NAME: Device name. Formats such as
vda,vda1,nvme0n1p1. - SIZE: Device capacity.
- MOUNTPOINT: Mounted path. If empty, the device is not mounted.
Commonly used options
| Option | Description |
|---|---|
| -f | Displays file system type, label, and UUID |
| -o <column list> | Output only the specified columns |
| -p | Displays device names with the full path (/dev/...) |
| -d | Displays only disks, not partitions |
Three essential command combinations
lsblk -f— Check file system type and mount statuslsblk -o NAME,SIZE,TYPE,MOUNTPOINT— View only the columns you needlsblk -f /dev/vdb— Check partitions/filesystems on a specific disk
💬 "Give me an example of isolating a problem server with this command"
This is a step-by-step summary of situations you often encounter on live servers.
Step 1 · Check the overall device structure
Check disks, partitions, and mount status.
lsblk -f
Step 2 · Choose a new disk
Find a device with an empty mount point.
lsblk -o NAME,SIZE,TYPE,MOUNTPOINT
Step 3 · Verify after mounting
After creating a filesystem and mounting it, check again.
lsblk -f /dev/vdb
In practice, this is how it's used
1. Adding a disk
Situation — You added a volume in the cloud, but it doesn't appear yet.
lsblk -o NAME,SIZE,TYPE,MOUNTPOINT
Result — If a new device (vdb) appears without a MOUNTPOINT, it needs to be mounted.
Point — Proceed in this order: check device → create filesystem → register in /etc/fstab.
2. Checking for missing mounts
Situation — After a reboot, /data appears empty.
lsblk -f && grep /data /etc/fstab
Result — If the device exists but is not mounted, check the fstab configuration or mount failure.
Point — For partitions not shown by df, first check with lsblk whether the device itself is recognized.
Things to watch out for
- Creating a filesystem on an unmounted device can destroy existing data. Always double-check the device name.
- In LVM environments, physical volumes and logical volumes are shown together, which can make the structure complex. Use -o to view only the items you need.
- Device names (vda/vdb) can change depending on boot order, so use UUIDs in fstab.
Actual command output
This is the result of checking disks, partitions, and mount points (including vdc, which is not mounted).
!lsblk command output: block device structure
Production server
Source (HTML): https://games.aidebatehub.com/programs/linux/filesystem/lsblk.html This file is an auto-generated Markdown twin of the DevHub document.
AI Knowledge Hub
Visitor Comments