Convert File System from ext3 to ext4

Some time ago ext4 was released and served as a built-in feature in linux kernel mainline. Ext4 provides additional benefits compared to ext3. The next release of Fedora, version 11, will by default use ext4 unless serious regressions occured. In this article I’d give you a general way on converting filesystems from ext3 to ext4.

EXT4 Filesystem Features

Ext4 filesystem has more features and generally gain better performance than ext3, it’s main features include:

* Delayed allocation & mballoc allocator for better on-disk allocation
* Sub-second timestamps
* Space preallocation
* Journal checksumming
* Large (>2T) file support
* Large (>16T) filesystem support
* Defragmentation support

Once you converted your file system to ext4, the fs cannot be mounted as ext3. Note that ext4 may have some bugs so do not use it on productive servers. It’s also recommended that keep your /boot in ext3.

You need to check ext4 is supported and compiled in you current kernel. Otherwise, you need to apply the patch, and re-compile your kernel. I assume that your kernel supports ext4.
Simply follow these steps to convert an existing ext3 file-system to ext4. For example, in order to converting /dev/sdb1 to ext4, you need to type:
# cd /; umount /dev/sdb1
# tune2fs -O extents,uninit_bg,dir_index /dev/sdb1
# fsck -pf /dev/sdb1

Now, all’s OK, just mount it as ext4:

mount -t ext4 /dev/sdb1 /ext4

If you have converted /boot file system , you need to update /boot/grub.conf. Use your favourite editor to open this file, find out current kernel config section and append the following parameter:

Here is sample config:

title        Ubuntu 8.10, kernel
root        (hd0,1)
kernel    /boot/vmlinuz- ro quiet splash rootfstype=ext4
initrd        /boot/initrd.img-

Save and close the file. And run update-grub:
$ update-grub
Next, update your /etc/fstab file so that it can be mounted as ext4 file system by default. And finally, reboot your system:
$ reboot
All’s done, have a nice tour!

Share Button

2 thoughts on “Convert File System from ext3 to ext4

Leave a comment

Your email address will not be published. Required fields are marked *