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 know that this feature dates back 20 years but I still would like to find out

What is the purpose of the reserved blocks in ext2/3/4 filesystems?

share|improve this question
add comment

3 Answers 3

up vote 11 down vote accepted

The man page of tune2fs gives you an explanation:

Reserving some number of filesystem blocks for use by privileged processes is done to avoid filesystem fragmentation, and to allow system daemons, such as syslogd(8), to continue to function correctly after non-privileged processes are prevented from writing to the filesystem.

It also acts as a failsafe; if for some reason the normal users and their programs fill up the disk up to 100%, you might not even be able to login and/or sync files before deleting them. By reserving some blocks to root, the system ensures you can always correct the situation.

In practice, 5% is an old default and may be too much if your hard drive is big enough. You can change that value using the previously mentioned tune2fs tool, but be sure to read its man page first!

share|improve this answer
    
+1 for the "5% may be too much". On a 2 TB disk that means 100GB are reserved for root. –  bahamat Jun 19 '12 at 18:08
add comment

Part of the purpose of reserve % is to allow "empty pockets" to exist between files to help prevent fragmentation. Modifying a file later won't necessarily force the file to be broken into fragments because something was parked right at the tail of the file when originally written.

There is also the emergency recovery aspect where root needs to be able to log in and clean things up because something went amiss and filled up the drive (be it user or malconfigured program).

Appropriate reserve percentages depend kind of heavily on the partition's use case. If the partition is an OS disk, then 5-10% reserve for root seems completely reasonable, even for very large partitions. For user-data partitions, there is often no need for any reserve, except maybe to help with preventing fragmentation.

share|improve this answer
add comment

The purpose of reserving a small number of blocks for root's use only is to give root a chance to log in and give them a little bit of breathing room to make space in case the disk becomes completely full. Without it, root could be prevented from logging in because the login process fails when it gets unexpected errors writing files (like utmp and wtmp, files in /dev/pts, etc...). One could hope that the login process is robust and will work even with a full disk, but disk full errors during the login process is probably usually a less well tested code path.

Nowadays, of course, even a small percentage of blocks represents way more space than is necessary for this purpose!

share|improve this answer
add comment

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.