Disk space - not being released?

September 28, 2017 946 views
MySQL

My MySQL database stopped responding with the following "Got error 28 from storage engine"

df -kh showed that disk space use was 100%

I managed to release some reserved space with the command

tune2fs -m 0 /dev/vda1

I then deleted substantial number of rows from numerous tables and on each table ran 'OPTIMISED TABLE {tableName}'

If I then run a mysql query to calculate the size of the DBs < 13GB

But df -kh still shows 18GB

Filesystem      Size  Used Avail Use% Mounted on
/dev/vda1        20G   18G  2.2G  89% /

1) which is correct? I reckon mySQL count is. So how do I release the space?

1 Answer

In Linux a file isn't deleted until every pointer to the file is removed. So for an example if you have a log file which is currently being written to and has grown to 5GB in size and you delete it, although the file will not be listed in your directory anymore because that pointer was removed, you won't free up the disk space because there is still an active process on your system which has a pointer to the file and is still writing to it.

This is why when you are deleting from active files you want to restart the service in question otherwise all of the pointers won't be removed and the free space won't be reclaimed.

So if you are doing any file level operations to open files you want to restart the service, or stop it before performing them.

Very likely if you get your active services, in this case MySQL, you should reclaim whatever free space you actually have available.

Have another answer? Share your knowledge.