Disk usage and mounts on Linux (df, du, lsblk, fstab)
df shows free space per filesystem, du shows what uses it, lsblk and blkid identify disks, and /etc/fstab tells Linux which filesystems to mount at boot, where a bad line can stop the server booting.
- Updated Nov 27, 2026
- Markdown
Find what uses disk space and inodes, identify a disk by UUID, and add a mount to fstab with a backup and a test that avoids a failed boot.
- An Ubuntu or Debian server you can reach over SSH
- A user with sudo access
- Console or rescue access from your hosting provider, in case a mount breaks boot
Two disk problems hit servers most: running out of space, and breaking boot with a bad mount. The first is fixed by measuring correctly. The second is fixed by a short, careful routine before you ever touch /etc/fstab. Use this together with check disk, memory and CPU usage and fix a full disk on a Linux server.
How it works#
Linux presents one tree, and each disk or partition becomes part of it by being mounted at a directory (a mount point). A block device such as /dev/sda1 holds a filesystem such as ext4. A mount connects that filesystem to a path such as /srv/data.
At boot, systemd reads /etc/fstab and mounts what it lists. A mount that fails at boot can stop the whole boot into emergency mode, which on a remote server means you need the provider’s console to recover. That is why fstab changes need care.
df asks the filesystem how much is used. du walks the files and adds them up. The two answers can differ, and each tells you something different.
Step 1: See free space and inodes#
df -h
df -h /var
df -i
df -hTdf -h prints human-readable size, used, available, use percentage and mount point. Ignore tmpfs and udev rows when you look for disk problems. -T adds the filesystem type. df -i shows inodes. Every file takes one inode, and when IUse% hits 100% you cannot create files even though df -h shows free bytes. Linux also reserves some space on ext4 for root, so usable space for normal users can be slightly less than the free total.
Step 2: Find what is using the space#
sudo du -h --max-depth=1 /var | sort -h
sudo du -xh -d 1 / | sort -h | tail -n 10
sudo du -sh /var/log/* | sort -h | taildu -sh prints one total per argument. --max-depth=1 (or -d 1) shows one level of subfolders. -x stays on one filesystem so it does not walk into other mounts. Sort with sort -h to order human sizes. Start at /, look at the biggest folder, then repeat inside it. Common culprits are /var/log, /var/lib/docker and /var/cache. Interactive ncdu (sudo apt install ncdu) does the same with a browsable view.
If df says the disk is full but du adds up to much less, a deleted file is probably still open:
sudo lsof +L1Restart the process that holds it and the space returns.
Step 3: Identify disks and mounts#
lsblk
lsblk -f
sudo blkid
findmnt
findmnt /srv/data
mount | grep ext4lsblk draws the tree of disks and partitions with size, type and mount point. lsblk -f adds filesystem type, label and UUID. blkid prints the UUID of each device and needs sudo. findmnt shows the mount tree, and findmnt PATH tells you which device and options back a path, which is the cleanest way to check where a folder really lives. mount with no arguments lists everything, but is noisy.
A new, empty disk shows in lsblk with no filesystem. Creating one with mkfs erases the disk, so confirm the device name twice first.
Step 4: Mount a disk by hand#
sudo mkdir -p /srv/data
sudo mount /dev/sdb1 /srv/data
findmnt /srv/data
sudo umount /srv/dataMount by hand first to confirm the device and filesystem work. This mount lasts until reboot. umount fails with target is busy while a process uses it, so check with lsof +f -- /srv/data. If the mount point already contained files, they are hidden while the disk is mounted.
Step 5: Make it permanent in fstab#
Warning: a wrong line in
/etc/fstabcan stop the server booting, and on a remote host that means console recovery. Back up the file, edit it carefully, and test withsudo mount -aandfindmnt --verifybefore you ever reboot. Keep your SSH session open until the test passes.
Back up and find the UUID:
sudo cp -a /etc/fstab /etc/fstab.bak
sudo blkid /dev/sdb1Output looks like /dev/sdb1: UUID="3f6a1b22-8e1c-4c8f-9a52-0d7e1c0b5a11" TYPE="ext4". Edit with sudoedit /etc/fstab, as shown in read and edit files on Linux, and add:
UUID=3f6a1b22-8e1c-4c8f-9a52-0d7e1c0b5a11 /srv/data ext4 defaults,nofail 0 2The six fields are:
- Device:
UUID=..., which stays stable, unlike/dev/sdb1. - Mount point, which must exist.
- Filesystem type, such as
ext4orxfs. - Options:
defaultsis the usual set,nofaillets boot continue if the device is missing,noatimereduces writes,romounts read-only. - Dump flag, normally
0. - fsck order:
1for the root filesystem,2for others,0to skip checks.
Now test, with the session still open:
sudo mount -a
findmnt --verify
findmnt /srv/datamount -a mounts everything listed that is not already mounted, and prints any error right away. findmnt --verify checks syntax, and missing devices or mount points. Only reboot after both pass. If anything fails, restore the backup: sudo cp -a /etc/fstab.bak /etc/fstab.
Check it worked#
df -h /srv/data
findmnt --verify
findmnt /srv/datadf should show the new disk size at the mount point, and findmnt should show the UUID’s device with your options. After a planned reboot, run findmnt /srv/data again to confirm it came back. Persistent application data on such a disk, such as Docker volumes, is covered in Docker volumes and persistent data.
Edge cases and gotchas#
- A missing mount point is not fatal with nofail, but the folder looks empty. An app may then write into the underlying folder on the root disk and fill it. Check
findmntbefore starting apps. - Network mounts need
_netdev. NFS and similar mounts must wait for the network, or boot may stall. - Cloned disks share UUIDs. Two filesystems with the same UUID confuse mounting. Change one with
tune2fs -U randomon ext4, while unmounted. - Resize before you fill.
resize2fsgrows an ext4 filesystem after you enlarge its partition. Take a snapshot first. - Swap lives in fstab too. A swap file line follows the same rules, see add swap space on Ubuntu.
- Do not move system folders casually.
/varor/homeon a new disk needs a careful copy withrsync -aHAX, not just a mount.
Troubleshooting#
| Symptom | Likely cause | Fix |
|---|---|---|
No space left on device with free bytes in df -h | Inodes exhausted | df -i, then delete the many small files |
df -h shows 100% but du is small | Deleted file still open | sudo lsof +L1, restart that service |
mount: /srv/data: special device UUID=... does not exist. | Wrong UUID or typo | Compare with sudo blkid and fix the line |
mount: /srv/data: mount point does not exist. | Folder not created | sudo mkdir -p /srv/data |
mount: wrong fs type, bad option, bad superblock on /dev/sdb1 | Wrong type or no filesystem | Check lsblk -f; do not run mkfs if data exists |
umount: /srv/data: target is busy. | A process uses it | lsof +f -- /srv/data, stop the process |
Boot ends in Welcome to emergency mode! | Bad fstab line without nofail | Use the console, restore /etc/fstab.bak, reboot |
findmnt: /etc/fstab: parse error at line 5 | Wrong number of fields | Fix line 5 so it has six fields |
Quick reference#
df -h; df -i # space and inodes
sudo du -xh -d 1 /var | sort -h # biggest folders
lsblk -f # disks, types, UUIDs
sudo blkid # UUIDs
findmnt /srv/data # what backs a path
sudo cp -a /etc/fstab /etc/fstab.bak # backup first
# UUID=... /srv/data ext4 defaults,nofail 0 2
sudo mount -a && findmnt --verify # test before rebootRelated lessons#
- Check disk, memory and CPU usage: the quick health view.
- Fix a full disk on a Linux server: the recovery steps when space runs out.
- Free disk space with Docker prune safely: the biggest space user on many hosts.
- Add swap space on Ubuntu: another fstab entry.
For storage choices in a container setup, see self-host a static site with Docker.
Next#
With the base system covered, put it to use by serving a site in nginx from scratch.
Check what you learned
Frequently asked questions
How do I check disk space on Linux?
Run df -h to see size, used and available space for each mounted filesystem in human-readable units. Then run sudo du -h --max-depth=1 /var to see which folders take the space.
Why is my disk full when du shows less than df?
A deleted file can still be held open by a running process, so df counts it but du cannot see it. Run sudo lsof +L1 to find it, then restart that process.
What are inodes and what does df -i show?
An inode stores one file's metadata. A filesystem has a fixed number of them, so millions of tiny files can exhaust inodes while df -h still shows free space. df -i shows inode use.
How do I mount a disk permanently on Linux?
Add a line to /etc/fstab using the disk's UUID from blkid, test it with sudo mount -a before rebooting, and keep a backup of the original file.
Sources
Keep going: guides and tutorials
- Install a Self-Hosted PaaS on Your Own Server in Five Minutes One installer download, one setup token, one sample app. The full Levelrail install on a fresh Linux server, with the checks and the fixes.
- Manage Secrets Self-Hosted: Env Vars and Master Key Rotation Set env vars and encrypted secrets on a self-hosted server, apply changes safely, and rotate the master key with no downtime without locking yourself out.