Ext4 file system reserved blocks

Since Red Hat Enterprise Linux 7, XFS is the default file system. However Ext4 filesystem is still widely used because of its high permormance and flexibility such as the ability to shirnk a Ext4 filesystem.

One thing often overlooked about Ext4 filesystem is its reserved blocks. The concept of it is “for the super-user. This avoids fragmentation, and allows root-owned daemons, such as syslogd(8), to continue to function correctly after non-privileged pro‐cesses are prevented from writing to the filesystem” — from man page of mke2fs(8).

The default value is 5% of the filesystem. With large capacity allocated to an Ext4 filesystem nowdays, 5% space could be very significant and a waste of disk space.

If you use an Ext4 filesystem as a long term archive which means files will not be deleted and created very often or as database file location where files are pre-allocated and rarely deleted, it’s better to adjust reserverd percentage of your Ext4 filesystem from the default 5% to a smaller percentage like 1% (or 0.5%, 0.1% if you have a very big partition), or even 0%.

Some examples:

— Make a filesystem with 0% reserved blocks:

# mkfs.ext4 -m 0 /dev/partition

— Check reserved blocks for a filesystem:

# tune2fs -l /dev/partition | grep 'Reserved'

— Change reserved blocks by percentage:

# tune2fs -m 1 /dev/partition
# tune2fs -m 0.1 /dev/partition

— Change reserved blocks by number (10000 blocks)

# tune2fs -r 10000 /dev/partition

— Actual size can be calculated by (block size x num of blocks)

# tune2fs -l /dev/partition | egrep '^Block size:'

References:

  1. Reserved block count for Large Filesystem
  2. How to Choose Your Red Hat Enterprise Linux File System
  3. https://superuser.com/questions/1256074/how-much-space-to-leave-free-on-hdd-or-ssd/
  4. https://wiki.archlinux.org/title/ext4

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s