Scenario
A production Linux server runs out of disk space, causing application write failures and service disruption. Monitoring alerts show disk usage above 95%. Affected services may include databases, web servers, log collectors, or application runtimes.
Symptoms
- Application logs:
write error: No space left on device df -hshows 100% utilization on one or more partitions- System logs (e.g.,
/var/log/messages) report space exhaustion - Services fail to start or respond slowly
- Possible inode exhaustion:
df -ishows 100% IUse%
Diagnosis
-
Quick disk check
bash df -h df -i # check inode usageIdentify the affected partition and free space. -
Find large directories/files
bash du -sh /* 2>/dev/null | sort -rh | head -10 du -sh /var/* | sort -rh | head -5Prioritize/var(logs),/tmp,/home, and application data mounts. -
Check deleted but held files
bash lsof +L1 # list all deleted files still held openThese take space but don't appear indu; truncate or restart the holding process. -
Inspect log rotation
bash ls -lh /var/log/*.log systemctl status logrotate cat /etc/logrotate.confEnsure logrotate is running and properly configured. Manually rotate:logrotate -f /etc/logrotate.conf -
Find files >1GB
bash find / -type f -size +1G -exec ls -lh {} \; 2>/dev/nullReview results; decide deletion/compression.
Risk Controls
- Do not
rm -rfunknown files without checking dependencies. - For logs, avoid deleting critical logs (e.g., database binlogs).
- Use
truncate -s 0 <file>to empty a file instead of deleting it (preserves file handles). - Check
lsofbefore removing files held by processes. - Take a filesystem snapshot (if cloud) or backup critical directories.
Remediation
-
Immediate space recovery - Truncate a large log:
truncate -s 0 /var/log/syslog- Clean old temp files:find /tmp -type f -atime +7 -delete- Compress old logs with gzip. -
Permanent fix - Adjust logrotate retention and compression. - Set up automated cleanup scripts. - Increase disk size or mount additional storage.
-
Handle deleted-but-held files - If the holding process is expendable, restart it:
systemctl restart <service>- Otherwise, use> /proc/<pid>/fd/<N>to truncate the file descriptor (dangerous).
Rollback
- If a file is deleted in error, restore from backup (requires pre-existing backup).
- If truncation breaks a service, restart the service (log files are re‑created automatically).
- For truncation causing process crash, remove the file and restart the process.
- Disk expansion is often irreversible; rollback by unmounting new volumes and restarting services.
Verification
- Run
df -hto confirm space is under threshold. - Check application logs for absence of space errors.
- Perform functional test (e.g., write a test file).
- Verify monitoring alert clears.
- Ensure logrotate works: generate new log and check rotation.
When to Submit an OpsGlobal Ticket
- You cannot identify the root cause of space consumption.
- Critical files (e.g., database files) need recovery after deletion.
- Suspected filesystem corruption (
dmesgshows I/O errors). - Long‑term capacity planning or architecture changes required.
- Your team lacks Linux system administration expertise.
OpsGlobal engineers will remotely assist with deep analysis, root cause identification, remediation, and preventive recommendations.
Use cases
Useful for teams handling DevOps issues and needing a clear troubleshooting and delivery workflow.
Problem background
A deep practical guide for diagnosing and resolving disk full issues on Linux production servers. Covers symptom recognition, diagnostic commands, risk controls, rollback steps, verification, and when to escalate to OpsGlobal support.
Troubleshooting steps
Confirm impact and recent changes, collect logs, configuration and metrics, then apply fixes from low to high risk.
Command examples
Replace sample resource names with real values and store passwords, tokens and keys in environment variables.
Risks
Before production changes, confirm backups, access boundaries, change windows and rollback paths.
Rollback plan
Keep original configuration and release versions; roll back config, images or database changes if metrics degrade.
Deliverables
Root-cause notes, key commands, remediation steps, verification results and follow-up recommendations.
Need help with a similar technical issue?
If your servers, Kubernetes, Docker, CI/CD, databases or monitoring systems have similar issues, submit logs and config files for remote diagnosis.