Hund

How to save disk space by changing the reserved blocks for Ext-filesystems

May 28, 2020

By default the Extended-filesystem, more known as Ext2/4, reserves 5% of the filesystem blocks on the filesystem for privileged processes. It’s done to avoid filesystem fragmentation and to allow system daemons to continue to function correctly after non-privileged processes are prevented from writing to the filesystem due to a full filesystem.

It’s a great feature for system critical filesystems, but if you have a storage disk you usually don’t need that feature at all. And if you have a large system disk you could probably lower the value a bit, but that’s for you to decide.

An example with my storage disk

I have turned off the reserved blocks on my storage disk and as you can see below it does make a noticeable difference on a larger filesystem.

Before

$ df -h

Filesystem      Size  Used Avail Use% Mounted on
[...]
/dev/sdb1       3.6T  1.9T  1.6T  55% /mnt/hdd0

After

$ df -h

Filesystem      Size  Used Avail Use% Mounted on
[...]
/dev/sdb1       3.6T  1.9T  1.8T  52% /mnt/hdd0

Instructions

Start by checking the amount of reserved block count you have on the disk:

# tune2fs -l /dev/sdb1  | grep 'reserved block count'

Reserved block count:     48837696

If you don’t know what your device names is you can list them with the command fdisk -l as a privileged user. In my case the device name was sdb1.

To change the value we are going to use the tool tune2fs. In this example I changed the value to 0 (zero) with the flag -m0:

# tune2fs -m0  /dev/sdb1

tune2fs 1.45.5 (07-Jan-2020
Setting reserved blocks percentage to 0% (0 blocks)

You can then double check to see if it worked:

# tune2fs -l /dev/sdb1  | grep 'reserved block count'

Reserved block count:     0

Meta

No Comments

Use the e-mail form, if you wish to leave feedback for this post. Markdown is supported. [Terms of service]