Skip to main content
A full disk causes cascading failures — applications crash, databases refuse to write, system logs stop recording, and in severe cases the operating system itself becomes unstable. The good news is that the majority of disk-full situations are resolved quickly once you know where to look: package manager caches, rotated log files, and temporary directories frequently account for gigabytes of reclaimable space that accumulated silently over time.

Identifying the Scope of the Problem

1

Check Overall Disk Usage with df

df (disk free) shows the used and available space on every mounted filesystem at a glance. Always start here to confirm which filesystem is full and how severe the situation is.
A filesystem at 95% or above should be treated as critically full. Many applications and databases begin failing between 95–100% capacity. Linux reserves 5% of ext4 space for root by default, so a partition may report 100% used while still having ~5% reserved — but this reserve is not available to non-root processes.
Focus your cleanup effort on the filesystem mounted at / (root) if that is the one approaching capacity.
2

Drill Down with du to Find Disk Hogs

Once you know which filesystem is full, use du (disk usage) to locate the directories consuming the most space.
Start at the root (/) with --max-depth=1, identify the largest directories, then recurse into each one with increasing depth. This top-down approach is much faster than scanning every directory at once.
3

Find Large Individual Files

After identifying large directories with du, use find to locate individual files above a size threshold anywhere on the system.
Use the -xdev flag with find when scanning from / to prevent it from crossing into other mounted filesystems (e.g., NFS mounts or external drives). Without it, find will scan network mounts, which can be extremely slow and misleading.
4

Clear Package Manager Caches

Package managers download packages to a local cache before installing them. This cache is never automatically purged and can grow to several gigabytes on systems that are updated regularly.
apt autoremove removes packages that were installed as dependencies but are no longer needed by any installed package. It is safe to run regularly and often reclaims hundreds of megabytes.
5

Manage and Rotate Log Files

Unrotated or verbose application logs are one of the most common causes of unexpected disk exhaustion, particularly on servers.
Never use rm to delete a log file that is actively being written to by a running service — the file descriptor remains open and disk space is not freed until the service is restarted. Use truncate -s 0 instead, or restart the service after deletion.
Manage systemd journal logs (Linux):
Force log rotation immediately:
6

Clear Temporary Files and Application Caches

On machines running Docker, docker system prune -a is frequently the single most impactful cleanup action, recovering 10–30 GB on active CI/CD build hosts.
7

Use macOS Storage Management (macOS Only)

macOS provides a built-in graphical Storage Management tool that categorizes your disk usage and offers system-level optimizations not accessible from the command line.
  1. Click the Apple menuSystem Settings (macOS Ventura or later) or System Preferences (earlier).
  2. Select GeneralStorage (Ventura) or click Manage next to your disk.
  3. The Storage Management window opens and analyzes your drive. Allow it to complete — this takes 30–60 seconds.
Built-in optimization options:
Clearing ~/Library/Caches on macOS is safe — the OS and applications will rebuild these caches as needed. However, some apps (particularly Xcode and Simulator) store large items here. Check du -sh ~/Library/Caches/ before and after to confirm the reclaimed space.

Reclaim Space: Priority Checklist

Use this checklist to quickly work through the highest-impact cleanup actions first:
Set up automated log rotation (logrotate), configure journald size limits, schedule periodic apt autoremove or brew cleanup via cron, and enable iCloud Optimized Storage on macOS laptops to prevent the disk from filling up again.

Escalation

Deleted files held open by running processes can consume space invisibly — df shows space as used, but du doesn’t find the files because they have been deleted from the directory tree.
A filesystem can run out of inodes (directory entries) while still having free blocks. This produces the same “No space left on device” error.
  1. Document the output of df -h, df -i, and the top output from du -h --max-depth=3 / 2>/dev/null | sort -rh | head -30.
  2. If you cannot safely delete enough data to free space, contact your systems administrator or storage team to discuss expanding the volume, adding a new disk, or migrating large directories (e.g., /var/log) to a separate mount point.
  3. For cloud instances (AWS EC2, GCP, Azure), submit a request to increase the volume size — this can often be done online without downtime.