Skip to content

Change ext3’s reserved block count and gain Gigabytes

Wiebe was looking over my shoulder while I was running df to check the disk space that was still available on my Lenovo ThinkPad:

# df -h /dev/sda2
Filesystem            Size  Used Avail Use% Mounted on
/dev/sda2              90G   79G  7.3G  92% /

He noticed that there was a huge gap between the total space (79 used + 7.3 available = 88.3) and the actual size of the file system. According to him this was due to the reserved block count, which is set to five percent by default in ext2 and ext3 file systems—clearly a legacy from a time where disks were smaller.

# dumpe2fs /dev/sda2|grep -i 'reserved block count'
dumpe2fs 1.40.8 (13-Mar-2008)
Reserved block count:     1196559

# dumpe2fs /dev/sda2|grep 'Block count'
dumpe2fs 1.40.8 (13-Mar-2008)
Block count:              23931180

# echo 'scale = 2; 1196559 / 23931180'|bc
.05

I changed the reserved block count with tune2fs:

# tune2fs -m 1 /dev/sda2
tune2fs 1.40.8 (13-Mar-2008)
Setting reserved blocks percentage to 1% (239311 blocks)
# dumpe2fs /dev/sda2|grep -i 'reserved block count'
dumpe2fs 1.40.8 (13-Mar-2008)
Reserved block count:     239311
# df -h /dev/sda2
Filesystem            Size  Used Avail Use% Mounted on
/dev/sda2              90G   79G   11G  88% /

Now, the reserved blocks take up roughly 934 MiB; I’ve freed 3.7 GiB with this little file system tweak. 🙂

Update 14 nov 2010: I finally fixed two errors in my final calculations spotted by Den. He noticed that the numbers (700 MiB and 13 GiB) were wrong. Thanks, Den!


    5 Comments ( Add comment / trackback )

    1. (permalink)
      Comment by ml
      On July 31, 2009 at 09:27

      This helped me to get the current % of reserved blocks.

      Thank You

    2. (permalink)
      Comment by den
      On February 5, 2010 at 01:04

      Very helpful, thanks. But the numbers in your closing remark are well off. Your reserve is 934 MiB and you freed 3.7 GiB.

      May God Bless.

    3. (permalink)
      Comment by Rowan Rodrik
      On November 14, 2010 at 17:53

      Hi Den,

      I never properly thanked you for your corrections, so thank you! I’ve updated the numbers in my post.

      God bless you!

    4. (permalink)
      Comment by Jens Rantil
      On July 29, 2014 at 21:16

      > clearly a legacy from a time where disks were smaller

      This is not true. The limit is there for two reasons: For root partitions you generally want to allow some slack to the root user. This can be really killer when you run out of disk space and can’t log in because, say, sshd needs some little temporary file to run. However, the root reason is not why your need _5%_ percent. 0.5% would do.

      The second, and more important, reason is because once you go above ~85% disk usage, fragmentation starts to hurt you badly and write and read latencies will stagger (partially depending on disk type). This will hurt, even on a desktop computer. To keep the computer performant the reserved block limit was put in place. It’s still equally valid today as it was when the limit was set.

      Now you know,
      Jens

    5. (permalink)
      Comment by Rowan Rodrik
      On July 31, 2014 at 14:37

      Thanks, Jens! Very illuminating! 🙂