Disk space - not being released?

  • Posted September 28, 2017
  • 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?

Submit an answer
You can type!ref in this text area to quickly search our full set of tutorials, documentation & marketplace offerings and insert the link!

These answers are provided by our Community. If you find them useful, show some love by clicking the heart. If you run into issues leave a comment, or add your own answer to help others.

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.