It is necessary to distinguish space saturation, saturation in inodes and deleted files still open before cleaning a Linux server.
Steps.
- Measuring volumes — Use df -h to locate the saturated file system.
- Check for inodes — Use df -i to exclude a lack of,inodes.
- Search for large folders — Use from the assembly point concerned.
- Search for deleted open files — lsof can reveal large files still occupied by a process.
- Clean in a targeted manner – Process logs, caches or data only after identification.
Commands
df -h
df -i
sudo du -xhd1 /var | sort -h
sudo lsof +L1
Key takeaways
- Do not blindly delete /var/lib or files from a database.
- A deleted but still open file continues to occupy disk space.
- Check Logrotate if the logs are the recurring cause.
See also: LVM.