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

Ext2 stands for second extended file system. Ext3 stands for third extended file system. Ext4 stands for fourth extended file system. This was developed to overcome the limitation of the original ext file system. Starting from Linux Kernel 2.4. A filesystem is a way of storing, organizing and accessing files (and/or directories) on a storage device. Some examples of filesystems are FAT, NTFS for Windows/DOS, HFS for MAC OS etc. In Linux, the popular filesystems are ext2, ext3 and ext4 file systems. Some other filesystems such as ReiserFS are also natively supported by Linux. This article discusses various features of extended filesystems in Linux, i.e. ext2, ext3 and ext4.

Ext2

  • Ext2 stands for second extended file system.
  • It was introduced in 1993. Developed by Rémy Card.
  • This was developed to overcome the limitation of the original ext file system.
  • Ext2 does not have journaling feature.
  • On flash drives, usb drives, ext2 is recommended, as it doesn’t need to do the over head of journaling.
  • Maximum individual file size can be from 16 GB to 2 TB
  • Overall ext2 file system size can be from 2 TB to 32 TB

Ext3

  • Ext3 stands for third extended file system.
  • It was introduced in 2001. Developed by Stephen Tweedie.
  • Starting from Linux Kernel 2.4.15 ext3 was available.
  • The main benefit of ext3 is that it allows journaling.
  • Journaling has a dedicated area in the file system, where all the changes are tracked. When the system crashes, the possibility of file system corruption is less because of journaling.
  • Maximum individual file size can be from 16 GB to 2 TB
  • Overall ext3 file system size can be from 2 TB to 32 TB
  • There are three types of journaling available in ext3 file system.
    • Journal – Metadata and content are saved in the journal.
    • Ordered – Only metadata is saved in the journal. Metadata are journaled only after writing the content to disk. This is the default.
    • Writeback – Only metadata is saved in the journal. Metadata might be journaled either before or after the content is written to the disk.
  • You can convert a ext2 file system to ext3 file system directly (without backup/restore).

Ext4

  • Ext4 stands for fourth extended file system.
  • It was introduced in 2008.
  • Starting from Linux Kernel 2.6.19 ext4 was available.
  • Supports huge individual file size and overall file system size.
  • Maximum individual file size can be from 16 GB to 16 TB
  • Overall maximum ext4 file system size is 1 EB (exabyte). 1 EB = 1024 PB (petabyte). 1 PB = 1024 TB (terabyte).
  • Directory can contain a maximum of 64,000 subdirectories (as opposed to 32,000 in ext3)
  • You can also mount an existing ext3 fs as ext4 fs (without having to upgrade it).
  • Several other new features are introduced in ext4: multiblock allocation, delayed allocation, journal checksum. fast fsck, etc. All you need to know is that these new features have improved the performance and reliability of the filesystem when compared to ext3.
  • In ext4, you also have the option of turning the journaling feature “off”.

How to Determine File System Type?

To determine your Linux file system type, run the following command.

df -hT | awk '{print $1,$2,$NF}' | grep "^/dev"

Creating an Ext2, or Ext3, or Ext4 File Systems

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 vda1 with your device name.

Creating a Ext2 File System

mke2fs /dev/vda1

Creating a Ext3 File System

 mke2fs –j  /dev/vda1
 or
 mkfs.ext3  /dev/vda1

-j option is used for journaling.

Creating the Ext4 File System

 mke2fs -t ext4 /dev/vda1
 or
 mkfs.ext4 /dev/vda1

-t option to specify the file system type.

Converting an Ext2, or Ext3, or Ext4 File Systems

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 vda1 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/vda1

Converting Ext2 to Ext4

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

tune2fs -O dir_index,has_journal,uninit_bg /dev/vda1

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

e2fsck -pf /dev/vda1

-p option automatically repairs the file system.
-f option forces 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/vda1

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

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

e2fsck -pf /dev/vda1

Conclusion

We hope everyone understatnds What is Ext2, Ext3 & Ext4 and How to Create and Convert Linux File Systems. Are you looking for cheap web hosting service providers? Then this is your last destination to end your search. We at TheStack provide premium WordPress hosting, hybrid smart server hosting, SEO dedicated server hosting, cheap dedicated server hosting, and managed virtual private servers at the best price. So, what are you waiting for? Give us a quote to work with us.

Related Articles