Create and Convert Linux File Systems

Learn how to create partitions on a disk drive and how to format them for use on a Linux system. Use this article to create and convert linux file system.
file system

See Also:
Linux File Systems: Ext2 vs Ext3 vs Ext4

Creating an Ext2 or Ext3 or Ext4 File Systems

Once you create file system using fdisk command, use mke2fs command to create file system.

Note: Make sure you replace xvdaX with your device name.

Creating Ext2 File System

# mke2fs /dev/xvdaX

Creating Ext3 File System

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

-j option is used for journaling.

Creating Ext4 File System

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

-t option is used for file system type.

Converting an Ext2, or Ext3, or Ext4 File Systems

It is always better way to unmount file system and convert. Again replace xvdaX 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/xvdaX

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

# e2fsck -pf /dev/xvdaX

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

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

# e2fsck -pf /dev/xvdaX

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

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

We must run fsck to fix up some on-disk structures that tune2fs has modified.

# e2fsck -pf /dev/xvdaX

Enjoy it!

No Responses

Leave a Reply

Your email address will not be published. Required fields are marked *

This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.

The reCAPTCHA verification period has expired. Please reload the page.