Node Running Out Of DiskSpace
There are many reasons for which your Node might be running out of Diskspace, We have mentioned a few of the common reasons mentioned below.
Log Files
A server log file is a general text document that contains all activities your server in a given period of time, It is usually automatically created and maintained by the server, and it can provide you with detailed insight into how, when, and by whom your website or the application was accessed.
The logs file by default is usually Present in the /var/log directory where you may see these files located. This file will grow over time considering the number of Logs that are added in a day. If you don’t have a system to Purge these Logs. It will keep on Increasing its size, especially when there are any errors or warnings. You need to make sure to Purge this Logs regularly So that it does not fill up your disk unnecessarily.
To purge logs you can use services like Logrotate that can purge your logs and Clear as per requirement. If you don’t want your logs to be saved, You can also truncate the Logs by the below command where the content of Logs will be wiped out reducing the disk consumption
For Example, to Truncate the messages Log file, You can use the below command:
cat /dev/null > /var/log/messages
Backup Files
Storing Regular backups on your server can Often increase the Disk Consumption on your server. You need to Make sure there is a Proper system of Deletion of Old Backups.
Temporarily Files and Regular Uploads
Some Applications and Services running on your server may create temporary files in /var/tmp folder. You can check these Files and Clear it if it’s not required.
Regular Uploads of Files and Folder should also need to be checked as many of these files/Foldes are no longer needed but still consumes a huge chunk of disk space on your server can be removed.
How to identify the Disk Usage on your server
In order to First check which Partition is full (You might have received the alert for root Partition), You can run the below command
df -h
Once you have identified the Partition which is full, You can check the Disk usage folders which you probably think is consuming the Disk on Your server with the below command
For example, To check the Disk usage of the path /root/user you can use the below command
du -sh /root/user/*
It will probably list out the output of the File consumption as below as per usage
1.5GB /root/user/backupfile
158MB /root/user/text
1MB /root/user/textfolder
Similarly, You can also use ncdu command to identify the full Disk Usage on your server. ncdu (NCurses Disk Usage) is a command-line version of the most popular “du command“. It is based on ncurses and provides a fastest way to analyse and track what files and directories are using your disk space in Linux
To Install ncdu command on your server, Please use below command
For RHEL, CentOS
yum install ncdu
For ubuntu and Debian
sudo apt-get install ncdu
Now Simply, run the “ncdu” command from the terminal. Once you run, it will start scanning for number of files and directories and disk usage of current working directory or path / to scan whole server
ncdu /
Sometimes, You may also face the issue of where the space consumption of the file is unknown. This may happen when programs that are running may still be writing to files that have been deleted.You can use command ** lsof | grep "(deleted)"** to find such a file. Rebooting your node once may also Fix this issue