How to migrate Ext2 or Ext3 file systems to Ext4 on Linux

Do you know you should upgrade your Linux filesystem but can’t face the worsening? How to convert ext2 and ext3 to ext4 without having to do a complete new installation.

Linux file systems

If you were polite you would call that ext3 file system venerable, market launch as in 2001 poor dude ext2 , this filesystem dates back to 1993 and there is no other word for it than ancient. Computationally, ext3 is an antique. And ext2 is an archaeological find.

The modern file system in the Linux world is ext4, that was published in 2008 . It’s faster, less prone to fragmentation, can handle larger file systems – and larger files -, has more accurate file date stamps, and did we mention it’s faster? Much faster.

OK, I’m sold – let’s do this

Let’s think this through. In fact, you probably don’t want to upgrade your filesystem.

It makes more sense to upgrade your entire Linux system instead. By upgrade, we mean doing some backups, wiping your system, reinstalling a modern distribution, and restoring your data. Go for the full update. Take advantage of a modern Linux distribution with updated software and a clean, up-to-date and newly installed file system.

If you can’t run modern Linux on your hardware, even one of the lightweight distributions is like Lubuntu , LinuxLite or CrunchBang ++ , and be sure to stick with the Linux you have, there are still caveats.

To upgrade your filesystem to ext4, you must be using kernel version 2.6.28 or higher. So if you don’t have this version of the kernel or a later version, you will need to upgrade your kernel first.

warning : Don’t even think about trying this without meeting the kernel version requirements. You will end up with an unbootable computer. Check which version of the kernel you are using before proceeding.

Make sure you have an installation disk for the version of Linux you are currently using and keep it on standby. Updating your file system is not safe.

Backups are your safety net. Before you do anything, make some backups of your data on various backup media and make sure you have the old Linux installation disk on hand. If something goes wrong, you can reinstall your old Linux and get your data back.

You will also need an up-to-date live CD / DVD from a modern Linux distribution to perform the file system upgrade. So make sure you have one of these on hand too.

Incidentally, this article was researched using an installation by Ubuntu Jaunty Jackalope that was published in April 2009. Ext3 was used as the file system.

Still with us?

John Wayne said Courage was frightened but saddled anyway. I admire your courage.

The first thing we do is check the kernel version uname . the uname Command can display various types of system information.

On your old Linux computer, open a terminal window and enter the following command. Type uname , a space, -r , then hit Enter.

                      uname -r

The Linux version on this machine is using kernel version 2.6.28-11 so we met the kernel version requirements.

Seriously, if you don’t meet this requirement, stop now. Close enough is just not enough. They must meet or exceed this kernel version number.

Now let’s check the hard drive IDs with blkid that identifies the block devices in the system.


This system has a single hard drive (sda) that has a filesystem (sda1) mounted on / dev / sda1. This is an ext3 filesystem. This is the file system we are going to convert.

There is also a filesystem called swap, but we don’t care.

Restart with the live CD

Insert the Live CD and restart your computer. You may have to press a key during the restart to get the computer to boot from the CD. The key to press is displayed during the early stages of the boot process. Be quick – the window of opportunity doesn’t last long. If you miss it, restart and try again.

Once you’ve booted into the Live CD environment, make sure you don’t accidentally start an installation. Take the time to read the options that are provided to you, and if there is one that says something similar to “try distribution name”, select that option.

Become a root

Open a terminal window and enter the following command. This effectively makes you root and means you don’t have to type sudo before each command.

                      sudo bash

Notice that the prompt has changed. You are root. Step cautiously.

Identify the file systems

We need to identify the file systems again to see how they appear in this Linux instance.

                      fdisk -l

You will see output similar to the following.

The file system previously identified as sda1 was found and recognized by the Linux Live CD. This is the first mini milestone.

The second is file system conversion.

Convert the file system

Here are two commands listed, one to convert Ext2 to Ext4 and one to convert Ext3 to Ext4. Make sure you are using the right one for you!

