11

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?

Karlson
  • 5,875

3 Answers3

17

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!

André Paramés
  • 802
  • 5
  • 12
7

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!

Celada
  • 44,132
0

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.

killermist
  • 1,601