Tech Journal Back to Tech Journal

How do I convert an EXT2 partition to an EXT3 partition?

Well, since EXT3 and EXT2 have an identicle format (as of this writing), there's no realy conversion involved. What we're really gonna do, is add a journal file, and then set the installed EXT3-enabled-kernel to use it as an EXT3 partition. (Note: I've only done this to a 2.2.17-6 system, with the EXT3 patch installed.

To create a 20MB journal file, first reserve some space using dd:

$ dd if=/dev/zero of=/journal.dat bs=1024 count=20k

Please make sure every partition has it's own journal file! I used /journal.dat for the root partition, and /usr/journal.usr.dat, /home/journal.home.dat, and /var/journal.var.dat for the /usr, /home and /var partitions.

We now have a file. Make is permission-protected and immutable:

$ chmod 400 /journal.dat
$ chattr +i /journal.dat

Now let's make it the partition's journal! Find the file's inode number by using ls:

$ ls -i /journal.dat

You'll get a line that looks something like:

2947 /journal.dat

the number on the left is the inode. Now, we'll unmount the partiton, remount it with the journal info, and then unmout it again (because we don't want to specify & change the journal's node every time.) I know it sounds complex, but just do this:

$ umount /mnt/ext3
$ mount -t ext3 /dev/hdb1 /mnt/ext3 -o journal=2947
$ umount /mnt/ext3

Finally, we'll re-mount it as a regular EXT3 partition. (This is what you can use from now on to mount the partition. If you don't use /etc/fstab to automatically mount it on boot.)

$ mount -t ext3 /dev/hdb1 /mnt/ext3

You might want to add a line to /etc/fstab, to mount it as ext3 every boot. Something like this would work:

/dev/hdb1     /     ext3    exec,dev,suid,rw,usrquota,grpquote    1 1

(You may or may not need the last two quota options, depending on whether you run quotas or not. Add and remove the other options to taste.)

As to converting your root partition, that's a bit more painful (or was for me.) First off, you must go into single-user mode (also speeds up reboots until you get it to work.) After creating the journal file and finding its inode number, tell lilo to set the journal file on next boot:

$ lilo -r rootflags=noload,journal=2947

Once you got that, you need to convince the system that the root partition is an EXT3 partition. Easiest way I found was to edit /etc/fstab to say the partition is now ext3 instead of ext2, and then reboot. You might need to reboot again to really convince it that it's EXT3. (On shutdown after you exit /etc/fstab, there's gonna be some complains about it really being EXT2 and not EXT3. Ignore 'em.)

Warning: You do this at your own risk. (Like everything in this tech-journal. And yes, that means you too, Shalom.)

Useful Links:

Last updated on 2001-09-11 14:00:00 -0700, by Shalom Craimer

Back to Tech Journal