How much space to reserve on ext3 filesystem to prevent fragmentation issues

ext2ext3

I wondered about some missing space on my ext3 partition and, after some googling, found that debian based ubuntu reserves 5% of the size for root.

I also found posts describing how to change that size via tune2fs utility.

Now I've got 2 questions, that I didn't find clear answers for:

  • should I unmount the partition before changing the reserved space. what could happen if I don't?

  • how much space should I reserve for the filesystem, so that it can operate efficiently?

Thank you!

Best Answer

You don't need to unmount the partition prior to doing this. Regarding question two, it depends. As HDDs have grown in size, so has the total amount of disk space that's reserved for root. If you have a 2 TB HDD and it's totally used for /, then I would say you could quite safely tune it down to 1% by doing this:

$ sudo tune2fs -m 1 /dev/sda*X*

A smaller drive in the region of 320 GB I'd probably leave as is.

Keep in mind that drives that are for data storage purposes don't really need all this space reserved for root. In this case you can change the number of reserved blocks like this:

$ sudo tune2fs -r 20000 /dev/sdb*X*

Hope that helps.

EDIT: Regarding fragmentation issues, ext file systems are inherently immune to fragmentation issues. To quote Theodore Ts'o:

If you set the reserved block count to zero, it won't affect performance much except if you run for long periods of time (with lots of file creates and deletes) while the filesystem is almost full (i.e., say above 95%), at which point you'll be subject to fragmentation problems. Ext4's multi-block allocator is much more fragmentation resistant, because it tries much harder to find contiguous blocks, so even if you don't enable the other ext4 features, you'll see better results simply mounting an ext3 filesystem using ext4 before the filesystem gets completely full.