Take the 2-minute tour ×
Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems.. It's 100% free, no registration required.

I understand that by default, newly created filesystems will be created with 5% of the space allocated for root. I also know you can change the defined space with:

tune2fs -m 1 /dev/sdXY

What I'm curious about though, is what the actual purpose for this reserved space is. Does it serve any practical purpose which would merit more than 5% space in some circumstances?

The reason I've stumbled upon this question is that we recently built a 1TB filestore, and couldn't quite figure out why a df -h left us missing 5% of our capacity.

share|improve this question
    
Okay, now that's a massive waste of 'unavailable' space. Maybe the 5% should be limited to drive sizes smaller than X (e.g. 5% of disk space to a maximum of 100MB). –  Tshepang Feb 24 '11 at 11:44
    
On my 8 TB filesystem 400 GB just gone away - this is the real waste of space!! :) –  Ilia Rostovtsev Mar 27 '13 at 17:38

4 Answers 4

up vote 41 down vote accepted

Saving space for important root processes (and possible rescue actions) is one reason.

But there's another. Ext3 is pretty good at avoiding filesystem fragmentation, but once you get above about 95% full, that behavior falls off the cliff, and suddenly filesystem performance becomes a mess. So leaving 5% reserved gives you a buffer against this.

Ext4 should be better at this, as explained by Linux filesystem developer/guru Theodore Ts'o:

If you set the reserved block count to zero, it won't affect performance much except if you run for long periods of time (with lots of file creates and deletes) while the filesystem is almost full (i.e., say above 95%), at which point you'll be subject to fragmentation problems. Ext4's multi-block allocator is much more fragmentation resistant, because it tries much harder to find contiguous blocks, so even if you don't enable the other ext4 features, you'll see better results simply mounting an ext3 filesystem using ext4 before the filesystem gets completely full.

If you are just using the filesystem for long-term archive, where files aren't changing very often (i.e., a huge mp3 or video store), it obviously won't matter.

share|improve this answer

The default of 5% is meant for system partitions. 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 special needs, you can change the user that gets the emergency space.

There's another reason to not allow an ext[234] filesystem to get full, which is fragmentation.

share|improve this answer
    
"For special needs, you can change the user that gets the emergency space." -- How? –  user4514 Jan 6 at 16:08
    
@user4514 tune2fs -u 1234 –  Gilles Jan 6 at 16:29

With the blocks reserved your users, and services that are running as specific users rather than running as root, can not fill a filesystsem and potentially break other things that need to write to said filesystem - though services running as root still can still make it completely full of course.

It also give you some space to work with when users complain that the disk is full, or services start failing because the filesystem is full. For instance you could archive some files off into zip/gz/7zip archives before removing them (though if the filesystem were completely full, chances are you have some other filesystem available that you could create the archive file in instead).

5% has been the default for a long time, from back when disks were far smaller (tens of megabytes rather then hundreds of gigabytes) so 5% wasn't all that much. Luckily it can easily be tuned down to a smaller percentage as you say, or set to a specific number of blocks if you use tune2fs's -r option instead of -m. In both cases you can give a parameter of 0 to turn the reservation off completely - I wouldn't do this for /, /tmp, /var and so forth, but you might want to for a filesystem that only acts as user storage (say a global file-share) or one that just holds fixed size files (like fixed sized VMs) that will only grow when you create a new one.

share|improve this answer

If you allow others to log on to your system, via ssh, for example, having these 5% blocks reserved ensures external users cannot fill the disk. Even if you don't allow others to log in to your system, the reserved blocks prevents programs not running as root from filling your disk.

share|improve this answer
    
Thanks for this, genuinely struggled with which answer to mark as correct - answer upvoted as it was first and spot on, mattdm's marked as correct due to the additional background and detail which helped me understand the "Why" more. –  foxed Feb 24 '11 at 16:35

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.