Did You Know?
Got a tip? Let us know

LFCS - Linux Foundation Certified SysAdmin - Exam Preparation Guide

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

Download Your Free eBooks NOW - 10 Free Linux eBooks for Administrators

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

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.
Download Free eBooks
Advanced Bash-Scripting Guide
Linux Bible
A Newbie's Getting Started Guide to Linux
Ubuntu Linux Toolbox: 1000+ Commands

Leave a Reply

This work is licensed under a (cc) BY-NC | TecMint uses cookies. By using our services, you comply to use of our cookies. More info: Privacy Policy.
© 2012-2014 All Rights Reserved.