Filesystems, Disks and Storage
Learn the Linux directory layout, how disks are partitioned and mounted, and how to find out what is filling a disk at 3 a.m.
Beginner · about 6 hours · difficulty 2/5
Learn first: Linux Command Line and Packages
A full disk is one of the most common production incidents. Knowing how Linux organises storage lets you diagnose it quickly and design systems that do not fall over.
Layout and concepts
- The Filesystem Hierarchy Standard:
/etcconfig,/var/loglogs,/var/libapp data,/tmp,/home,/opt,/usr/bin. - Inodes: each file has metadata stored in an inode. You can run out of inodes before running out of space (millions of tiny files).
- Hard links vs symbolic links, and why deleted-but-open files still consume space until the process closes them.
Disks and mounts
- Inspect with
lsblk,df -h,df -i,du -sh *,ncdu. - Partition and format with
fdisk/partedandmkfs.ext4ormkfs.xfs, then mount and persist in/etc/fstab(use UUIDs). - LVM lets you resize volumes; cloud block volumes (EBS, Azure Disk) can often be grown online.
- Swap, tmpfs, and network filesystems such as NFS.
Pitfalls
Logs without rotation (configure logrotate), a bad fstab entry that stops the machine booting (use nofail for optional disks), and deleting a huge log file that a process still holds open.
Good enough to move on: you can attach a new disk to a VM, format and mount it persistently, and track down the directory eating all the space.
Key concepts
- Filesystem Hierarchy Standard
- Inodes and links
- df, du, lsblk, ncdu
- Partitioning, mkfs and fstab
- LVM
- logrotate
- NFS and network storage
Mini project
Attach a second virtual disk to a VM, create an ext4 filesystem, mount it at /data via a UUID fstab entry, reboot to prove it persists, and set up logrotate for an app log written there.
Check yourself
df says the disk is full but du cannot find the files. What is the likely cause and how do you confirm it?
Free resources
- Linux Journey: The Filesystem (linuxjourney.com)
- hier(7) man page (man7.org)