how do I convert a live root ext3 filesystem to ext4?

I have a root filesystem thats live and mounted and I'd like to convert it to ext4. All the howto's i've read deal with booting off a live CD but thats not an option.


Solution 1:

It appears that my original post was completely wrong. You can convert an ext3fs partition to an ext4fs partition while it is mounted, because the conversion process doesn't actually change the files that were previously written to use extents. This is documented in the ext4 howto along with all the reasons why it's a really bad idea for you to try:

  • None of the existing files are converted, so you will not receive any performance boost (and according to the per-distribution instructions, some kernels have bugs dealing with these imported files)
  • You need to have a bootloader that supports ext4, if you don't, you won't know until it stops booting (since the file isn't changed during the conversion, the bootloader will still be able find it, until the file has been replaced or moved).
  • If ext4 isn't built into your kernel, you must make sure your initrd/initramdisk has the module for it.
  • You need to update all your fstab and kernel boot parameters to show that the filesystem is ext4 since it will no longer mount as ext3.
  • The system must be rebooted
  • The partition will require a fsck once rebooted (with a fsck version that understands ext4)

The howto lists some of the changes required on a per-distribution basis as well, so you can determine the correct versions of which packages to install.

If booting off a LiveCD is not an option, I presume that this is a remotely hosted server that you can't just go and boot off a cd. If one of those above fails, how are you going to deal with it when it doesn't come back after you reboot? How long does it take to fsck your root partition, so you'll know how long to give it before you start worrying, and how much longer 'til you start sweating?

Otherwise, if you're confident you've done everything right and have everything set up the right way, just run

tune2fs -O extents,uninit_bg,dir_index /dev/partitiondevice
shutdown -r now