The ext4 filesystem includes multiple improvements in terms of performance, over its predecessor ext3. Ext4 is not only faster than ext3, but can also handle much larger filesystems and files, and lots of other improvements under the hood. If you haven’t yet upgraded to ext4 on Linux, it’s definitely time to do so.
It this tutorial, we cover the step by step instructions to convert an ext3 fileystem to ext4, and thus enabling some of the ext4 performance enhancement features. Follow along with the steps below to convert ext3 to ext4 without losing data.
In this tutorial you will learn:
- How to uprade from ext3 to ext4 filesystem
|Category||Requirements, Conventions or Software Version Used|
|System||Any Linux distro|
|Other||Privileged access to your Linux system as root or via the
|Conventions||# – requires given linux commands to be executed with root privileges either directly as a root user or by use of
$ – requires given linux commands to be executed as a regular non-privileged user
Convert ext3 to ext4
Before you continue, please note that after you convert your ext3 partition to ext4 filesystem, you will no longer be able to mount that partition as ext3. Furthermore, if the ext3 partition you are going to convert to ext4 is used by Grub during boot load process, make sure that Grub loader is capable boot using ext4 filesystem.
- The first step is… take a backup! Nothing should go wrong in the conversion process, but it would be extremely negligent to avoid taking a backup before modifying a filesystem.
- In our example scenario, we will use the existing
/dev/sdb1partition, which is formatted with the ext3 filesystem. Here is our ext3 mounted partition:
# mount | grep sdb1 /dev/sdb1 on /mnt/temp type ext3 (rw,relatime,errors=continue,user_xattr,acl,barrier=1,data=ordered)
- Make sure to unmount your ext3 partition before continue:
# umount /mnt/temp/
- Modify the ext3 filesystem to include ext4 features:
# tune2fs -O extents,uninit_bg,dir_index /dev/sdb1
- You won’t recieve much output from the command above, if it was successful. Once that command completes, optimize and repair filesystem directories and force a filesystem check with this command:
# e2fsck -fD /dev/sdb1 e2fsck 1.45.5 (07-Jan-2020) Pass 1: Checking inodes, blocks, and sizes Pass 2: Checking directory structure Pass 3: Checking directory connectivity Pass 3A: Optimizing directories Pass 4: Checking reference counts Pass 5: Checking group summary information /dev/sdb1: ***** FILE SYSTEM WAS MODIFIED ***** /dev/sdb1: 12/54216 files (0.0% non-contiguous), 12765/216060 blocks
- Now, we can test mount our new ext4 filesytem:
# mount /dev/sdb1 /mnt/temp/ # mount | grep sdb1 /dev/sdb1 on /mnt/temp type ext4 (rw,relatime,user_xattr,barrier=1,data=ordered)
All done. We have successfully converted ext3 filesystem to ext4.
In this tutorial, we saw how to convert an ext3 filesystem to ext4 by using Linux commands. After mounting the new filesystem, you’ll be able to enjoy all the features of ext4, which mostly boil down to a sharp increase in performance. Enjoy!