When you got a notification regarding your server's disk space being nearly full, below are the steps you should follow to address and find out what is consuming most of the disk space.
You would need to confirm if the disk space is indeed nearly full. You can check this by the df command.
You should see an output similar to below:
Filesystem Size Used Avail Use% Mounted on
devtmpfs 7.7G 0 7.7G 0% /dev
tmpfs 7.7G 7.6M 7.7G 1% /dev/shm
tmpfs 7.7G 59M 7.7G 1% /run
tmpfs 7.7G 0 7.7G 0% /sys/fs/cgroup
/dev/mapper/centos-root 50G 37G 14G 73% /
/dev/sda1 1014M 351M 664M 35% /boot
/dev/mapper/centos-home 1.8T 2.6G 1.8T 1% /home
/dev/loop0 2.2G 195M 1.9G 10% /tmp
tmpfs 1.6G 4.0K 1.6G 1% /run/user/42
tmpfs 1.6G 40K 1.6G 1% /run/user/0
According to the output above, you can see /dev/mapper/centos-root is at 73% full. Therefore, we should be investigating that partition alone.
Since /dev/mapper/centos-root is the root partition, it includes all the other partitions. It is important to ensure we are excluding other partitions when checking the disk space. Else, the disk space is going to take a very long while to calculate.
du -h --max-depth=1 --exclude=/tmp --exclude=/tmp --exclude=/proc --exclude=/home/virtfs /root
Once you have determined the directory that is consuming the most disk space, you can use the command below to get a more detailed read-out.
du -h --max-depth=1 -x /$partition | sort -hr
We are using -x, because we are reading for --one-file-system. This skips directories on different file systems
Replace $partition with the complete file path.
# du -h --max-depth=1 -x /usr | sort -hr
From the output above you could see within /usr directory, /usr/share/ is the directory that is using a lot of disk space. You could run the same command once more on /usr/share/ to calculate the details.
# du -h --max-depth=1 -x /usr/share | sort -hr
Once you have determined which directory consumed a lot of the disk space, then you can review individual files and sections of that directory to see if anything is using more space than it should. Often at time, this maybe a log file that has never been cleared, or backups that were forgotten about. You can then perform any necessary actions to have the cause of the increased disk space addressed properly.