Ext2, ext3 and ex4 are most popular file systems on Linux, Ext2 was introduced in 1993 and was the first default file system in several linux distro like RedHat, Debian etc..

Here few examples show you how to create these filesystems.

Spearate journal and data on different device

In most of cases, and it is default, the journal(if there is) and data device are on the same block device. Seperate journal and data brings performance improvement, on the other hand, introduce the management complexity and the chance of data inconsistency risk.

Prepare block device

You can use a whole disk/lun for a filesystem, or partition it into different partitions by fdisk or parted

Create ext2 filesystem

    Maximum file size is 16GB – 2TB.
    Journaling feature is not available.

You can use any one of the command to create an ext2 filesystem

#mkfs -L <volume-label> -t ext2 /dev/sdxx
#mkfs.ext2 -L <volume-label> /dev/sdxx
#mke2fs -L <volume-label> -t ext2 /dev/sdxx

-t stands for filesystem type, default is ext2

-L stands for filesystem volume label

Create ext3 filesystem

    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.
    Max file size 16GB – 2TB.
    Provide facility to upgrade from Ext2 to Ext3 file systems without having to back up and restore data.

#mkfs -L <volume-label> -t ext3 /dev/sdxx
#mkfs.ext3 -L <volume-label> /dev/sdxx
#mke2fs -L <volume-label> -t ext3 /dev/sdxx
#mke2fs -L <volume-label> -j /dev/sdxx

-t stands for filesystem type, default is ext2

-L stands for filesystem volume label

-j stands for journal(as if using -t ext3 )

Created ext4 filesystem

    On October 2008, Ext4 as stable code were merged in the Kernel 2.6.28 which contains Ext4 file system.
    Backward compatibility.
    Max file size 16GB to 16TB.
    Ext4 file system have option to Turn Off journaling feature.
    Other features like Sub Directory Scalability, Multiblock Allocation, Delayed Allocation, Fast FSCK etc.

#mkfs -L <volumelabel> -t ext4 /dev/sdxx
#mke2fs -L <volume-label> -t ext4 /dev/sdxx
#mkfs.ext4 -L <volume-label> /dev/sdxx

Check a filesystem type

To tell a filesystem type, simply run

# df -T 
Filesystem           Type  1K-blocks    Used Available Use% Mounted on
/dev/sda2            ext4    1477292  391364   1009220  28% /
tmpfs                tmpfs   4030604   44456   3986148   2% /dev/shm
/dev/sda1            ext4     197157   59247    127519  32% /boot
/dev/mapper/vg0-home ext4   50281156 5702696  42017644  12% /home
/dev/mapper/vg0-opt  ext4     999320    2152    944740   1% /opt
/dev/mapper/vg0-tmp  ext4     499656     460    472984   1% /tmp
/dev/mapper/vg0-usr  ext4    3966144 3058724    702620  82% /usr
/dev/mapper/vg0-var  ext4    9964080  369196   9082068   4% /var

To list specific filesystem mounted, simply run

# df -t tmpfs
Filesystem     1K-blocks  Used Available Use% Mounted on
tmpfs            4030604 44456   3986148   2% /dev/shm

Utility tune2fs offers more options to let you display, set filesystem parameters

Comments powered by CComment