Understanding the 'Disk quota exceeded' Error
When you try to write to a file or directory on a Linux system and receive the message Disk quota exceeded, it means you've hit a limit imposed by the filesystem's quota system. This limit can be on the total disk space used (block quota) or on the number of files and directories (inode quota). The error prevents you from creating new files, extending existing ones, or sometimes even receiving email or running applications that need to write temporary data.
Block Quotas vs Inode Quotas
Quotas are enforced in two dimensions:
- Block quota (disk space): limits the total number of 1βKB blocks (or the configured block size) a user or group can own. This directly caps the bytes stored.
- Inode quota (file count): limits the total number of files and directories. Even if you have free disk space, creating thousands of tiny empty files can exhaust the inode quota first.
The error message usually doesn't distinguish which one you've hit, so you must check both.
Soft vs Hard Limits
Linux quota supports two thresholds per resource:
- Soft limit: you can exceed it temporarily during a grace period. The system warns you but still allows writes until the grace time expires.
- Hard limit: you can never exceed this under any circumstances. Attempting to write beyond the hard limit immediately triggers the error.
When you see "Disk quota exceeded", it usually means you've reached the hard limit, or the grace period on a soft limit has already passed and the soft limit is being enforced as hard.
Why It Matters
Quotas protect shared systems from a single user consuming all available storage, causing denial-of-service for others. They are common on shared hosting, university servers, CI/CD build environments, and corporate development boxes. As a developer, encountering this error can break your build process, prevent database writes, crash loggers, or block version control operations. Understanding how to diagnose and resolve it quickly keeps your workflows running.
Diagnosing the Problem
π Deploy your AI agent in 10 minutes
Managed Hermes hosting. Zero DevOps. 100M tokens/mo included.
Try it free →
First, determine whether you've hit a block limit or an inode limit, and see your current usage against both soft and hard boundaries. Use the quota command.
# Show your own quota usage and limits on all mounted quota-enabled filesystems
quota -s
The -s flag prints block sizes in human-readable units (MB, GB). Sample output:
Disk quotas for user alice (uid 1001):
Filesystem space quota limit grace files quota limit grace
/dev/sda1 495M 500M 600M 124k 0 0
spaceβ current block usagequotaβ soft limitlimitβ hard limitfilesβ current inode count (often in thousands with a 'k' suffix)
If you see your usage equal to or exceeding the hard limit, that's the cause. If the soft limit is reached but the grace period still shows "none" or a time, you may still be able to writeβunless the grace period expired and the soft limit now behaves as a hard cap.
For a more detailed view, use:
quota -v
This includes filesystems where you have no quota and shows additional information. To check group quotas:
quota -g
Checking the Quota State as Root
If you have sudo access or are the system administrator, you can inspect all users:
sudo repquota -s /
Replace / with the mount point of the filesystem (e.g., /home, /var). The -s flag gives human-readable sizes. This shows every user and group with non-zero usage, their soft/hard limits, and grace times. It helps identify whether the entire filesystem is over quota or just one user.
Finding Large Files and Inode Hogs
To free space you need to find what consumes it. Use du and find.
# Summarize disk usage of your home directory, sorted by size
du -ah ~ | sort -rh | head -20
This lists the largest files and directories. For inode usage (number of files), you can count files per directory:
# Count files in each subdirectory of the current folder
find . -type d -exec sh -c 'echo "$1: $(find "$1" -maxdepth 1 | wc -l)"' _ {} \;
Or simply:
# Show directories with the most files (up to depth 1)
find ~ -maxdepth 1 -type d -print0 | xargs -0 -I {} sh -c 'echo $(find "{}" -mindepth 1 | wc -l) "{}"' | sort -rn | head
How to Fix 'Disk quota exceeded'
There are two fundamental approaches: free up space (or inodes) by deleting or compressing files, or increase your quota limits (requires administrator privileges). As a regular user, you'll typically clean up.
Cleaning Up Disk Space
Start with the obvious candidates: temporary files, package caches, old logs, and large downloads.
# Delete files in the trash (if using a desktop environment)
rm -rf ~/.local/share/Trash/*
# Clear the user's systemd journal (if persistent journal is enabled)
journalctl --user --vacuum-time=1d
# Remove package manager caches (example for apt-based systems)
sudo apt clean
# Or for pip (Python) cache
pip cache purge
# Remove npm cache if you're a Node.js developer
npm cache clean --force
Look for log files that may be filling up:
# Find files larger than 100MB under /var/log (requires appropriate permissions)
find /var/log -type f -size +100M -exec ls -lh {} \;
If you have permission to read but not delete system logs, contact the admin. For your own application logs, truncate or compress them:
# Truncate a log file (keep last 10,000 lines)
tail -n 10000 app.log > app.log.tmp && mv app.log.tmp app.log
# Compress old logs with gzip and then delete originals
gzip old.log
Freeing Inodes
If you hit the inode limit, you must reduce the total number of files. Common culprits include:
- Package caches (like
node_moduleswith thousands of tiny files) - Build artifacts (object files, dependency directories)
- Mail spool files (thousands of emails stored in
Maildir) - Session or cache data from web applications
Identify directories with extremely high file counts:
# Show number of files (including subdirectories) in the current tree
find . -type f | wc -l
Then remove or relocate them. For example, clearing a node_modules directory that isn't needed:
rm -rf project/node_modules
If you need the directory, you might archive it into a single tarball to drastically reduce inode count, though you'd then have to extract it on a different filesystem when needed.
Moving Data to Another Filesystem
If the quota applies only to one partition (e.g., /home), but you have space on a different partition without quotas (or with higher limits), you can move large files there and create a symbolic link. This works if you have write access to the other partition.
# Move a large directory to /scratch (assuming /scratch has no quota)
mv ~/big_project_data /scratch/
ln -s /scratch/big_project_data ~/big_project_data
Be careful: applications that resolve symlinks will write to the new location, avoiding the quota. However, some tools may not follow symlinks, so test first.
Increasing Quota Limits (for System Administrators)
If you manage the server and the user legitimately needs more space, adjust the quota. This section assumes you have root access and the filesystem is mounted with quota support.
Enabling Quota on a Filesystem
First, ensure quota is enabled. The mount options usrquota and grpquota must be present in /etc/fstab for the respective filesystem.
# Example /etc/fstab line
/dev/sda1 /home ext4 defaults,usrquota,grpquota 0 2
If you added these options, remount or reboot:
sudo mount -o remount /home
Then run quotacheck to initialize quota databases:
sudo quotacheck -cug /home
This creates aquota.user and aquota.group files. Then turn quotas on:
sudo quotaon /home
Modifying a User's Quota Limits
Use edquota to edit limits interactively:
sudo edquota -u alice
This opens your default editor showing current block and inode limits. The format is usually:
Disk quotas for user alice (uid 1001):
Filesystem blocks soft hard inodes soft hard
/dev/sda1 500M 500M 600M 124k 0 0
Change the soft and hard values as needed. To set the same limits for multiple users, you can use -p to prototype:
# Set bob's quota to match alice's
sudo edquota -p alice bob
For scripting, use setquota:
# Set user alice: block soft=700000 hard=800000, inode soft=150000 hard=200000
sudo setquota -u alice 700000 800000 150000 200000 /home
Numbers are in blocks (usually 1KB) and absolute inode counts. After changing limits, users may still be over the soft limit but within the grace period; you can edit grace periods with edquota -t.
Checking and Updating Quota Database
After major changes or if you suspect inconsistency, run quotacheck again:
sudo quotacheck -m /home
The -m flag forces a check even if the filesystem is mounted read-write. Then turn quotas off and on to apply:
sudo quotaoff /home && sudo quotaon /home
Best Practices to Avoid Quota Issues
- Monitor usage regularly: run
quota -sin your shell startup or via cron, and set up alerts if you approach soft limits. - Configure logrotate: ensure application logs are rotated and old archives compressed or deleted automatically.
- Clean caches and temporary files: schedule periodic cleanup of package manager caches (
apt clean,dnf clean all), pip cache, npm cache, and your browser/IDE caches. - Use
/tmpor a dedicated scratch space: for build artifacts that are ephemeral, write them to/tmp(usually on a different partition without quotas) or a/scratchvolume. - Separate large data: store databases, container images, and large datasets on partitions with generous limits or no quotas.
- Set realistic limits: as an admin, profile typical usage before assigning quotas. Use a grace period long enough for users to react (default 7 days).
- Educate users: provide clear documentation on how to check quotas and what to do when limits are reached.
- Automate enforcement: use scripts that check quota usage and warn users via email when they hit 80% of soft limit.
Conclusion
"Disk quota exceeded" is a protective mechanism, not a permanent barrier. As a developer, you can quickly diagnose whether you've hit a block or inode limit using quota and repquota, then recover by removing or compressing unneeded files, clearing caches, or relocating data to a non-quota partition. Administrators can adjust limits with edquota or setquota to match legitimate workload growth. By combining proactive monitoring, sensible cleanup routines, and well-tuned limits, you can keep your development environment free of quota interruptions and maintain productivity on shared Linux systems.