Converting an ext3 partition to ext4

      No Comments on Converting an ext3 partition to ext4

Mounting an ext3 partition using ext4 fs drivers will usually speed-up your filesystem without actually changing the on-disk structures. Therefore it’s possible to revert to the ext3 driver without any problem. This allows you to easily benefit from delayed allocation (delalloc) and multi-block allocation (mballoc).

Further performance enhancements are possible if you do change the on-disk structure, e.g. by using extents. The downside is that you can’t mount the filesystem any longer with kernel lacking ext4 support and you can’t revert.

To enable ext4 features on an existing ext3 filesystem, invoke:

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

Unfotunately, features like flex_bg and >16TB fs support can only be enabled at format time1.

Your filesystem is now indeed converted to ext4, however, only files that are written after conversion will benefit from ext4 extends. Existing files would have to be rewritten. e4defrag is being developed to take care of this but in now meant for production environments as of now.

A workaround would be to use chattr to rewrite the files using extends. From the archlinux wiki:

find /home -xdev -type f -print0 | xargs -0 chattr +e
find /home -xdev -type d -print0 | xargs -0 chattr +e

It is being recommended though, “to test this command on a small number of files first, and check if everything is going all right. It may also be useful to check the filesystem after conversion.2. Please note their warnings about mercurial repositories and hardlinks in general, too.

[1] https://wiki.archlinux.org/index.php/Ext4#Migrating_files_to_extents
[2] https://ext4.wiki.kernel.org/index.php/Ext4_Howto#Converting_an_ext3_filesystem_to_ext4

Leave a Reply

Your email address will not be published.

This site uses Akismet to reduce spam. Learn how your comment data is processed.