2011-08-29

HOWTO: change ext3 / ext4 file system reserved block count in Linux

By default, 5% of blocks in ext3 / ext4 filesystems (not sure about others) are reserved for emergency cases and can be used only by root user and privileged processes.
On big volumes the reserved space size can be enormous (e. g. 1000 GiB * 0.05 = 50 GiB).
Fortunately, this can be easily fixed.

First of all, issue one of the following commands (where /dev/sdb2 is your ext3/ext4 partition):
$ sudo dumpe2fs -h /dev/sdb2
or
$ sudo tune2fs -l /dev/sdb2
and check the "Reserved block count" and "Block size" parameters.
By default, "Block size" is 4096 bytes (or 4 KiB).

This can set reserved blocks to 1% (e. g. 10 GiB * 0.01 = 100 MiB):
$ sudo tune2fs -m 1 /dev/sdb2
Or you can set the total number of blocks (e. g. 100000 * 4096 = 409600000 or approx. less than 400 MiB):
$ sudo tune2fs -r 100000 /dev/sdb2
I think, reserve of 500 MiB is usually enough; you can even set the number of reserved blocks to 0 (zero), but it's not recommended.

References:
  1. http://www.lisnichenko.com/articles/ext3-file-system-overhead-disclosed-part-1.html

1 comment:

  1. Крайне полезно! Я думаю, нам многое можно обсудить и поделиться опытом, но в упор не могу найти Ваши контакты :(

    ReplyDelete