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

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:

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

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

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

Mount your filesystem

Open the fstab file:

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

edit fstab

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

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

You should see your filesystem mounted as ext4 now

check filesystem type

That’s all. Enjoy!

32 comments

  1. As a disclaimer maybe you’d add that ext4 is ready in general but many user-land applications are not ready for ext4 yet.

    • Yes, but he does tell you to use a live-cd, so the drive isn’t mounted in the first place.

      • Crap. I did it, and didn’t read the ‘use LiveCD’ part, because it was in the same step as upgrading to 9.04, which I already did, and just assumed that I should fsck it anyways, despite the warning. I was able to boot into ubuntu after a few tries, but stuff is acting weird. I might as well reinstall fresh… >_>

        I know it is completely my fault for not reading directions fully, but I think you should make the notice you need to use a LiveCD a little more prevalent for idiots like me. :P Otherwise, the article was well written. All things considered, at least I learned a lesson. :)

        djsonik

  2. Just don’t use ext4 yet. It’s considered stable, but really is not. There is a risk of data loss currently.

  3. Nice guide! Only it ruined my /home partition. I can now boot, but when I log in, it gives some error about /home/jarik (jarik is login name) not available or something, en then I click Yes or No. One of them will log me in, but only a blue screen appears (Blue is the color setting of the login screen) and nothing happens.
    I have followed all steps, exept for the gksu gedit /mnt/etc/fstab because that file was somehow empty :O
    I got a dual boot Vista/Ubuntu 9.04. Vista is on C:\ (sda1) I’ve got a second harddrive D:\ (sdb) for Data and an HP_recovery (E:\ or sda2).
    Ubuntu is installed on my external harddrive (sdc) and has got an NTFS partition for Windows (250GB sdc1 ) a swapfile for Linux (2GB sdc3) and \home partition (which is screwed up, 50GB sdc2) and of course where ubuntu is installed (8GB sdc5)
    And somehow there’s a sdc4 linking to sdc5 (it has always been there)

    Can anyone help me getting my account back on plz?
    Luckily I decided to backup most important data to my DATA drive :D
    If there’s anything I can do for you to help me better, just ask me.

  4. Nice guide! Only it ruined my /home partition. I can now boot, but when I log in, it gives some error about /home/jarik (jarik is login name) not available or something, en then I click Yes or No. One of them will log me in, but only a blue screen appears (Blue is the color setting of the login screen) and nothing happens.
    I have followed all steps, exept for the gksu gedit /mnt/etc/fstab because that file was somehow empty :O
    I got a dual boot Vista/Ubuntu 9.04. Vista is on C: (sda1) I’ve got a second harddrive D: (sdb) for Data and an HP_recovery (E: or sda2).
    Ubuntu is installed on my external harddrive (sdc) and has got an NTFS partition for Windows (250GB sdc1 ) a swapfile for Linux (2GB sdc3) and home partition (which is screwed up, 50GB sdc2) and of course where ubuntu is installed (8GB sdc5)
    And somehow there’s a sdc4 linking to sdc5 (it has always been there)

    Can anyone help me getting my account back on plz?
    Luckily I decided to backup most important data to my DATA drive :D
    If there’s anything I can do for you to help me better, just ask me.

    • Your situation is a bit more complicated, because you have plenty of partition.

      My suggestion:

      Boot into LiveCD.

      Open a terminal, (assuming your sdc5 is the filesystem folder and is in ext3 format)

      sudo mount -t ext3 /dev/sdc5 /mnt

      gksu gedit /mnt/etc/fstab

      and change the ext3 entry to ext4 (only for the /home partition). Save and exit.

      Reboot the computer.

  5. This screwed up my /home partition. I did everything exept for the grub install and ‘gksu gedit /mnt/etc/fstab’. fstab was empty somehow, so I couln’t edit that.
    I converted my /home partition and my installation partition to ext4.
    If there’s anything I can do to help you help me better, plz ask me!

  6. Ok, my problem is solved now. I’m running Ubuntu 9.04 on Ext4 :D
    I actually figured it out myself by trying gksu gedit /mnt/etc/fstab again, and this time it did show the file I should have editted in the first place.
    Thank you for the help :D
    Great guide, but should have been a bit more clear on part when you should insert the LiveCD.

  7. I upgraded my / and /home partitions successfully. Hovewer, I had an error when reinstalling grub with the suggested command (sudo grub-install /dev/XXX). Grub complained about not finding the /boot directory corresponding to that partition. To circumvent the error, I used:

    sudo grub-install –root-directory=/mnt /dev/XXX

    • Thanks a lot Carlos.. that tip help me a lot… I feel like @djsonik… I feel so stupid because I don’t read carefully this great post…

      Muchas gracias, espero que me entiendas… me había comenzado a preocupar cuando me apareció ese problema con el boot…

    • Thank you for the How-to Damien.
      I had the error described by Carlos with ubuntu 9.04 installed on ext3 that I wanted to upgrade to ext4.

      @Carlos: thank you for your tip that solved my problem but the correct command is not “sudo grub-install –root-directory=/mnt /dev/XXX” but “sudo grub-install –root-directory=/mnt /dev/XXX”

  8. Excuse my bad English…

    Work 99% on my laptop with jaunty. Just when is necessary reinstall grub, the command return something like no drive, or not bios, something like that, but i type the Carlos command and reboot…

    Im happy now with ext4 and my data is safe, thanks for the tutorial.

    Too many thanks from Chile

  9. But, how would one go to convert his ‘/’ partition (that he setup as ext4 when installing Jaunty), BACK to ext3 without losing data, or the OS in general?

    I have my /home as ext3 (from previous hardy installation) and when I installed jaunty I setup / as ext4, but the system is very very unstable, and I’m thinking that is the issue.

  10. Kernel 2.6.28 in Jaunty seems to be unstable on a lot of systems. I reinstalled my system with ext3 cause I though ext4 made it unstable, but it was the kernel. Now I’m running 2.6.17 instead of 28 and it’s working fine (with ext3 though).

  11. Absolutely great guide. However, I should note that if you also want to convert your /home partition, once you mount it and run “gksu gedit /mnt/etc/fstab” you will be greeted with a blank fstab. I recommend you change both your /home and root partition in the fstab to ext4 after mounting the root partition then continue on to converting the /home partition.

  12. Worked for me on the forth attempt, thank you!
    My question is, my root and home are on different partitions, so now I need help converting /home file system to ext4.

Comments are closed.

Sponsored Stories