Information Technology | Softwares - Graphics - Programming - Hacking - Security

Oct 19, 2018

What is ext partition? Linux file systems: Ext2, Ext3 and Ext4 - Understanding file system superblock linux

AT32, NTFS, exFAT are three different files systems used to store data in a storage device. Created by Microsoft, these file systems have their own set of pros and cons which will help you choose the correct file system for different needs. Ext2, ext3 and ext4 are all filesystems created for Linux system. Ext4 was born as a series of backward-compatible extensions to ext3, many of them originally developed by Cluster File Systems for the Lustre file system between 2003 and 2006, meant to extend storage limits and add other performance improvements.


Ext2

  • Ext2 stands for second extended file system.
  • It was introduced in 1993. Developed by Rémy Card.
  • developed to overcome the limitation of the original ext file system.
  • Ext2 does not have journaling feature.
  • On flash drives, disk, 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 create an ext file system:

ext2: mke2fs /dev/sda1

ext3: mkfs.ext3 /dev/sda1
ext4: mkfs.ext4 /dev/sda1
sda1 is e.g your ext partition.

Blocks in File System

When a partition or disk is formatted, the sectors in the hardisk is first divided into small groups. This groups of sectors is called as blocks. The block size is something that can be specified when a user formats a partition using the command line parameters available.
Block Size for Ext2 can be 1Kb, 2Kb, 4Kb, 8Kb
Block Size for Ext3 can be 1Kb, 2Kb, 4Kb, 8Kb
Block Size for Ext4 can be 1Kb to 64Kb

Why block size has an impact on performance?

The file system driver sends block size ranges to the underlying drive, while reading and writing things to files system. Just imagine if you have a large file, reading smaller blocks (which combined together makes the file size) one by one will take longer. So the basic idea is to keep bigger block size, if your intention is to store large files on the file system.

A linux Kernel performs all its operations on a file system using block size of the file system. The main important is the block size can never be smaller than the hard disk's sector size, and will always be in multiple of the hard disk sector size. Kernel also requires the file system block size to be equal or smaller to the system page size.


File System Superblock

Its the metadata of the file system. Superblocks store metadata of the file system. As it stores critical information about the file system, the utmost importance is preventing corruption of superblocks. Superblocks also stores configuration of the file system.


  • Blocks in the file system
  • No of free blocks in the file system
  • Inodes per block group
  • Blocks per block group
  • No of times the file system was mounted since last fsck.
  • Mount time.
  • UUID of the file system.
  • Write time.
  • File System State (e.g: was it cleanly unounted, errors detected etc)
  • The file system type etc(e.g: whether its ext2,3 or 4).
  • The operating system in which the file system was formatted.

If the superblock of a file system is corrupted, then you will face issues while mounting that file system such as bad superblock

How to view Superblock Information?

type: dumpe2fs -h /dev/sda1
sda1 is e.g your ext partition.

Thanks for reading.



Share:

About Us