how to convert ext3 to ext4 on debian

September 4, 2011 § 1 Comment

recently i wanted to migrate from ext3 to ext4 file system without losing any data on the hard drive, in order to use the new trim functionality that is available on linux 2.6.33 and later. i searched the internet and there were a few links, however they were not complete or they were for different distros. i tried a few of them and ended up with not-bootable linux and lots of issues. finally i found how to do this by trial and error and thought to write a short tutorial on how to do it.

the first thing needs to be done is to enable the extra options on the ext3 file system by running the following command:

tune2fs -O extents,uninit_bg,dir_index [hard drive mount point]

in my case the mount point is /dev/sda1

then you have to run the file system check utility to re-adjust the file system to your new parameters (don’t worry about the errors, they are expected)

fsck -f -y [hard drive mount point]

after the file system parameters are adjusted you need to let the kernel know that you want to run ext4 file system. this is done through the grub boot loader. add the following kernel option to your kernel line in grub’s menu.lst file.


for example, your menu.lst section will be something like,

title Debian GNU/Linux, kernel 3.0.1-rt11
root (hd0,0)
kernel /boot/vmlinuz-3.0.1-rt11 root=/dev/sda1 ro quiet rootfstype=ext4
initrd /boot/initrd.img-3.0.1-rt11

then you need to edit /etc/fstab file and change the drive fs type to ext4, for example if the original line is

/dev/sda1 / ext3 rw,noatime,errors=remount-ro 0 1

you need to modify it to,

/dev/sda1 / ext4 discard,rw,noatime,errors=remount-ro,commit=0 0 1

discard option is added to use the new trim functionality for ssd drives. i will discuss this in another post.

now you can reboot and your system will boot up using your new ext4 file system. remember this is a must if you are going to use ssd drives on your system.

also note that grub doesn’t read ext4 file systems, you need to upgrade to grub2 for you boot loader to work. the upgrade to grub2 is very easy and harmless. here’s a good link on grub2


Tagged: , , , , , , , , , , , ,

§ One Response to how to convert ext3 to ext4 on debian

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

What’s this?

You are currently reading how to convert ext3 to ext4 on debian at artang.