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

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. By following this guide anyone can convert their file systems smartly, but still I like to WARN you’ll before doing this, because the following task required skilled administrative practices and make sure you must take 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.

Linux File System

Linux File System

In a computer, a file system is the 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.

File system is divided in 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 difference amongst Ext2, Ext3 and Ext4 file systems. Before moving further readings, let me introduce a brief about Linux file systems.

Ext2 – Second Extended File System

  1. Ext2 file system was introduced in 1993 and Ext2 was developed by Remy Card. It was the first default file system in several Linux distro like RedHat and Debian.
  2. It was to overcome limitation of legacy Ext file system.
  3. Maximum file size is 16GB – 2TB.
  4. Journaling feature is not available.
  5. It’s being used for normally Flash based storage media like USB Flash drive, SD Card etc.

Ext3 – Third Extended File System

  1. Ext3 file system was introduced in 2001 and same was integrated in Kernel 2.4.15 with journaling feature, which is to improve reliability and eliminates need to check file system after unclean shutdown.
  2. Max file size 16GB – 2TB.
  3. Provide facility to upgrade from Ext2 to Ext3 file systems without having to back up and restore data.

Ext4 – Fourth Extended File System

  1. Ext4, the high-anticipated Ext3 successor.
  2. On October 2008, Ext4 as stable code were merged in the Kernel 2.6.28 which contains Ext4 file system.
  3. Backward compatibility.
  4. Max file size 16GB to 16TB.
  5. Ext4 file system have option to Turn Off journaling feature.
  6. Other features like Sub Directory Scalability, Multiblock Allocation, Delayed Allocation, Fast FSCK etc.

How to Determine File System Type?

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

# df -hT | awk '{print $1,$2,$NF}' | grep "^/dev"
/dev/sda3 ext3 /
/dev/sda1 ext3 /boot
Warning: Please take important data backup before executing below commands.

Creating an Ext2, or Ext3, or Ext4 File Systems

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

Creating Ext2 File System

# mke2fs /dev/hdXX

Creating Ext3 File System

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

-j option is used for journaling.

Creating Ext4 File System

# mke2fs -t ext4 /dev/hdXX
OR 
# mkfs.ext4 /dev/hdXX

-t option to specify the file system type.

Converting an Ext2, or Ext3, or Ext4 File Systems

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

Converting Ext2 to Ext3

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

# tune2fs -j /dev/hdXX

Converting Ext2 to Ext4

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

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

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

# e2fsck -pf /dev/hdXX

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

Converting Ext3 to Ext4

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

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

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

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

# e2fsck -pf /dev/hdXX

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

Best Affordable Linux and WordPress Services For Your Business
Outsource Your Linux and WordPress Project and Get it Promptly Completed Remotely and Delivered Online.

If You Appreciate What We Do Here On TecMint, You Should Consider:

  1. Stay Connected to: Twitter | Facebook | Google Plus
  2. Subscribe to our email updates: Sign Up Now
  3. Get your own self-hosted blog with a Free Domain at ($3.45/month).
  4. Become a Supporter - Make a contribution via PayPal
  5. Support us by purchasing our premium books in PDF format.
  6. Support us by taking our online Linux courses

We are thankful for your never ending support.

Narad Shrestha

He has over 10 years of rich IT experience which includes various Linux Distros, FOSS and Networking. Narad always believes sharing IT knowledge with others and adopts new technology with ease.

Your name can also be listed here. Got a tip? Submit it here to become an TecMint author.

RedHat RHCE and RHCSA Certification Book
Linux Foundation LFCS and LFCE Certification Preparation Guide

You may also like...

10 Responses

  1. Ela says:

    Please suggest is it possible to convert ext4 to xfs filesystem on redhat 7?

  2. madhav says:

    Please ignore my previous comment, I was using small o instead capital. I got it later.

  3. madhav says:
    [[email protected] appdata]# tune2fs -o dir_index,has_journal,uninit_bg /dev/sda7
    tune2fs 1.41.12 (17-May-2010)
    Invalid mount option set: dir_index,has_journal,uninit_bg
    
    [[email protected] appdata]# tune2fs -o extents,uninit_bg,dir_index /dev/sda5
    tune2fs 1.41.12 (17-May-2010)
    Invalid mount option set: extents,uninit_bg,dir_index
    

    I hit these both commands and it says invalid mount options set.

  4. Hemant Singh says:

    I think it should be “Partitions instead of File Systems” in this line “Once you create file system using fdisk or parted command, use mke2fs command to create either of file system and make sure you replace hdXX with your device name.”

  5. abdulwajid khan says:

    how to change the filesystem path in linux /dev/db1 to /prod/db1

  6. Dragos Alexe says:

    A nice way is to manage LVM through ssm. Only one step-we can create a logical volume and volume group, choose file system type.
    ex: sudo ssm create -s 200GB -n disk0 –fstype ext4 -p my_volume /dev/sda /mount

    So we create a volume group named “my_volume”, create a 200GB LVM volume named disk0, after that format the volume ext4 file system, and mount it under “/mount” mounting point.

Got something to say? Join the discussion.

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.