Study guide
7.5 Monitoring Disk Usage: df, du & tune2fs (104.2)
LPIC-1 Linux Administrator — Exam 101 101-500
Track your progress as you read
Finished sections get a check mark.
1 Exam Overview & Study Strategy
1.1 LPIC-1 101-500 Exam Structure & Blueprint 1.2 Command Line & Shell Fundamentals for Exam Success 1.3 Fill-in-the-Blank Strategies & Common Traps
2 Topic 101: System Architecture
2.1 Hardware Discovery, Sysfs, Procfs & Kernel Modules (101.1) 2.2 Udev, Dbus & Device Management (101.1) 2.3 BIOS vs. UEFI & System Boot Process (101.2) 2.4 Kernel Initialization, Initramfs & System Logs (101.2) 2.5 Systemd Boot Targets & Unit Management (101.3) 2.6 SysVinit Runlevels, Telinit & System Shutdown (101.3)
3 Topic 102: Linux Installation & Boot Management
3.1 Hard Disk Layout, Partition Schemes & Swap Design (102.1) 3.2 LVM & Standard Mount Point Allocation (102.1) 3.3 GRUB 2 Configuration & Troubleshooting (102.2) 3.4 Legacy GRUB & Alternative Boot Loaders (102.2) 3.5 Managing Shared Libraries & ldconfig (102.3) 3.6 Linux as a Virtualization Guest & Cloud Instances (102.6)
4 Topic 102: Package Management Systems
4.1 Debian Low-Level Package Management with dpkg (102.4) 4.2 High-Level Debian Package Management: apt, apt-get & apt-cache (102.4) 4.3 RPM Package Management with rpm (102.5) 4.4 YUM, DNF & Zypper Package Management (102.5) 4.5 Package Repositories & Integrity Verification (102.4/102.5) 4.6 Universal Linux Packages: Snap, Flatpak & AppImage (102.4/102.5)
5 Topic 103: Command Line & Text Processing
5.1 Shell Environment, Environment Variables & Aliases (103.1) 5.2 Command History, Quoting & Expansion (103.1) 5.3 Basic Text Filters: cat, head, tail, cut, paste, nl, od (103.2) 5.4 Advanced Text Filters: sort, uniq, wc, tr, split, less & Checksums (103.2) 5.5 Stream Editing with sed (103.2) 5.6 Basic File Management: cp, mv, rm, touch, mkdir, rmdir (103.3) 5.7 Archiving and Compression: tar, gzip, bzip2, xz, cpio & dd (103.3)
6 Topic 103: Streams, Processes, Regex & Vi
6.1 Standard Streams, Redirection & File Descriptors (103.4) 6.2 Pipelines, tee & xargs (103.4) 6.3 Process Monitoring: ps, top, free, watch, pgrep, pstree & uptime (103.5) 6.4 Signals, kill, Job Control, nohup, screen & tmux (103.5) 6.5 Process Priorities: nice & renice (103.6) 6.6 Regular Expressions & grep, egrep, fgrep (103.7) 6.7 vi / vim Modes, plus nano, Emacs & EDITOR Awareness (103.8)
7 Topic 104: Devices, Partitions & Filesystems
7.1 Block Devices, fdisk & gdisk (104.1) 7.2 GNU Parted & Partition Table Management (104.1) 7.3 Creating Filesystems: mkfs, ext4, XFS, VFAT/exFAT & Btrfs (104.1) 7.4 Filesystem Integrity: fsck, e2fsck, xfs_repair, xfs_fsr & xfs_db (104.2) 7.5 Monitoring Disk Usage: df, du & tune2fs (104.2) 7.6 Managing Swap Space: mkswap, swapon & swapoff (104.1/104.2)
8 Topic 104: Mounts, Permissions, Links & FHS
8.1 Mounting and Unmounting Filesystems: mount & umount (104.3) 8.2 Persistent Mounts: /etc/fstab, UUIDs & systemd mount units (104.3) 8.3 Standard File Permissions: chmod, chown, chgrp & umask (104.5) 8.4 Special Permissions: SUID, SGID & Sticky Bit (104.5) 8.5 Hard Links vs. Symbolic Links: ln & Inodes (104.6) 8.6 Filesystem Hierarchy Standard (FHS) & File Location (104.7)
7.5 Monitoring Disk Usage: df, du & tune2fs (104.2)
Key Takeaways Explain This Topic AI
The df (disk free) utility inspects filesystem superblock metadata to report storage capacity, mount points, and inode exhaustion ( df -i ).
The du (disk usage) utility recursively traverses directory trees to calculate space consumed by individual files and directories, supporting summary mode ( -s ), human units ( -h ), and max depth ( -d ).
Discrepancies where df reports a disk as 100% full while du shows low usage occur when deleted files remain held open by running processes (diagnosed with lsof +L1 or lsof | grep deleted ).
tune2fs allows non-destructive inspection ( -l ) and tuning of ext2/ext3/ext4 parameters including volume labels ( -L ), UUIDs ( -U ), reserved root blocks ( -m ), max mount counts ( -c ), and check intervals ( -i ).
Filesystem labels are managed across filesystem types using e2label / tune2fs -L (ext2/3/4), xfs_admin -L (XFS), and fatlabel (FAT32).
Last updated: August 2026
7.5 Monitoring Disk Usage: df, du & tune2fs
Quick Summary: Linux administrators monitor storage capacity and health using df (to evaluate overall filesystem capacity and inode consumption) and du (to track directory tree disk usage). For ext2/ext3/ext4 filesystems, the tune2fs utility enables administrators to inspect superblock parameters ( -l ) and modify settings—including volume labels ( -L ), UUIDs ( -U ), reserved root block percentages ( -m ), and error behaviors ( -e )—on live systems without reformatting.
1. Filesystem Capacity Monitoring with df
The df (disk free) utility queries the superblock and kernel Virtual File System (VFS) statistics of all currently mounted filesystems to report available, used, and total storage capacity. Command Syntax:
- df [options] [file|device...]
- Essential df Command Flags Reference
Flag Long Option Operational Description & Exam Context
-h --human-readable Formats sizes in human-readable powers of 1024 ( KiB , MiB , GiB , TiB ).
-H --si Formats sizes in powers of 1000 ( KB , MB , GB , TB ), matching hard drive vendor specifications.
-T --print-type Prints the filesystem type column ( ext4 , xfs , vfat , tmpfs ).
-t <type> --type=<type> Includes only filesystems matching <type> (e.g., df -t ext4 ).
-x <type> --exclude-type Excludes filesystems of type <type> (e.g., df -x tmpfs -x devtmpfs ).
-i --inodes Reports inode usage statistics (Inodes, IUsed, IFree, IUse%) instead of block storage space.
-a --all Includes dummy, virtual, and 0-block pseudo filesystems ( proc , sysfs , cgroup ).
-k (none) Displays sizes in 1-KiB blocks (standard POSIX default behavior).
-m (none) Displays sizes in 1-MiB blocks.
-l --local Restricts reporting strictly to local filesystems, ignoring network mounts (NFS, CIFS). # Display human-readable filesystem usage with filesystem types
- $ df -hT
- Filesystem Type Size Used Avail Use% Mounted on
- /dev/sda2 ext4 40G 18G 20G 48% /
- /dev/sda1 vfat 512M 32M 480M 7% /boot/efi
- /dev/sdb1 xfs 200G 45G 156G 23% /srv/data
- tmpfs tmpfs 7.8G 0 7.8G 0% /dev/shm
- 2. Inode Exhaustion & The df -i Metric
Every file, directory, and symbolic link created on an ext2/ext3/ext4 filesystem requires an inode to store its metadata. When an ext filesystem is created with mkfs.ext4 , a fixed number of inodes is generated in the inode table.
The "No Space Left on Device" Inode Trap
If a service (such as an unmonitored mail server or session cache) creates millions of 0-byte or tiny files, it can consume 100% of available inodes while using almost none of the actual disk byte capacity. When this happens, any attempt to create a new file fails with No space left on device even though df -h shows gigabytes of free disk space! # Diagnose inode exhaustion with df -i
- $ df -i
- Filesystem Inodes IUsed IFree IUse% Mounted on
- /dev/sda2 2621440 2621440 0 100% /var/spool/mail
- /dev/sdb1 13107200 421090 12686110 4% /srv/data
💡 LPIC-1 Exam Fill-in-the-Blank Alert: What df command-line option displays filesystem inode usage statistics rather than block capacity? Answer: -i (or --inodes )
Loading diagram... df vs du Measurement Mechanics and The Deleted Open File Phenomenon
3. Directory & File Space Analysis with du
While df operates at the filesystem level, du (disk usage) measures the actual disk space consumed by directories and files by traversing the directory tree. Command Syntax:
- du [options] [directory|file...]
- Essential du Flags Reference
Flag Long Option Detailed Purpose & Exam Context
-h --human-readable Displays sizes in human units ( K , M , G ).
-s --summarize Displays only a total size for each specified argument , suppressing subdirectory breakdown.
-a --all Displays counts for all individual files, not just directories.
-c --total Produces a grand total line at the bottom of the output.
-d <N> --max-depth=<N> Limits directory recursion to <N> levels deep (e.g., -d 1 shows immediate subdirectories only).
-x --one-file-system Skips directories residing on different filesystems / mount points during traversal.
--exclude=<pat> Exclude Pattern Skips files matching shell pattern <pat> (e.g. --exclude="*.log" ).
-b --bytes Displays sizes in exact raw bytes.
- Practical du Commands for System Administration # 1. Summarize total size of /var/log in human units
- $ du -sh /var/log
- 4.2G /var/log
- # 2. Inspect space used by immediate subdirectories under /var (depth 1)
- $ du -h --max-depth=1 /var
- 1.2G /var/cache
- 4.2G /var/log
- 850M /var/lib
- 6.3G /var
- # 3. Identify the 5 largest directory consumers on the root filesystem (staying on one filesystem)
- # du -xh / | sort -rh | head -n 5
- The df vs. du Discrepancy (Deleted Open Files Trap)
A classic Linux administration dilemma occurs when df reports a partition is 100% full, but du -sh / calculates only 30% usage.
Root Cause: When a large file (e.g., a 50 GB log file) is deleted with rm while a running process (e.g., rsyslogd or Java) still holds an open file descriptor to it, the directory link is removed, but the inode and data blocks remain allocated on disk until the process terminates or closes the descriptor. # Locate deleted files that are still held open in memory by running processes
# lsof +L1
# Or filter lsof for deleted entries:
- # lsof | grep deleted
- java 4810 root 3u REG 8,2 52428800000 189204 /var/log/app.log (deleted)
- # Resolution: Restart the holding service to release the disk blocks
- # systemctl restart app-service
- 4. Superblock Inspection & Parameter Tuning with tune2fs
The tune2fs utility allows administrators to inspect and adjust tunable filesystem parameters on ext2, ext3, and ext4 filesystems without reformatting or destroying data. Command Syntax:
- tune2fs [options] <device>
- Essential tune2fs Command Options Reference
Option Flag Detailed Purpose & Exam Context
-l <device> List superblock contents. Dumps all parameters stored in the ext superblock (block count, inode count, UUID, volume name, mount count, check interval, reserved blocks, filesystem state, features).
-L <label> Set volume label. Sets or updates the filesystem volume label (up to 16 characters).
-U <UUID> Set UUID. Sets a specific UUID or generates a new one with tune2fs -U random <device> .
-m <percent> Adjust reserved root space percentage. Adjusts percentage of reserved superuser blocks (e.g. tune2fs -m 1 /dev/sda1 ).
-r <blocks> Adjusts the reserved space by an exact numeric block count.
-c <max> Max mount count before fsck. Sets the maximum number of times the filesystem can be mounted before triggering an automatic e2fsck at boot ( -c 0 or -c -1 disables this check).
-i <interval> Time interval between checks. Sets maximum time between filesystem checks (e.g., -i 180d for 180 days, -i 0 to disable).
-C <count> Sets the current filesystem mount counter.
-e <action> Set kernel error behavior. Controls kernel reaction when filesystem errors are detected: continue (normal execution), remount-ro (remount read-only to protect data, default), or panic (force kernel panic and halt).
-j Add ext3 journal. Adds an ext3 journal to an existing ext2 filesystem, non-destructively upgrading it to ext3.
-o [^]<opts> Sets or clears ( ^ ) default mount options embedded in the superblock (e.g., acl , user_xattr ).
- Practical Superblock Inspection with tune2fs -l # Inspect superblock details of an ext4 filesystem
- # tune2fs -l /dev/sda2
- tune2fs 1.46.5 (30-Dec-2021)
- Filesystem volume name: ROOT_VOL
- Filesystem UUID: a28b12f4-7e11-42b8-a6d1-817290123456
- Filesystem magic number: 0xEF53
- Filesystem state: clean
- Errors behavior: Remount read-only
- Filesystem OS type: Linux
- Inode count: 2621440
- Block count: 10485760
- Reserved block count: 104857 (1.00%)
- Free blocks: 6120491
- Free inodes: 2410882
- Block size: 4096
- Mount count: 14
- Maximum mount count: 30
- Last checked: Mon Aug 25 14:20:00 2026
- Check interval: 15552000 (180 days)
- Filesystem features: has_journal ext_attr resize_inode dir_index filetype extent 64bit
- 5. Filesystem Volume Label Management Utilities
Volume labels allow disks to be identified and mounted persistently via LABEL=name in /etc/fstab rather than relying on shifting /dev/sd* device node names.
Label Management Tools Across Filesystem Types
Filesystem Type View Current Label Change / Set New Label Maximum Label Length
ext2 / ext3 / ext4 e2label /dev/sda1 e2label /dev/sda1 NEW_LABEL ; tune2fs -L NEW_LABEL /dev/sda1 16 Characters
- XFS xfs_admin -l /dev/sdb1 xfs_admin -L NEW_LABEL /dev/sdb1 (Must be unmounted) 12 Characters
- VFAT / FAT32 fatlabel /dev/sdc1 fatlabel /dev/sdc1 NEW_LABEL ; dosfslabel /dev/sdc1 NEW_LABEL 11 Characters
Btrfs btrfs filesystem label /mnt btrfs filesystem label /mnt NEW_LABEL 255 Characters # Set and view volume labels using e2label
- # e2label /dev/sda2 SYS_ROOT
- # e2label /dev/sda2
- SYS_ROOT