552 Disk full – Delete unwanted files on CentOs server
552 Disk full – Delete unwanted files on CentOs server
Running out of the storage space is very common problem. If we’ve GUI interface available with then its easy to clean and discard unwanted files but when it happens with our server and you’re not server expert then its a big one then and probably will consume a days for a newbie. Just few days back I had a same issue. My CentOS7 VPS server ran out of the space. I came to know this when one of the team developer reported the “552 Disk full – please upload later (via FTP)” while using filezilla.
Not having any such previous experience of cleaning up the server using terminal access, I logged into my WHM cPanel. Started looking possible. I found two useful section
1) Home »System Health »Show Current Disk Usage
Showing the Current Disk Usage Information. Right now its showing 4.3G available but at that it was full, it was showing only 100MB available. However I could not get much information which part of storage is full.
2) Home »Server Status »Server Information
Showing the various information blocks like
– Processor Information
– Memory Information
– System Information
– Current Memory Usage
– Current Disk Usage
The Block “Current Disk Usage” was useful for me which suggested that “/dev/vda1” was highly used and I need to clean that up. In order to delete unwanted files I need to find the large sized files and folders. It was not providing any such details. Then I googled and I found one command “du”. I used it but did not find that useful. Anothor handy command i found was “ncdu” and it was very useful.
I logged into my server using putty SSH. I changed my current directory to “/” from “/root” and used command
ncdu /
This command gave me the exact summary that I wanted. By this I realized that I’ve setup weekly system-backup and these multiple backups inside “/backup” folders are eating up lot of memory. I deleted all unwanted one using. You may use up and down arrows to traverse and hitting enter will give further drill-down report for that specific folder.
rm -rf file_to_delete
By this i freed up some GBs. At least that “552 Disk full – please upload later (via FTP)” was gone now.
Then I further investigated and found that command “yum” had some cache which I deleted.
rm -rf /var/cache/yum
Then further found if your system is upgraded then may be that old kernals are still there and occupying a lot of space.
By using command
rpm -qa kernel
we can know all kernals and by using command
uname -r
we can get the current kernal being used. Now we need to delete the unwanted kernals. Beware when deleting the kernals. Deleting right one, you may end up crashing the system.
package-cleanup --oldkernels --count=1
The above command will delete all the kernels except the latest one. If you want to be specific then you may use
sudo yum remove kernel-you-want-to-delete
Follow only If you’re using Laravel.
Now if you are using laravel, then its a good practice to clean up your laravel cache. you may do that by deleting all cache files
rm -rf your_laravel_project/storage/framework/cache/data
So eventually by all the above few commands I was able to delete some unwanted files and folders and freed up some space.