Wednesday, August 06, 2014

Linux - ext2 vs ext3 vs ext4

A short introduction of Ext FS

Ext2 - Second Extended FS

  • Introduced in 1993 and Ext2 was developed by Remy Card. Ext2 was probably the first default file system in several Linux distro like RedHat and Debian
  • It was to overcome limitation of legacy Ext file system
  • Maximum file size is 16GB - 2TB
  • No journaling feature
  • It's being used for normally Flash based storage media
  • Overall ext2 file system size can be from 2 TB to 32 TB
Ext3 – Third Extended FS

  • Introduced in 2001 and integrated in Kernel 2.4.15 with journaling feature.
  • Improved reliability and eliminates the need to check FS after unclean shutdown
  • Max file size 16GB - 2TB
  • Provides facility to upgrade from Ext2
  • 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

Ext4 – Fourth Extended FS

  • Introduced in 2008 and merged into Kernel 2.6.28
  • Backward compatibility
  • Max file size 16GB to 16TB
  • 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)
  • Supports journaling feature and can be turned off
  • Sub Directory Scalability, Multiblock Allocation, Delayed Allocation, Fast FSCK etc
  • You can also mount an existing ext3 fs as ext4 fs (without having to upgrade it)

To determine FS type
# df -hT | awk '{print $1,$2,$NF}' | grep "^/dev"
/dev/sda3 ext4 /
/dev/sda2 ext2 /boot
/dev/sda6 ext4 /tmp
/dev/sdb1 ext4 /data1
/dev/sdc1 ext4 /data2
/dev/sdd1 ext4 /data3

Creating Ext FS:
# mke2fs /dev/hdXX

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

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

Ext FS converting:
Ext2 to Ext3
To change an ext2 file system to ext3 enabling the journal feature, use the command.
# tune2fs -j /dev/hdXX

Ext2 to Ext4
# 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
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
After running this command we MUST run fsck to fix up some on-disk structures that tune2fs has modified.
# e2fsck -pf /dev/hdXX

No comments: