1. Inodes Describes file data stored in blocks in Linux, and file meta-information, such as file creator, file creation date, and file size. The area where the meta information is stored is called an inode, or “index node” in Chinese. The inode also occupies space on the hard disk, and when the hard disk is formatted, the operating system automatically divides the hard disk into two areas. One is the data area, storing file data; The other is the inode table, which stores the information contained in the inode.
The size of each inode node, typically 128 or 256 bytes. The total number of inode nodes, given at formatting time, is typically one inode per 1KB or 2KB. Assuming a 1GB hard disk with 128 bytes for each inode node and one inode for every 1KB, the size of the inode table would be 128MB, or 12.8% of the total hard disk.
2. Inodes resources are used up Similar to that of the storage space. Files cannot be created or commands cannot be executed. When the inodes are used up, the inode table can be filled with a large number of small files.
In most cases, only a few percent of the storage space is used up, so it is easy to ignore the monitoring of inodes usage.
To display the usage of disk space, run the df command to view the usage of disk space
To check the usage of inodess, run the df -i command
The preceding two commands can use the -h parameter. The commands are df -h and df -hi. You can see that disk space is 71% used, but inodes is 100% used.
The size of inodes is determined during disk partition formatting and depends on the partition size. A larger partition means a larger inodes and vice versa.
In Linux, the partition of the root directory is small. If periodic small files are generated and the inodes are not cleared in time, the inodes may be used up.
Inodes are full.
(1) View the directory with the most files
for i in /*; do echo $i; find $i | wc -l; done
Copy the code
If the directory scope is specified, make the /* more specific
Eventually found is/var/spool/postfix/maildrop directory too small file, here’s why: because the Linux in execute cron, cron script execution will be the output and warning information, will be in the form of mail sent to the cron owner. Because sendmail and Postfix in the customer environment did not work properly, the mail could not be sent successfully, and all the small files were piled up in the MailDrop directory. Moreover, due to the lack of automatic cleaning mechanism, a large number of files were piled up in this directory.
The root user has delivered a scheduled clock synchronization task that generates a small file every minute.
(2) Delete a large number of files
Ls | xargs - n 1000 rm - rf need to use xargs command, or it will delete failed.Copy the code
Add MAILTO=”” to the first line of crontab -e and no file will be generated
(2) redirection Set the redirection output file for scheduled tasks. Scheduled tasks that do not need log output can be redirected to /dev/null as follows:
*/10 * * * * /tmp/test.sh >/dev/null 2>&1
Copy the code
(3) Regularly clean up files
Find directories -type f - mtime + 30 | xargs -n 1000 rm -f * *Copy the code
(4) Monitor the use of inodes
Note: Pay attention to the format of crontab and the periodic clearing of generated files