Converting from Ext2 to Ext3

The conversion procedure is simple enough. Imagine /dev/hda10 mounted as /test – the procedure would be as follows:

  • Log in as root
  • Make sure /etc/fstab has /dev/hda10 mounted to /test as ext2, read write
  • umount /dev/hda10
    • If you can’t unmount it, then remount it read only (mount -o remount,ro /dev/hda10)
  • tune2fs -j /dev/hda10
  • Edit /etc/fstab, and for /dev/hda10, change ext2 to ext3
  • mount /dev/hda10
  • /sbin/shutdown -h now
  • mount | grep /dev/hda10
    • If it’s not shown as ext3, reboot, if still not, troubleshoot
    • Otherwise, you’re done.

A few explanations are in order. The tunefs command creates the journal file, which is kept in a special inode on the device (by default). You then must change the /etc/fstab entry to reflect it’s a journalling filesystem, and then mount it.


Converting the /usr directory

This applies only to those systems in which the /usr tree has its own partition. Converting the /usr directory presents a challenge because commands like tune2fs are located in the /usr tree, so it must be mounted. Mount it read only with the following command:

mount -o remount,ro /usr

Then run tune2fs -j, edit /etc/fstab, and then unmount and remount /usr.

Converting the / directory

First, think long and hard before deciding to convert the root directory. Ext3’s primary purpose is shorter recovery from disaster rather than data loss prevention. Converting the root directory from Ext2 to Ext3 isn’t difficult, but converting it back from Ext3 to Ext2 is a treacherous process fraught with problems. But, if you really must perform the Ext2 to Ext3 conversion on the root directory, here’s how, assuming /dev/hda2 is mounted as the root directory and /dev/hda1 is mounted as /boot:

  • Log in as root
  • Edit /etc/fstab and change ext2 to  ext3 on the line referencing the root directory.
  • tune2fs -j /dev/hda2
  • cd /boot
  • mv initrd-2.4.18-26.8.0.img initrd-2.4.18-26.8.0.img.ext2
  • mkinitrd initrd-2.4.18-26.8.0.img 2.4.18-26.8.0
  • reboot

In the preceding, you MUST perform all the steps, including the mkinitrd, before rebooting. Failing to perform all the steps before rebooting produces a “buried shovel” where if only you could boot the machine, you could run the mkinitrdcommand, and if only you could run the mkinitrd command, you could boot the machine.