Change the size of reserved space on ext4 partitions
By default, when formatting a partition with ext4 (it also applies to ext3 and ext2), a percentage (usually 5%) of the total disk size is set aside and reserved for use by privileged processes and the root user.
This is useful when the root filesystem is full (as this extra space will allow to continue working for awhile), but it’s not really needed for other filesystems other than root. Also, reserving 5% was a good idea when the hard drives were small, but with the size of current hard drives, this amount is a huge waste of space.
Here’s how to fix this:
First, determine the amount of space reserved in your partitiion:
1. Find the partition name
# mount -l | grep ' / ' /dev/xvda1 on / type ext3 (rw,relatime,data=ordered)
2. Get the info of the partition
# tune2fs -l /dev/xvda1 | grep -Ei '(block count|block size)' Block count: 17039360 Reserved block count: 851968 Block size: 4096
The partition size in bytes is: Block count * Block size
The size of reserved space in bytes is: Reserved block count * Block size
Doing the math, you can find that you’re wasting ~3Gb on a partition of ~65 Gb.
To change the size of reserved disk space, use
tunefs -m <percentage> <partition>
In the above example, we reduce the amount of reserved disk space down to 1%:
# tune2fs -m 1 /dev/xvda1 tune2fs 1.42.12 (29-Aug-2014) Setting reserved blocks percentage to 1% (170393 blocks)
With the above command, we recover ~2.5Gb for regular use
Leave a Reply