On this page

This chapter covers checking disk space, measuring what uses it, and seeing which disks and filesystems the system has.

df — disk free

df shows how much space is used and available on each mounted filesystem.

$ df -h
Filesystem      Size  Used Avail Use% Mounted on
/dev/nvme0n1p2  2.7T  727G  2.0T  27% /
Flag Meaning
-h human-readable sizes
-T also show the filesystem type
$ df -hT
Filesystem     Type      Size  Used Avail Use% Mounted on
/dev/nvme0n1p2 btrfs     2.7T  727G  2.0T  27% /

The Type column tells you the filesystem — see “Filesystems at a glance” below. A disk at 100% usually means trouble, so check df -h before it happens.

du — disk usage

du measures how much space a directory tree uses.

$ du -sh /var
502M	/var
Flag Meaning
-s summary: one total, don’t list every file
-h human-readable sizes
--max-depth=N how many levels deep to report

Find what is eating a disk:

$ du -h --max-depth=1 /var | sort -rh
502M	/var
340M	/var/lib
120M	/var/cache

The sort -rh puts the biggest directories first.

Graphical alternative: the Disk Usage Analyzer (baobab) shows the same data as a chart.

lsblk — list block devices

lsblk shows the disks and partitions as a tree, with sizes and mount points. It does not need root.

$ lsblk
NAME        MAJ:MIN RM   SIZE RO TYPE MOUNTPOINTS
nvme0n1     259:0    0   1.8T  0 disk
├─nvme0n1p1 259:1    0     2G  0 part
└─nvme0n1p2 259:2    0   1.8T  0 part /

nvme0n1 is a whole disk; the p1/p2 entries below it are its partitions. The MOUNTPOINTS column shows where each one is attached.

Filesystems at a glance

A filesystem is how a disk stores data. The most common ones you will meet:

Filesystem Used by Notes
ext4 Ubuntu/Debian/Mint default mature, reliable, good all-rounder
btrfs Fedora default snapshots, compression, checksums
xfs RHEL default fast, scales well on big disks
swap all distros not a filesystem for files — it is virtual memory on disk

See which filesystem a disk uses:

$ df -T /
Filesystem     Type  ...
/dev/nvme0n1p2 btrfs ...

$ lsblk -f
NAME      FSTYPE LABEL UUID ...
nvme0n1p2 btrfs   ...

The blkid command shows the same filesystem/UUID information, but it needs root privileges.

Why it matters: btrfs and xfs have features (snapshots, resizing) that ext4 lacks, and some operations are filesystem-specific. For everyday file work the choice rarely matters — but if you plan a server, check which filesystem your distro defaults to.

Do not run mkfs, mount, fdisk or parted on your main disk. Those commands can destroy data. If you ever need them, test in a disposable virtual machine first, and always back up before partitioning.