VPS servers often have limitations on disk space and/or inodes (the number of files). When these limits are reached, it can cause problems and affect the server's performance. Lack of disk space or inodes can prevent the creation of temporary files needed for task execution, potentially causing the server to become unresponsive.
To manage disk space and inode usage effectively, you can periodically check the space and inode usage yourself.
Checking Disk Space
Use the following commands to monitor disk space usage:
Check general disk space usage on the server:
df -h
Check the space taken by the contents of the current folder:
du -h
Check only the disk space of the current folder:
du -hs
Check the size of files and folders in a specific directory:
du -hs /etc
Find files larger than 1024KB:
find / -mount -size +1024k -type f -exec du -Sh {} \; | sort -rh
Checking Inodes Usage
To monitor inode usage, use these commands:
Check inodes usage in the current folder:
for i in $(ls -1A); do echo "$(find $i | sort -u | wc -l) $i"; done | sort -rn | head -5
Check the top 50 folders by inode usage:
du -a / | sort -n -r | head -n 50
Note: You can use this command within a specific folder. For example, to check the top 50 folders by inode usage in the /etc
directory:
cd /etc
du -a / | sort -n -r | head -n 50
By regularly monitoring disk space and inode usage, you can prevent your server from running into issues related to disk space and file limitations.