How To Upgrade From Ext3 To Ext4 Without Formatting The Hard Disk

Yesterday, we have discussed some of the new features in Ubuntu 9.04 Jaunty. In that article, I did mention that the new filesystem – ext4 is stable, fast and backward compatible with ext2 and ext3. Today, we will look at how you can upgrade your existing ext3 filesystem to ext4 without reformating your hard disk.

Disclaimer: Anything that deals with the filesystem hack always involve certain risks. While we have tested it out and get it working on our systems, there is no guarantee that it will work for you. We shall not be responsible for any data loss or hard disk crash. Before you try this, please remember to BACKUP your system and important files.

Step 1: Upgrade your existing Ubuntu

First for all, upgrade your existing Ubuntu to Ubuntu 9.04. You can skip this step if you have already upgraded to Ubuntu 9.04.

Press Alt + F2 on your keyboard and type in

update-manager -d

The Update Manager will appear. Click on the Upgrade button.

dist-upgrade

Depending on your Internet connection, the upgrade could last for several hours.

At the same time, proceed to Ubuntu website and download the Ubuntu 9.04 LiveCD iso.

After you have downloaded the LiveCD, burn it into a CD or use the USB Startup Disk Creator (System -> Administration -> USB Startup Disk Creator) to create a bootable USB drive.

Once the system completes the upgrading, restart your computer and play around with it to make sure that it is working fine in your system.

When you are happy with the result, reboot the computer again, this time boot into your LiveCD.

Step 2: Upgrading to Ext4

Go to System->Partition Editor. This will show all the partition in your hard disk. Record down the filesystem ID of the partition that you want to convert to ext4.

gparted

Close the Partition Editor. Open a terminal, type the following:

sudo tune2fs -O extents,uninit_bg,dir_index /dev/XXXX

Replace XXXX by the filesystem ID that you have recorded just now.

Once that is done, type the following to fixed your partition:

sudo fsck -pf /dev/XXXX

Don’t forget to replace XXXX with your filesystem ID.

Mount your filesystem

sudo mount -t ext4 /dev/XXXX /mnt

Open the fstab file:

gksu gedit /mnt/etc/fstab

and change the ext3 entry to ext4. Save and exit.

edit fstab

Back to the terminal, we need to reinstall the grub bootloader.

sudo grub-install /dev/XXX

This time, replace the XXX by the filesystem without the number. For example, sudo grub-install /dev/sda

Close the terminal and restart the computer. Reboot into ubuntu 9.04.

In the terminal, type

df -T

You should see your filesystem mounted as ext4 now

check filesystem type

That’s all. Enjoy!