You can upgrade Ext2 or Ext3 partitions to the new, faster Ext4 without having to format the partition which I'm sure is a relief to everyone. All it takes are several commands and you're done. As well as Ext4 being generally faster than Ext3, it also takes only a fraction of the time to run disk checks which will save you an age in the long run.
To start with, ensure you are root
otherwise you won't be able to do much. In this article I will refer to sdx
: you will need to replace 'sdx' with the name of the drive that you wish to perform the actions on, for example hda2 or sdb1. This guide also assumes a few things, firstly that you're using a recent version of GRUB with Ext4 support
and that you are using a Kernel that supports Ext4.
If you are still using Ext2 then you will need to upgrade to Ext3 by doing the following:
tune2fs -j /dev/sdx
If you're not sure which version of Ext you are currently using, run the command mount
and it will tell you via an output like this:
/dev/sda2 on / type ext3 (rw,noatime,errors=remount-ro)
tmpfs on /lib/init/rw type tmpfs (rw,nosuid,mode=0755)
proc on /proc type proc (rw,noexec,nosuid,nodev)
sysfs on /sys type sysfs (rw,noexec,nosuid,nodev)
udev on /dev type tmpfs (rw,mode=0755)
Once you have updated to Ext3 you can work on upgrading to Ext4. Keep in mind that once you upgrade to Ext4, you will not be able to mount this drive as Ext3 anymore. To upgrade, you need to run another command:
tune2fs -O extents,uninit_bg,dir_index /dev/sdx
Your partition has now been upgraded to Ext4 but before it is safe for use, you will need to run a fsck
on it to fix the structures that you have just modified. Only do this if you are upgrading a partition that is not
mounted. If you are upgrading your root partition then skip this step.
e2fsck -fDC0 /dev/sdx
You will receive multiple error messages that "One or more block group descriptor checksums are invalid"
- this is fine and nothing to worry about. Unfortunately one of the main speed boosters, extents, doesn't apply to existing files via this upgrade method but it will to any new files created on your partition, so eventually you will gain the speed boost anyway as files are removed and replaced.
If you are upgrading your root '/
' partition, you won't be able to run fsck safely without rebooting so you will need to force Linux to perform a disk check on the next reboot. This can be done by creating a file called forcefsck on the root of the partition that you would like checked. This can be done easily with one command:
There is now one final stage which is to update your /etc/fstab
file and make sure that you have your newly upgraded partition set to ext4
and not ext2 or ext3.
If, when you reboot after upgrading your root partition you are faced with a message that fsck could not run and needs to be run manually, chances are you will have been dropped to a maintenance prompt with your root partition mounted read only. That's fine, simply run the file system check you skipped over earlier which in turn will fix the issues and complete the upgrade. You can now reboot.
And that's it, enjoy your new faster Linux partition.
For more information on Ext4, please see their official site