Disk Management Basics - Inspecting Storage with fdisk and lsblk
What You'll Learn
- How to read storage layout with
lsblkandfdisk -l - The relationship between block devices, partitions, and mount points
- When to use
dfvsdufor disk space investigation
Quick Summary
- Check disk layout →
lsblk(tree view, no root required) - Partition details →
sudo fdisk -l(sector boundaries and types) - Free space by filesystem →
df -h - Space used by directory →
du -sh *
What is lsblk? Visualizing Block Devices as a Tree
lsblk (list block devices) displays disks, partitions, and mount points in a tree structure. It runs without root privileges, making it the first command to reach for when investigating storage layout.
$ lsblk NAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINTS sda 8:0 0 20G 0 disk ├─sda1 8:1 0 1G 0 part /boot ├─sda2 8:2 0 2G 0 part [SWAP] └─sda3 8:3 0 17G 0 part / sdb 8:16 0 50G 0 disk └─sdb1 8:17 0 50G 0 part /data
Column reference:
| Column | Meaning |
|---|---|
| NAME | Device name (sda = first SATA/SCSI/NVMe disk) |
| SIZE | Device size |
| TYPE | disk (physical disk) / part (partition) / lvm etc. |
| MOUNTPOINTS | Mount target (blank = not mounted) |
Show filesystem details with -f
$ lsblk -f NAME FSTYPE FSVER LABEL UUID FSAVAIL FSUSE% MOUNTPOINTS sda ├─sda1 ext4 1.0 a1b2c3d4-... 800M 20% /boot ├─sda2 swap 1 [SWAP] └─sda3 ext4 1.0 e5f6a7b8-... 14.2G 16% /
The -f flag adds filesystem type (FSTYPE) and UUID. UUIDs are useful when checking /etc/fstab mount configuration.
What is fdisk -l? Inspecting Partition Tables
fdisk -l (list) shows the full partition table with sector counts and partition types (Linux, Linux swap, EFI System, etc.). Root privileges are required.
$ sudo fdisk -l /dev/sda Disk /dev/sda: 20 GiB, 21474836480 bytes, 41943040 sectors Disk model: Virtual disk Units: sectors of 1 * 512 = 512 bytes Sector size (logical/physical): 512 bytes / 512 bytes I/O size (minimum/optimal): 512 bytes / 512 bytes Disklabel type: gpt Disk identifier: XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX Device Start End Sectors Size Type /dev/sda1 2048 2099199 2097152 1G Linux filesystem /dev/sda2 2099200 6293503 4194304 2G Linux swap /dev/sda3 6293504 41943006 35649503 17G Linux filesystem
Key fields to read:
- Disklabel type:
gpt(GUID Partition Table) ordos(MBR). Modern systems use GPT. - Type: Partition role —
Linux filesystem,Linux swap,EFI System, etc. - Start / End / Sectors: Partition boundaries, useful during disk diagnostics.
To check a specific disk: sudo fdisk -l /dev/sda. To list all disks at once, run sudo fdisk -l with no arguments.
fdisk can also edit partition tables — operations beyond -l (list) risk data loss if used incorrectly. This article covers read-only inspection only.
How Do df and du Fit In?
lsblk and fdisk show the hardware and partition layout. df and du report filesystem usage — what is actually used and free at the OS level.
| Command | Shows | Typical use |
|---|---|---|
lsblk |
Block device tree structure | Understand disk layout |
fdisk -l |
Partition table details | Check boundaries and types |
df -h |
Used/free space per filesystem | Find which FS is running low |
du -sh |
Size of directories or files | Find what is consuming space |
# Space free per filesystem $ df -h Filesystem Size Used Avail Use% Mounted on /dev/sda3 17G 2.7G 13G 17% / /dev/sda1 974M 189M 718M 21% /boot /dev/sdb1 50G 1.2G 47G 3% /data # Breakdown by subdirectory $ du -sh /var/* 48M /var/cache 1.2G /var/log 8.0K /var/mail
If df shows free space but writes fail, check inode exhaustion with df -i. Filesystems have separate limits on blocks and inodes.
Device Naming Conventions
Device names vary by hardware type — a common source of confusion for new users.
| Prefix | Hardware | Examples |
|---|---|---|
/dev/sd* |
SATA / SCSI / USB / most virtual disks | sda, sdb, sdc |
/dev/nvme* |
NVMe SSD | nvme0n1, nvme0n1p1 |
/dev/vd* |
KVM/QEMU virtual disk | vda, vdb |
/dev/xvd* |
Xen virtual disk | xvda |
NVMe partitions use a p suffix followed by the partition number (nvme0n1p1 = partition 1 on the first NVMe drive).
$ lsblk NAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINTS nvme0n1 259:0 0 256G 0 disk ├─nvme0n1p1 259:1 0 512M 0 part /boot/efi ├─nvme0n1p2 259:2 0 2G 0 part /boot └─nvme0n1p3 259:3 0 253G 0 part /
Summary
lsblk: First command to run for any disk investigation. No root required.sudo fdisk -l: Detailed partition table including type and sector layout. Root required.df -h: How much space is free on each mounted filesystem.du -sh: Which directories are consuming the most space.
The standard investigation flow: lsblk to map the device layout → df -h to find which filesystem is full → du -sh to pinpoint the large directories within it.