linux poison RSS
linux poison Email

Tune your ext3 filesystem

All examples use /dev/sda1, but you can change it to whatever you want
tune2fs command can be run on mounted ext3 volumes.


Ext3 has 3 journal modes, Journal, Ordered, and Writeback (slowest to fastest)
All it takes is a command by tune2fs.


Code: tune2fs -o journal_data_writeback /dev/sda1

This added journal_data_writeback to the default ext3 mount options for that partition. So if ext3 is mounted without options saying otherwise, or specifically with the option ‘defaults’ (rebuildfstab adds this), it will use writeback.

To get rid of that option, just add ^ before the option

Code: tune2fs -o ^journal_data_writeback /dev/sda1

Just remember not to have two journal options as default.

Note: the writeback journal is not very reliable and you may lose important data in a power outage. Check the man page of tune2fs for more information.

Reserved blocks percentage

According to the manual, reserved blocks are designed to keep your system from failing when you run out of space. Its reserves space for privileged processes such as daemons that start during init 3 and the reserved space can also prevent the filesystem from fragmenting as it fills up. On large partitions such as 300gb, however, the default 5% reserved space can be 15gb, which is quite a lot of space.

You can use the following command to reduce it to 3%, which is a bit more logical on larger filesystems.

Code: tune2fs -m3 /dev/sda1

Remember, you don’t want to remove the reserved blocks entirely, just reduce it to gain back unused space for unprivileged data.

dir_index: Use hashed b-trees to speed up lookups in large directories.

You can enable it with this command.

Code: tune2fs -O dir_index /dev/sda1

Thats not enough however, you much run e2fsck on the partition with the -D parameter to optimize the directories for dir_index.

To do this, you must unmount it, or remount as read only. If you are using the partition and can’t unmount it, switch to init 1 and run

Code: umount /dev/sda1

This will remount it as read only. You can then proceed to running

Code: fsck -Df /dev/sda1

and then

Code: reboot

fsck timers

Ext3 disk checks are long and usually uneventful. By default ext3 is scheduled for a full disk check quite often (about 32 mounts or a few weeks).

Time dependent fsck flags generally are less reliable, you can reset your CMOS on your bios or a power outage might mess with it. Its just really easy to change the time.

To disable time dependent fscking, you would run something like this:

Code: tune2fs -i0 /dev/sda1

# of mounts is more accurate, so there is no need to change the defaults (32), but if you did, this would be an example for 100 mounts.

Code: tune2fs -c100 /dev/sda1


Anonymous said...


Post a Comment

Related Posts with Thumbnails