Reserved space for root on a filesystem – why?

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.

Asked By: suitedupgeek

||

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.

Answered By: LawrenceC

With the blocks reserved your users, and services that are running as specific users rather than running as root, can not fill a filesystem 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.

Answered By: David Spillett

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.

Answered By: mattdm

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 (tune2fs -u 1234).

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

It’s very useful and I don’t think it should be reduced as disks get larger, because the need for space to handle them (backups etc.) scales at roughly the same rate. If you’re at 95% of your disk space you need a new disk anyway… this traditional safety buffer makes perfectly good sense.

Answered By: Simon
Categories: Answers Tags: , ,
Answers are sorted by their score. The answer accepted by the question owner as the best is marked with
at the top-right corner.