Handling Windows system C drive full / Linux system disk block and inode full
Published: 2014-12-04
Windows system
Log in to the server remotely, download c盘清理.bat, save it to D:\ , then double-click the bat file to clean automatically. It is recommended to set a scheduled task to clean at 1:00 every night
Run under cmd in Windows 2008 system:
schtasks /create /tn "cleanC" /tr D:\c盘清理.bat /sc daily /st 01:00:00
Linux system
First log in to the server remotely via SSH. Login tutorial: http://www.west.cn/faq/list.asp?unid=417,
There are two situations when the disk is full. Execute the following two commands respectively to see which situation yours belongs to.
Disk block is full. Check command: df -vh

Disk inode is full. Check command: df -ih

I. How to handle a full block
The commands needed are as follows:
ll List files in the current directory
df –vh Check disk usage
cd directory name Enter a directory
du -sh * Count the size of files in the current directory
rm -rf file name|directory Delete a file or directory (the operation is irreversible; before deleting, please confirm whether the file is useless)
ls -A | grep -Ev 'home' |xargs du -sh Count the size of files in directories other than the home directory
1). Use df -vh to check which partition is full

2). Use the cd and du commands to check which directory is the largest

3). Continue executing the cd and du commands to find the largest file or directory

4). Find the largest file and delete it with the rm -rf file name command

PS: Before deleting, please confirm whether the file is useless, and delete only after confirmation. If all files are useful, please consider upgrading the disk size. If the cd command reports an error, please check whether what you entered is a directory by using the ll command. Directory names are blue, and file names are white. In addition, if the du command does not respond for a long time, press Ctrl + C to end the command, execute the ll command, enter the next directory under the directory last displayed by the du command, and continue searching
II. How to handle a full inode
The commands and scripts needed are as follows:
ll List files in the current directory
df –ih Check disk inode usage
cd directory name Enter a directory
du -ah * Count the size of files in the current directory and subdirectories
rm -rf file name|directory Delete a file or directory (the operation is irreversible; before deleting, please confirm whether the file is useless)
ls |xargs rm -rf Delete all files in the current directory
check_inode_counts.pl script quickly counts the inode usage of each directory under a directory
find */ ! -type l | cut -d / -f 1 | uniq -c Count the inode usage of each directory under the current directory (executes slowly; this command is not used by default)
1). Use df -ih to check which partition is full

2) Download the check_inode_counts.pl script and execute it. Execute the following commands in sequence:
wget http://downinfo.myhostadmin.net/check_inode_counts.txt
mv check_inode_counts.txt check_inode_counts.pl
perl check_inode_counts.pl /
Continue executing for the directory equal to 50000; if there is none, the maximum-value directory has high usage. For example, if perl check_inode_counts.pl / reports that the /home directory equals 50000, continue executing perl check_inode_counts.pl /home, executing directory by directory to find the largest usage, as shown in the figure

3). Continue searching, until you find the directories with relatively large inode usage, note that there are usually multiple directories.
After executing the ll command, many similar files will appear

4). Use the command cat file name to check whether the file is abnormal. If it is abnormal, delete it; if it is not abnormal, continue searching

Delete all abnormal files in this directory

PS: If all files in the current directory are normal, please execute cd ../ to return to the upper-level directory and continue searching using the above method. Before deleting, please confirm whether the file is useless, and delete only after confirmation. If all files are useful, please consider upgrading the disk size. In addition, if the above deletion command gets stuck, you can use the find . -name "*.html"|xargs -t -n5 rm -rf command, where "*.html" is the suffix of the abnormal files seen above
Note: Before deleting files, please confirm whether the files are useless. If you are unsure, please consult a website programmer. In addition, the above methods only find and handle the problem; you need to analyze the cause yourself. If backups or logs are full, you need to modify or disable backups or logs. If a Trojan program generates a large number of files, in addition to deleting the files, you also need to find and fix the program vulnerability!
