Regarding the problem of the Linux disk being full, I have encountered it before when using the WDCP panel because the website log was enabled in the background of the panel, but the log was not deleted regularly. In the long run, the disk space of the VPS host was filled up with logs. When the disk space reaches 100%, some inexplicable errors will occur on the website, such as being unable to log in to the background, unable to comment, and the page is blank, etc.

However, recently when I was maintaining the network monitoring platform ping.wzfou.com, I found that there was still a lot of disk space, but the No Space Left on Device error was still reported in the log. After investigation, it was finally discovered that the inodes of the Linux disk were used up, causing the website to be unable to continue writing new data. Finally, Smokeping in the background was not running properly and reports could not be displayed.

Whether it is disk space or disk inode space, as long as it is occupied, it will cause instability of the website. Sometimes we may not suspect this and may look for other problems. The most serious situation where the disk is full may cause S#S¥H to be unable to enter. At this time, we need to perform related operations to release disk space from the VPS panel.

Solution to Linux system disk space full-No Space Left on Device error

This article will share the solution to the problem that the Linux system disk space is full. The main purpose is to record the use of the search disk space command to prepare for future emergencies. For more ways to use Linux commands, here are:

  1. Three command tools Rsync, SCP, and Tar-quick solution to VPS remote website relocation and data synchronization
  2. Summary of Linux system monitoring commands - master CPU, memory, disk IO, etc. to find performance bottlenecks
  3. Linux Crontab command scheduled task basic syntax and operation tutorial-VPS/Server Automation

PS: Updated on February 22, 2019, When the disk space is about to be used up, it is time to consider expanding the hard disk: Linux VPS host hard disk expansion method - VPS new hard disk partition mounting and hard disk dynamics Expansion.

1. Solve the problem of disk space occupied 100%

1.1  Check the current remaining disk space

Command: df -h, use this command to see how much disk space is left on the current VPS host. If you see that the occupied space reaches more than 90%, you need to clean up the space.

2. Solve the problem of disk inode occupying 100%

2.1  Check the inode occupancy status

When the hard disk is formatted, the operating system automatically divides the hard disk into two areas. One is the data area, which stores file data; the other is the inode area (inode table), which stores the information contained in the inode. The size of each inode node is generally 128 bytes or 256 bytes. The corresponding relationship between inode and data storage is as follows:

Use the command df -ia to query the current inode occupancy:

2.2  Find out the directory with large inode occupancy

Use the following command to calculate the inode occupied by each folder in the current directory:


#当前各大文件夹占用inode情况
for i in /var/*; do echo $i; find $i |wc -l; done
#排序
sudo find . -xdev -type f | cut -d "/" -f 2 | sort | uniq -c | sort -n

Use the above command multiple times to find out the specific directory that occupies a large inode, and then delete the file or folder using the above method.

3. Summary

Generally speaking, inodes cannot be used up unless the program generates a large number of logs. For example, the problem encountered by wzfou.com this time is that there are a large number of files in /var/spool/postfix/maildrop/. This is because postfix cannot run. Normally caused. Of course, if sendmail or postfix is ​​running normally, a large number of emails will accumulate in the /var/mail directory.

If you do not use sendmail or postfix, it is recommended to delete or uninstall them directly:

apt-get remove sendmail*
yum remove sendmail
或者
yum remove postfix
sudo apt-get remove postfix
sudo apt-get remove --auto-remove postfix

Some friends thought that they could use scripts to monitor the inode usage of the VPS host. In fact, the Zabbix introduced before can realize the inode monitoring of the server. For details, see: Zabbix installation and use - a powerful server performance monitoring tool to control server software and hardware resources.

Leave a Reply