What happens when disk space is full???
First case: there is not enough disk space left for a block (df-h)
Second, there is not enough disk space left for inode (df-i)
Show no space left on device
block space is full, storage is too large
inode is full and produces lots of small files
1. Index Node Information - inode and blockde
The difference between inode and blockde:
1. What do inode and blockde do?
inode:(index node)Index node information used to store data---Some properties of a file or directory (the permissions for a file belong to a group of users) block: block For storing data---True data information for the file
2. How did inode and blockde appear?
Only after the disk is well formatted will there be a file system inode and block(Pouch) Creating a file takes up at least one inode And a block
3. How inode and blockde query for information
inode Information viewing method: [root@VM-0-3-centos ~]# df -i Filesystem Inodes IUsed IFree IUse% Mounted on devtmpfs 232347 329 232018 1% /dev tmpfs 235251 7 235244 1% /dev/shm tmpfs 235251 422 234829 1% /run tmpfs 235251 16 235235 1% /sys/fs/cgroup /dev/vda1 3276800 81268 3195532 3% / tmpfs 235251 1 235250 1% /run/user/0
block Information viewing method: [root@VM-0-3-centos ~]# df -h Filesystem Size Used Avail Use% Mounted on devtmpfs 908M 0 908M 0% /dev tmpfs 919M 24K 919M 1% /dev/shm tmpfs 919M 476K 919M 1% /run tmpfs 919M 0 919M 0% /sys/fs/cgroup /dev/vda1 50G 3.5G 44G 8% / tmpfs 184M 0 184M 0% /run/user/0
4. Why do df-h and df-i both show disk usage, but are they so different?
df -h Is to delete files that are relatively large and useless --- Large files occupy a large amount of disk capacity. df -i Remove too many small files --- Too many files consume a lot of inode Number. PS:If df To see any disk space that is full, you need to delete files from the file and clean up the space
2. Insufficient disk space block remaining (df-h)
Looking at the disk capacity through the df-h command, we found that / dev/vda1 has a larger capacity
[root@VM-0-3-centos /]# df -h Filesystem Size Used Avail Use% Mounted on devtmpfs 908M 0 908M 0% /dev tmpfs 919M 24K 919M 1% /dev/shm tmpfs 919M 468K 919M 1% /run tmpfs 919M 0 919M 0% /sys/fs/cgroup /dev/vda1 50G 3.5G 44G 8% / tmpfs 184M 0 184M 0% /run/user/0
Enter the /(root) directory and use du-sh * to see the capacity size of all directories under the /(root) directory
[root@VM-0-3-centos ~]# cd / [root@VM-0-3-centos /]# du -sh * 0 bin 123M boot 4.0K data 0 dev 37M etc 4.0K home 0 lib 0 lib64 16K lost+found 4.0K media 4.0K mnt 127M opt 0 proc 72K root 476K run 0 sbin 4.0K srv 0 sys 19M tmp 2.7G usr 408M var
Found usr directory occupies large capacity, enter usr directory to continue du-sh *investigation
[root@VM-0-3-centos /]# cd /usr [root@VM-0-3-centos usr]# du -sh * 277M bin 4.0K etc 8.0K ftp 4.0K games 33M include 774M lib 345M lib64 98M libexec 504M local 79M mpi 55M sbin 394M share 184M src 0 tmp
Continue to view capacity in the larger-footprint directory src
[root@VM-0-3-centos usr]# cd src [root@VM-0-3-centos src]# du -sh * 8.8M debug 77M kernels 8.0K mlnx-ofa_kernel 4.0K mulu 62M ofa_kernel 37M ofa_kernel-5.1 4.0K wenjian
PS: This operation simulates a situation where directories or files already need to be cleaned up
Now that you can find out which files are taking up a lot of memory, we'll use the mulu (directory) and wenjian (file) created by my own simulation as the test objects.
1. Clean up the files in the /usr/src/mulu directory.
[root@VM-0-3-centos src]# rm -r /usr/src/mulu/* rm: remove directory '/usr/src/mulu/fu'? y
2. Clean up the Wenjian files in the SRC directory of /usr/src/wenjian
Empty the contents of the file with the redirected command (and there are other ways to empty the contents of the file without demonstrating them all)
[root@VM-0-3-centos src]# echo " " >> /usr/src/wenjian
3. Insufficient disk space inode surplus (df-ih)
Plus h because it directly outputs units of capacity that people can see directly
Looking at the inode under df-ih, it is found that the usage of the inode value under the root directory is 100%
[root@VM-0-3-centos ~]# df -ih Filesystem Inodes IUsed IFree IUse% Mounted on devtmpfs 227K 329 227K 1% /dev tmpfs 230K 7 230K 1% /dev/shm tmpfs 230K 420 230K 1% /run tmpfs 230K 16 230K 1% /sys/fs/cgroup /dev/vda1 3.2M 3.2M 0 100% / tmpfs 230K 1 230K 1% /run/user/0
Solution: Check through the following script to see which directory has the most files under it
[root@VM-0-3-centos ~]# find / -xdev -printf '%h\n' | sort | uniq -c | sort -k 1 -n
Ultimately, the maximum number of files was found in the / usr/local/tomcat directory. Then it became clear that there were millions of files under the / usr/local/tomcat/logs directory, which should be logs accumulated over time by long-running applications, deleting all files in that directory, and using the xargs command to delete a larger number of files
[root@VM-0-3-centos ~]# ls | xargs -n 10 rm -rf