Clare Bonthrone Clare Bonthrone -4 years ago 181
Linux Question

How to free up space on centos server

I'm getting daily warning that my VPS server space is getting full. I have deleted old kernals, cleaned up install files and reduced the amount of backup stored. I'm not really sure what else I can delete?

I run the command:

du --max-depth=1 -h /

0 /dev
16K /lost+found
1.6G /var
75M /opt
89M /run
2.8G /backup
38M /etc
4.0K /cd
4.0K /srv
4.0K /media
7.4G /usr
2.6M /tmp
0 /sys
179M /boot
61M /root
4.0K /mnt
149G /home

I also run the command:

df -l

Filesystem 1K-blocks Used Available Use% Mounted on
/dev/mapper/centos-root 49066108 43581052 3396348 93% /
devtmpfs 2009504 0 2009504 0% /dev
tmpfs 2019500 0 2019500 0% /dev/shm
tmpfs 2019500 90696 1928804 5% /run
tmpfs 2019500 0 2019500 0% /sys/fs/cgroup
/dev/sda1 463826 185067 250292 43% /boot
/dev/loop0 1948752 5624 1842472 1% /tmp
tmpfs 403900 0 403900 0% /run/user/0

I have about 10 websites running on this VPS and I also deleted any backups stored within their respective accounts. Is there anything else here I can get rid of that I don't need?

Answer Source

After a bit of search here I found an answer from How do I clear space on my main system drive on a Linux CentOS system? that worked for me:

If you just want to look for big files and delete those then you could also use find

find / -type f -size +100M
would search for files only (-type f) with a size > 100MB (-size +100M)

subsequently you could use the same command to delete them.

find / -type f -size +100M -exec rm \{\} \;

-exec executes a program which gets passed the file or folder it has found ( {} ), needs to be terminated with \;

don't forget you could add -i to rm to approve or disapprove a deletion.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download