Hello all, Suddenly from this afternoon my site stops working. then i find out its the inodes that gone to 100% was the reason. then after many searching i found the following article and that solved my issue. but not entirely. No space left on device – running out of Inodes
i followed above tutorial and freed up 5% of innodes by removing only one folder /usr/src with the following command.
rm -rf /usr/src
now i just want to be confirm about 1 thing. that command only delete bad empty files not important files as well? because i have just delete one folder with that command and freed up 5% inodes. but i have couple of more folders with large number of files but im a bit scared to apply this with those. because after the above command now i can see the whole src folder is deleted.
This textbox defaults to using Markdown to format your answer.
You can type !ref in this text area to quickly search our full set of tutorials, documentation & marketplace offerings and insert the link!
Removing system folders like /usr/src is never a good idea. While this particular directory is less likely to cause serious issues since it does not generally include binaries you run or support files needed for an application to run, it does contain files required for building components of some software and since these files are managed by the package manager they should not be manually deleted.
Instead you should be looking for what you are running that is creating so many files and where those are being created. I would check your logs in /var/log to see if there are masses of files being created there by a process and review the scripts/services you are running.
Heya,
Running out of inodes can be a real headache, especially when you have a folder with millions of smaller files. Don’t worry, I’ve got you covered! Here’s a more efficient way to handle this using the find command directly.
Identify Inode Usage: First, let’s identify which directories are consuming the most inodes. You can use the find command combined with wc -l to get a count of the inodes used by each directory.
find / -xdev -type d -exec sh -c 'echo -n "{}: "; find "{}" | wc -l' \; | sort -n -k2
This command will give you a sorted list of directories with their inode usage.
Drill Down Further: Once you’ve identified the main directory, you need to drill down further. For example, if /home is the culprit:
find /home -xdev -type d -exec sh -c 'echo -n "{}: "; find "{}" | wc -l' \; | sort -n -k2
Keep drilling down until you find the specific directory causing the issue.
Handle Hidden Files: Include hidden files in your search by specifying the appropriate paths:
find /home/youruser -xdev -type d -exec sh -c 'echo -n "{}: "; find "{}" -name ".*" | wc -l' \; | sort -n -k2
Clean Up: Once you’ve found the directory with the most inodes, it’s time to clean up. Here are a few strategies:
Delete Unnecessary Files: Identify and delete files you don’t need. For example, temporary files, logs, or cache files:
```
find /home/youruser/temp -type f -delete
```
Automate Cleanups: To prevent this from happening again, you can set up a cron job to regularly clean up unnecessary files:
crontab -e
Add a job to clean up temporary files every week:
0 3 * * 0 find /home/youruser/temp -type f -mtime +7 -delete
Here are some commands to help you get started:
# Check inode usage
df -i
# Identify high inode usage directories
find / -xdev -type d -exec sh -c 'echo -n "{}: "; find "{}" | wc -l' \; | sort -n -k2
# Drill down into specific directories
find /home -xdev -type d -exec sh -c 'echo -n "{}: "; find "{}" | wc -l' \; | sort -n -k2
# Include hidden files in search
find /home/youruser -xdev -type d -exec sh -c 'echo -n "{}: "; find "{}" -name ".*" | wc -l' \; | sort -n -k2
# Delete unnecessary temporary files
find /home/youruser/temp -type f -delete
# Compress files
tar -czvf archive.tar.gz /home/youruser/folder
# Move files to another server
scp -r /home/youruser/folder user@other-server:/path/to/destination
# Automate cleanups with cron job
crontab -e
By following these steps, you should be able to clear up some inodes and prevent this issue from recurring in the future.
Hope that this helps!
Get paid to write technical tutorials and select a tech-focused charity to receive a matching donation.
Full documentation for every DigitalOcean product.
The Wave has everything you need to know about building a business, from raising funding to marketing your product.
Stay up to date by signing up for DigitalOcean’s Infrastructure as a Newsletter.
New accounts only. By submitting your email you agree to our Privacy Policy
Scale up as you grow — whether you're running one virtual machine or ten thousand.
Sign up and get $200 in credit for your first 60 days with DigitalOcean.*
*This promotional offer applies to new accounts only.