What is Ext2, Ext3 & Ext4 and How to Create and Convert Linux File Systems

[‘

n

I have used my Fedora old system to test where I converted from ext2 to ext3, ext2 to ext4, and ext3 to ext4 file systems successfully.

n

By following this guide anyone can convert their file systems smartly, but still, I like to WARN you all before doing this because the following task required skilled administrative practices, and make sure you must take the important backup of your files before doing this. If in case something goes wrong at least you can revert to back with your backup data.

n

n

In a computer, a file system is a way in which files are named and placed logically to store, retrieve, and update the data and also used to manage space on the available devices.

n

n

The file system is divided into two segments called User Data and Metadata. In this article, I am trying to explore how to create and convert various Linux file systems and high-level differences amongst Ext2, Ext3, and Ext4 file systems.

n

Before moving further readings, let me introduce a brief about Linux file systems.

n

Ext2 – Second Extended File System

n

    n

  1. The ext2 file system was introduced in 1993 and Ext2 was developed by Remy Card. It was the first default file system in several Linux distros like RedHat and Debian.
  2. n

  3. It was to overcome the limitation of the legacy Ext file system.
  4. n

  5. Maximum file size is 16GB – 2TB.
  6. n

  7. The journaling feature is not available.
  8. n

  9. It’s being used for normally Flash-based storage media like USB Flash drive, SD Card, etc.
  10. n

n

Ext3 – Third Extended File System

n

    n

  1. Ext3 file system was introduced in 2001 and the same was integrated with Kernel 2.4.15 with a journaling feature, which is to improve reliability and eliminates the need to check the file system after an unclean shutdown.
  2. n

  3. Max file size 16GB – 2TB.
  4. n

  5. Provide facility to upgrade from Ext2 to Ext3 file systems without having to back up and restore data.
  6. n

n

Ext4 – Fourth Extended File System

n

    n

  1. Ext4, the high-anticipated Ext3 successor.
  2. n

  3. In October 2008, Ext4 as stable code was merged in Kernel 2.6.28 which contains an Ext4 file system.
  4. n

  5. Backward compatibility.
  6. n

  7. Max file size 16GB to 16TB.
  8. n

  9. The ext4 file system has the option to Turn Off the journaling feature.
  10. n

  11. Other features like Sub Directory Scalability, Multiblock Allocation, Delayed Allocation, Fast FSCK etc.
  12. n

n

How to Determine File System Type?

n

To determine your Linux file system type, run the following command in the terminal as a root user.

n

# df -hT | awk '{print $1,$2,$NF}' | grep "^/dev"rn/dev/sda3 ext3 /rn/dev/sda1 ext3 /boot

n

Warning: Please take important data backup before executing below commands.

n

Creating an Ext2, or Ext3, or Ext4 File Systems

n

Once you create a file system using fdisk or parted command, use mke2fs command to create either of the file system and make sure you replace hdXX with your device name.

n

Creating a Ext2 File System

n

# mke2fs /dev/hdXX

n

Creating a Ext3 File System

n

# mke2fs –j  /dev/hdXXrnORrn# mkfs.ext3  /dev/hdXX

n

-j option is used for journaling.

n

Creating the Ext4 File System

n

# mke2fs -t ext4 /dev/hdXXrnOR rn# mkfs.ext4 /dev/hdXX

n

-t option to specify the file system type.

n

Converting an Ext2, or Ext3, or Ext4 File Systems

n

It is always a better way to unmount the file systems and convert them. Conversion can be done without unmounting and mounting the filesystem. Again replace hdXX with your device name.

n

Converting Ext2 to Ext3

n

To change an ext2 file system to ext3 enabling the journal feature, use the command.

n

# tune2fs -j /dev/hdXX

n

Converting Ext2 to Ext4

n

To convert from old ext2 to new ext4 file system with the latest journaling feature. Run the following command.

n

# tune2fs -O dir_index,has_journal,uninit_bg /dev/hdXX

n

Next, do a complete file system check with the e2fsck command to fix and repair.

n

# e2fsck -pf /dev/hdXX

n

-p option automatically repairs the file system.
n-f option forces checking file system even it seems clean.

n

Converting Ext3 to Ext4

n

To enable the ext4 features on an existing ext3 filesystem, use the command.

n

# tune2fs -O extents,uninit_bg,dir_index /dev/hdXX

n

WARNING: You cannot revert or mount back to the ext3 filesystem once you run the above command.

n

After running this command we MUST run fsck to fix up some on-disk structures that tune2fs have modified.

n

# e2fsck -pf /dev/hdXX

n

WARNING: Please try all these above commands on your testing Linux server.

n

‘]