One command to win 1.2To of free space

- 3 minutes read - 632 words
Tags Linux - Ext4 - Tech


Ext4 partitions reserve 5% of the volume to ensure enough free space is always available. I have tuned my ext4 filesystem to reduce reserved space from 5% to 0.05% to maximise usage on a multi Terabytes volume. For that I use the following command

sudo tune2fs -m 0.05 /dev/vda

I have NAS

I have a personal NAS that I manage myself. No TrueNAS or anything pre-made. I manage it myself on a computer. It’s a Debian based distribution (proxmox to be exact) with hardware RAID drives attached.

I have a big LVM volume with an ext4 partition where I put all my files inside. I have this exact volume for 3-4 years now. It grew whenever I add drives to it. From few TeraBytes it is 24To large now.

I have a monitoring in place to follow its usage. And you guessed it, empty drive space does stay empty very long.

A gauge showing that the cargo volume is full red at 97.2%
A gauge showing that the cargo volume is full red at 97.2%

As I’m not able to grow any Simoleon Tree at my place. I cannot add drive endlessly.

A Sims2 money tree
A Sims2 money tree

I perform some cleaning on a regular basis to try to keep the used space under control. I mostly delete anything not relevant anymore. From Movies files to project dataset I abandoned I can sometimes free multiple Terabytes of data.

Cleaning day

Today was cleaning day. After doing the usual stuff, I go on the recycle bin to permanently delete some dangling files. I do a df on the server to check free space after that and find odd values.

Results of the `df` command showing size=24T, used=20T, Available=2.4T use=90%
Results of the df command showing size=24T, used=20T, Available=2.4T use=90%

Who did steal my 1.2To ?

I check with a reliable calculator (my brain isn’t) and yes: 24-20=4 not 2.4. I know there is always some loss in filesystem to hold for maps, journals, or whatnot. But 1.6To seems excessive.

After some search on the great library of Internet, I found that ext4 filesystem, by default, reserve a small portion of any partition made to ensure there is always free space on a volume.

This seems at the utmost importance for system partitions because no space mean no shell. Believe me, I’m old enough to have worked on ancient system that did not have any protection in this regard, and it was a real challenge to get a shell on those computers. (considering you do not have physical access to it, of course)

Another usage of this reserved space is to fight against fragmentation. As I’m running on HardDrive and not SSD, Fragmentation is still a thing I need to consider. My volume is for cold storage mostly. I have some hot files that change a lot, but they represent a minimal amount of the total data on the drives. Fragmentation should be low.

Get my terabyte back

As I don’t have a real usage of this reserved space, It is safe for me to remove it or at least reduce it a lot. So let’s go. Simply run the following command and done

sudo tune2fs -m 0.05 /dev/vda

And voilà !

command `sudo tune2fs -m 0.05 /dev/vda` and results of the `df` command showing size=24T, used=20T, Available=3.6T use=86%
command sudo tune2fs -m 0.05 /dev/vda and results of the df command showing size=24T, used=20T, Available=3.6T use=86%
A gauge showing that the cargo volume is not full anymore at 85.1%
A gauge showing that the cargo volume is not full anymore at 85.1%

So what ?

I manage my NAS by hand, and learn with it. Today I learned. Goal achieved.

  • Now there is safety to avoid being locked away from a servers (when you have credentials)
  • Ext4 reserve 5% of a volume and this is not really useful if the volume is not used as root, or fragmentation is not a concern.
  • e4defrag exist and can be used to report on fragmentation and de-fragment a volume, but is really really really long.

Thanks reading me,
Bisoux 😗

Although commenting is not an option on this blog, I am open to discussing this topic further on various social media platforms. You can follow those links to find me
  • Published at
  • Last modified on
  • Available translation : Français
  • Published in : Linux - Ext4 - Tech
  • Except for quoted materials, which keep their original rights and attributions, post and its content published under the Creative Commons(CC BY-NC-SA 4.0) liscence
  • Found a typo, or something bigger that probably killed a grammar nazy ? suggest a fix via github.
  • You can subscribe via RSS icon RSS to get new articles as son as they are published