Digital Marketing

How to solve Disk Full problem of servers

There are 2 scenarios when disk full happens in servers. One is running out of disk space, another is exceeding the limits of inode.

For the 1st case, to produce a list of all the folders in /path/to/folder and their sizes

du -cks * | sort -rn | head
$ du -h --max-depth=1 /path/to/folder
To sort it
$ sudo du  --max-depth=1 / | sort -nr
To find files larger than certain size:
$ sudo find / -type f -size +100M
To exclude some folders, for example, not to find in folder "/backup" and "/mnt"

$ sudo find / -type f -not -path "/backup/*" -not -path "/mnt/*"   -size +50M
$ sudo ls -lh `sudo find / -type f -size +100M`
$ sudo du -h / -d 1 --exclude=/backup --exclude=/mnt
See also:

How to find the largest file in a directory and its subdirectories using the find command

If it is the 2nd case. first find out which partition is running out of inodes:

$ df -hi
Filesystem            Inodes   IUsed   IFree IUse% Mounted on
/dev/sda1 88.8G 88.8G 0 100% /i88ca
Next, try to find out which directories have too many files:
$ find /i88ca -xdev -size +10000k -type d
The size of a directory is proportional to the amount of files directly inside that directory. 
To ordered by "size":
$ find /i88ca -xdev -size +10000k -type d -printf '%s %p\n' | sort -n

Comments

Popular posts from this blog

MySQL Sandbox with the Sakila sample database