Repair Corrupted cPanel Quotas & Rebuild Disk Indexes Quickly
Fix corrupted cPanel quota files and stale disk‑usage indexes: back up, run checkquota, rebuildquota, and diskusage to restore accurate space reporting.
4 min read
cPanel is the most widely used control panel for shared hosting in India. Over time its quota database can become inconsistent, causing users to see incorrect disk‑space usage or to be blocked from uploading files even when space is available. This guide shows how to diagnose the problem, repair corrupted quota files, and rebuild the disk‑usage indexes so that cPanel reports accurate numbers again.
1. How cPanel Manages Disk Quotas
cPanel stores each account’s disk‑usage information in two locations:
Quota files – Plain‑text files located at /var/cpanel/users/USERNAME. They contain the account’s quota limit and current usage.
Disk‑usage indexes – Generated by the quota and diskusage utilities and cached in /var/cpanel/quota/ and /var/cpanel/diskusage/.
If the system crashes, a backup is restored, or the filesystem encounters errors, these files can fall out of sync with the actual data on disk. The result may be “0 MB used” for a full account, or upload attempts that are rejected despite apparent free space.
2. Prepare for Maintenance
Always create a snapshot or full backup of the affected accounts before modifying quota data. This protects you from accidental data loss.
# tar -czpf /root/cpanel-backup-$(date +%F).tar.gz /var/cpanel /home
This command creates a compressed .tar.gz archive in /root with a date‑stamped filename. Adjust the destination path if you store backups elsewhere.
3. Detect Corrupted Quota Files
cPanel includes a script that checks quota file integrity. Run it as root:
Run the quota check
# /usr/local/cpanel/scripts/checkquota
If the script reports “Corrupt quota file” for any user, note the usernames. You can also open the corresponding file in /var/cpanel/users/USERNAME to look for obvious syntax errors (missing fields, extra spaces, or non‑numeric values).
4. Repair Corrupted Quota Files
cPanel can rebuild a user’s quota file from the actual disk usage using the rebuildquota script.
Rebuild quota for a single user
# /usr/local/cpanel/scripts/rebuildquota USERNAME
Replace USERNAME with the affected account name. The script performs three actions:
Scans the user’s home directory to calculate total disk usage.
Updates /var/cpanel/users/USERNAME with the new usage value.
Regenerates the quota cache files under /var/cpanel/quota/.
Rebuild quota for all accounts
# /usr/local/cpanel/scripts/rebuildquota --all
Use this option if you suspect widespread corruption after a crash. The process may take several minutes on a busy server.
5. Rebuild Disk‑Usage Indexes
After fixing quota files, the cached usage indexes can still be outdated. Run both the diskusage and quota utilities to ensure consistency.
Step 1 – Rebuild the disk‑usage cache
# /usr/local/cpanel/scripts/diskusage --rebuild
This scans every user’s home directory, calculates the size of each subdirectory, and writes the results to /var/cpanel/diskusage/USERNAME. The --rebuild flag forces a full rescan, ignoring any existing cache.
Step 2 – Re‑run the quota utility
# /usr/local/cpanel/scripts/quota --rebuild
The quota utility updates the /var/cpanel/quota/USERNAME files, which are used by WHM’s “Disk Usage” widget and by cPanel’s “Disk Space Used” column.
Step 3 – Verify the results
# /usr/local/cpanel/scripts/checkquota
If the script returns “All quota files are OK”, the repair succeeded. You can also log into WHM → Account Information → List Accounts and confirm that the “Disk Used” column matches the size shown by du -sh /home/USERNAME.
6. Automate Future Checks (Optional)
Scheduling a nightly check and rebuild can minimise the risk of future corruption.
This runs at 02:00 AM every day, first checking for corruption, then rebuilding quotas and disk‑usage indexes if needed. Adjust the time to match your server’s low‑traffic window.
7. Common Pitfalls and How to Avoid Them
Running scripts during heavy file transfers – Utilities read the filesystem state; large uploads can cause temporary mismatches. Schedule maintenance during off‑peak hours.
Insufficient space in /tmp – Both rebuildquota and diskusage create temporary files there. Ensure at least 1 GB of free space on a typical shared‑hosting server.
Permission errors – The scripts must be executed as root. Running them under a limited user will produce “Permission denied” and leave quota files unchanged.
Outdated cPanel version – Older releases may contain bugs in the quota scripts. Keeping cPanel up‑to‑date (WHM → Upgrade to Latest Version) reduces the likelihood of corruption.
Conclusion
Corrupted quota files and stale disk‑usage indexes can be frustrating for both hosting providers and their customers. By backing up first, using cPanel’s built‑in checkquota, rebuildquota, and diskusage utilities, and optionally automating nightly checks, you can maintain accurate quota reporting and prevent unexpected service interruptions for your Indian clientele.