One command to win 1.2To of free space
TL;DR:
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.
As I’m not able to grow any Simoleon Tree at my place. I cannot add drive endlessly.
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.
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à !
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 😗
- Published at
- Last modified on
- Available translation : Français
- Published in : Linux - Ext4 - Tech
- Except for quoted materials, which retain their original rights and attributions, this post and its content are 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 to get new articles as son as they are published