Solving Unable to Delete Files due to “disk quota exceeded” Error | Linux
Recently in one of our Linux DB servers we hit the maximum disk usage limit that is one full mount drive was full of data and logs with 100% usage when we do df -kh . We were not able to delete or modify any files there even login was taking long time. We were not able to even rm -rf few files even for removing small files like few MBs in size were giving “Disk Quota Exceeded” error. We solved above problem by finally applying a new way of removing files when system is in disk quota exceeded state. Please follow below steps which worked for us:
1. Search for the largest files and logs which are present and taking up huge space in system. Use below query to find out
find /montedDrive -type f -ls | sort -k 7 -r -n | head -20
Above command will give you top 20 largest sized files in system. you can give up to any number to get more largest files by giving head -30/40/50 etc.
2. Once you have got the files list which you are suppose to delete use below technique to delete them. as if you use rm -rf file name its going to throw disk quota exceeded error.
Let the file be abc_datafile_1_tmp.dbf
do below steps to remove big files :
echo > abc_datafile_1_tmp.dbf
the above command will make the file 1byte or 1kb from some GB’s size.
then use rm -f abc_datafile_1_tmp.dbf to remove it. It will work.
Note: It takes few minutes to show the freed disk space after removing the files. so wait for few minutes before executing df -kh to check the free space.