Thursday, 2 July 2009

Upgrading to ext4

Ext4 support has been available as an installation option in Ubuntu Jaunty 9.04 and will be default in Ubuntu Karmic 9.10. I've been using ext4 now for quite a while on my servers (since the alpha releases of Jaunty) as it provides me with some extra benefits:

* fsck'ing a 500GB partition is so much faster - huge improvement!,
* removing entire kernel source trees takes a few seconds (very handy!),
* kernel builds are a little quicker (I've not quantified how much),
* block I/O on large files is quicker.

I've not experienced any problems with ext4; I use it daily to grind out kernels, and the filesystem gets a lot of exercise.

For those with existing ext2 or ext3 based file systems one can upgrade to ext4 using some relatively straight forward steps. Obviously please make sure you do this on an unmounted filesystem! One way of doing this is to boot your machine using a LiveCD and making sure the HDD is not mounted before proceeding...

Upgrading from ext2 to ext3, for example on /dev/sda1, do:

tune2fs -j /dev/sda1

..this basically enables the journal. One can then mount this as an ext3 filesystem.


Upgrading from ext3 to ext4, for example on /dev/sda5, do:

tune2fs -O extents,uninit_bg,dir_index /dev/sda5

Note that this renders the filesystem unmountable as an ext3 filesystem. You have been warned!

After this YOU MUST RUN fsck to fix some tune2fs modified filesystem structures:

e2fsck -fpDC0 /dev/sda5

New files created on this ext4 filesystem will use the extents format, however existing files will not be in extents format, so you won't see much of a speed improvement with existing files.

If you boot off the newly converted ext4 filesystem you need to re-install an ext4 capable version of grub using grub-install. The ext4 support for grub was introduced into Jaunty, thanks to a patch from Quentin Godfroy, and an inode tweak by me, and some help from Colin Watson. Maybe I should write about the fun and games I had in debugging this one day.. :-)

Any how, you may not get any immediate improvement from an ext3 to ext4 upgrade as existing files need to be re-written to get the full advantage of the ext4 extents. But over time with a lot of file activity you should get some improvement. Alternatively, back your data up, re-format to ext4 and restore the data and you get immediate ext4 goodness.

For more information about ext4, I recommend checking out the ext4 wiki.

No comments:

Post a Comment