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 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.

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.

Read Also: Explanation of “Everything is a File” and Types of Files in Linux

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.

If you liked this article, then do subscribe to email alerts for Linux tutorials. If you have any questions or doubts? do ask for help in the comments section.

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

TecMint is the fastest growing and most trusted community site for any kind of Linux Articles, Guides and Books on the web. Millions of people visit TecMint! to search or browse the thousands of published articles available FREELY to all.

If you like what you are reading, please consider buying us a coffee ( or 2 ) as a token of appreciation.

Support Us

We are thankful for your never ending support.

12 thoughts on “What is Ext2, Ext3 & Ext4 and How to Create and Convert Linux File Systems”

  1. Hello Ravi,

    I bought the RHCSA V8 book a couple of weeks ago. The book is missing RHCSA V8 topics such as Virtual data Optimizer(VDO) and tuned.

    Can they be added, please? I need them to prepare for the RHCSA exam.

    Reply
    • @Tam,

      Thanks for updating us, yes in next update I will add this topic, hopefully, will re-distribute updated copies by next week.

      Reply
  2. [[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.

    Reply
  3. 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.”

    Reply
  4. 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.

    Reply

Leave a Reply to madhav Cancel reply

Have a question or suggestion? Please leave a comment to start the discussion. Please keep in mind that all comments are moderated and your email address will NOT be published.

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