4 Convert an Ext2 or Ext3 File System to Ext4 In-Place

Convert an existing Ext2 or Ext3 file system to Ext4 without losing data.

Ext4 is an extension to Ext3, which in turn builds on features in Ext2. You can convert an earlier file system to a later version by enabling the features that are required for that version and then mounting it using the correct version type. The primary tool used for these changes is the tune2fs command.

Note:

The preferred method for upgrading an Ext2 file system to Ext4 is to back up the entire volume, reformat the storage device with Ext4, and restore the entire volume onto the newly formatted file system.

Always back up data before making file system modifications.

This procedure describes the steps to advance the file system from Ext2 to Ext4. If the file system that you're converting is an Ext3 file system, you can skip the intermediate step that converts the Ext2 file system to Ext3.

  1. Unmount the file system to prevent data corruption.
    sudo umount /dev/sda1
  2. Convert the file system from Ext2 to Ext3 by enabling the journal feature.
    sudo tune2fs -j /dev/sda1
  3. Convert the file system from Ext3 to Ext4 by enabling key Ext4 features.
    sudo tune2fs -O extents,uninit_bg,dir_index /dev/sda1
  4. Check the file system for errors.
    sudo e2fsck -f /dev/sda1
  5. Edit the /etc/fstab file to change the file system type to ext4 if the file system had a previous fstab entry.

    For example, you might change the entry to read:

    /dev/sda1        /mnt       ext4    defaults  1 1
  6. Remount the file system as Ext4.
    sudo mount -t ext4 /dev/sda1 /mnt
  7. Verify the file system type to ensure that it converted correctly.
    For example, you can check the file system type by running:
    sudo blkid /dev/sda1