To convert from ext2 to ext4 use:

                      tune2fs -O extents,uninit_bg,dir_index,has_journal /dev/sda1

To convert from ext3 to ext4 use:

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

It’s a little disappointing as not much seems to be happening. You are returned to the command prompt. If you see any output, it is most likely error messages. So no news is good news here.

Check the file system

Even if no errors were reported, let’s go through it carefully and check the entire filesystem for problems. We are using a command called e2fsck . This is a tool for checking the File System Integrity . It can also try to fix any problems it finds. the e2fsck Tool works with ext2, ext3 and also ext4 file systems.

the -p (preen) option causes e2fsck to try to repair errors and the -f (force) option causes e2fsck to check the file system even if the file system appears clean.

                      e2fsck -pf /dev/sda1

No errors were reported. We can now try to mount the filesystem.

Assembling the file system

We need to adjust the filesystem table (fstab) and the grub boot loader to work with the converted filesystem. To do this, we need to mount the filesystem. We’re going to mount it on / mnt. We previously identified the filesystem as sda1, so our command is:

                      mount -t ext4 /dev/sda1 /mnt

Now that it’s mounted we should be able to list the filesystem. Let’s check that out. The root directory of the file system is at the mount point / mnt.

                      ls /mnt

That’s encouraging. It looks like we are expecting it.

How to mount and disconnect storage devices from the Linux terminal

Editing fstab

We need to edit the fstab file and change all references from ext3 (or ext2 if that’s the filesystem you were converting from) to ext4.

The live CD used for this example has the nano Editor on it. It’s a simple little editor so we’ll be using it. if nano is not available on your Live CD, there is a different editor bundled on the CD from the Linux distribution.

                      nano /mnt/etc/fstab

the nano Editor window appears. You have to search for occurrences of the string “ext3” or “ext2” and change them to “ext4”. In this example, there was an occurrence of ext3 that is highlighted.

Nano window with ext3 highlighted

The ext3 was replaced by ext4.

Nano window with ext4 highlighted

You need to save the file and exit the editor. In nano Ctrl + O saves the file and Ctrl + X will close the editor.

Update grub

Since we mounted the sda1 file system on / mnt, the paths to the directories in the file system were practically all moved one level lower than usual. Because of this, the path we specified for nano was / mnt / etc / fstab instead of the usual / etc / fstab.

Since Grub expects to find things in certain places, we need to make the filesystem look like it is normally mounted. We need the root directory of the filesystem under / and not under / mnt. The chroot command allows us to run a command shell and specify the root point we want to use.

The command we used is:

                      chroot /mnt

Notice that the prompt has changed.

We can do that now update-grub Command to have Grub read the fstab file and reconfigure itself.



After Grub has reconfigured itself, we need to install a new Grub instance on the hard drive. Note that this is the sda ​​hard drive, not the sda1 file system. Don’t enter “1”, just enter “sda”.

                      grub-install /dev/sda

Reboot your Linux

Reboot your system and remove the live CD. When your system has restarted, open a terminal window and enter the following command:


As we can see, the filesystem is now an ext4 filesystem.

It took so long (over ten minutes) to restart the computer on which this article was researched that it was assumed that something had gone wrong and that it would never start again.

Maybe it was because it was a virtual machine, or maybe some of the filesystem conversion takes place during the initial boot. Either way, patience triumphed and eventually reappeared. If your device does something similar, wait and see. It may be that all is not lost.

Subsequent restarts went quickly as usual.

Instead, update your Linux

Well we got there. But you still have a non-standard hybrid that uses an old version of Linux on a modern filesystem.

If switching to a new file system is important to you and your hardware can take it, switching to an up-to-date Linux distribution is the best way forward. You enjoy all the other security and software advantages that result from it.

If there’s nothing else – and sometimes we don’t have the options we would have liked – you can use these steps to update your filesystem.

Related Posts