You are on page 1of 2

I am going to show you how to migrate your ext2 or ext3 partition to ext4.

I want to warn
you that you could lose data by doing this so, following good administrative practices,
back up your data! Once you are certain you have that backup of your data, it’s time to
begin.

Kernel pre-requisite
You must be certain you have a kernel that is at least 2.6.28-11-generic or higher. If not,
do NOT continue on with this. To find out what kernel you are running issue the
commanduname -r. If your kernel is lower thatn 2.6.28-11 stop where you are and close
your browser.
Step 1
The first step is to boot from a Ubuntu Live CD. You do this because you can’t convert a
file system that has been mounted. If you are converting a second drive on your
machine (one that doesn’t contain your OS or your ~/ (home) directory, you can always
just unmount that drive and do this without booting the Live CD.
Step 2:
Now it’s time to convert. We’re going to use /dev/sda1 as an example for converting.
You will want to know the exact name of the drive and/or partition you are wanting to
covert. If you are converting from ext2 to ext4 issue the following commands:
sudo bash tune2fs -O extents,uninit_bg,dir_index,has_journal /dev/sda1
If you are wanting to convert ext3 to ext4 issue the following commands:

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


NOTE: After you enter either of the sudo bash commands you will have to enter your
sudo password.
Step 3:
Regardless of which conversion you are doing you will want to check the drive (or
partition) after the conversion and repair any issues. Do this with the command:

e2fsck -pf /dev/sda1


Step 4:
Now you need to make sure the partition will mount. Do this with the command:

sudo mount -t ext4 /dev/sda1 /mnt


Hopefully you won’t see any errors. You should now see the contents of that drive listed
in the /mnt directory.
Step 5:
It’s time to edit your /etc/fstab file to reflect the change. Open this file up with your
favorite text editor and look for the line that corresponds to the drive/partition you just
changed. In that line you will reference to either ext2 or ext3. Change that reference to
ext4. Save and close that file.
Step 6:
Now you need to refresh grub. Depending upon how your boot partition is will determine
how you do this. If your boot partition is SEPARATE, do the following:

sudo bash mkdir /mnt/boot mount /dev/sda1 /mnt/boot grub-install /dev/sda


--root-directory=/mnt --recheck
If your boot partition is NOT separate, do the following:

sudo bash mount /dev/sda1 /mnt grub-install /dev/sda --root-directory=/mnt


--recheck
Step 7:
Reboot. Once up and running you will now be using the ext4 file system!

You might also like