Reclaim reserved disk space XEN/KVM/VMWare/Dedicated

Joe Dougherty from (great guy running a great company) sent me a tip about this thread over at and asked if I could write something about this “weird trick”. Actually it’s not a wierd trick, it’s a built in security feature. The information in this post will only work on dedicated servers or Virtual Servers that utilize full virtualization, meaning that this won’t work on OpenVZ.

On a newly created filesystems (Ext [2/3/4]) some of the space will be allocated for the system superuser (root) as “system reserved”. The default of 5% is meant for system partitions. If something goes wrong and your server consumes all its free disk space, the root user could still log in and check logs/crashdumps/etc and generally fix the situation.

For example, if your disk space fills up, the system logs (/var/log) and root’s mailbox (/var/mail/root) can still receive important information. For a /home or general data storage partition, there’s no need to leave any space for root. For very special needs, you can even change the user that gets this emergency space.

There’s another reason to not allow an ext[23] filesystem to get full, which is fragmentation. Ext4 should be better at this, as explained by Linux filesystem developer/guru Theodore Ts’o:

If you have a VPS with small disk size the 5% won’t mean much but if you have a 100GB drive or bigger, it quickly adds up to a vaste amount of unused space. In those cases we could lower the amount of reserved space in order to claim and use a few more GB.

I actually have a unused XEN VPS so lets have a look at what we can do about this by using that as a real life example.

first we confirm the filesystem parameters by running this command:

it will list all information about the disk. This is the output I got from my server:

The ineresting part from the output above:

Before we move on to the amount of reserved space, take a moment to reflect on what user who is allowed to use the reserved space. By default it is root unless changed by the system administrator.

if you multiply the Reserved Block Count with the current Block Size (also found in the tune2fs output above)

we get how much space in bytes that is reserved by the system:

Doing the same operation using the Block Count value:

will give you the Total Disk space of the drive

As you can see (7,5GB out of 150GB) exactly 5% of the disk is reserved space. As previously mentioned, if you don’t have a large disk it would be wise to not change that 5% value since it could mean that you wont have enough “system reserved space” to recover from a full disk problem.

In my case, 7,5 GB of reserved space is a bit much and I would benefit if this was available for me to store my backups instead. So, how do we change the amount of reserved space?

Since my disk is in total 150GB each percentage is 1,5GB and I think that 1,5GB will be enough for this server, the command to set the reserved space to 1 percent would therefor look like this:

The returned result :

Keeping in mind that each block is 4096 bytes the above result means the reserved space is: 393216 * 4096 = 1,5 GB

Before you jump of joy I would like to end this article with a few words of caution;

While this is a nice way to get some extra space on your server TAKE EXTREME CARE if you decide to change the settings on the drive that has the / volume or you could end up with a server that even root can’t save when the disk runs out of space. If you have a secondary drive that only holds data, may it be your mp3 collection or family photos, you can set the reserved space to 0percent on that drive. As long as it is NOT the system drive.


Leave a Reply

Your email address will not be published. Required fields are marked *