Home Linux guides How to format and Create Filesystems in Linux.

How to format and Create Filesystems in Linux.


This article targets individuals preparing themselves to sit for LPIC 1 examinations. This is a key area and fully understanding it will make your LPIC 1 exam worthwhile.

A Filesystem refers to methods and data structures that operating systems use to keep track of files and directories on a disk or a given partition.

Filesystems thus manage data stored in the storage devices. A filesystem maintains a map to locate each file placed in the storage device and shows you how to locate the files and directories contained within it.

Linux filesystem uses a virtual directory structure that contains file paths from all the storage devices installed on the system consolidated into a single directory structure.

In this article, we will narrow down to Formatting filesystems as well as creating them.

Formatting Filesystems.

In this section, we will look at various formatting filesystems that you can choose from. We will not go into much detail but will try and give what is important.

Linux filesystem has the ability to create a filesystem across multiple devices.

Common Formatting Filesystems.

1. btrfs

btrfs supports up to 16 exbibytes ( 1 exbibytes = 1024 pepibytes ) in size and a total file system size of 16 exbibytes.

btrfs performs its own form of RAID as well as LVM and subvolumes.

btrfs filesystem is used to perform several whole filesystem tasks like resizing, space statistics, label setting, and defragmentation.

2. ecryptfs

Enterprise Cryptographic Filesystem (ecryptfs) applies Portable Operating System Interface (POSIX) which is a compliant encryption protocol to data before storing it on the device.

This provides a layer of protection for data stored on the device

ecryptfs is a cryptographic stacked Linux filesystem that can be mounted on any directory and on top of the main filesystem.

3. ext3

This is also referred to as ext3fs

ext3 supports files up to 2 tebibytes (TiB) with a total filesystem of 16 TiB.

ext3 supports journalling, faster startup, and recovery. Journalling is the ability to keep a journal or logs of the changes made to the filesystem.

4. ext4

This is also called ext4fs.

It is the default current Linux Filesystem.

ext4 support files up to 16 EiB with a total filesystem size of 1 EiB.

Like ext3, ext4fs supports journalling.

5. ReiserFS

This filesystem was created before ext3fs.

its commonly used on old Linux systems and is no longer supported.

ReiserFS provides features found in both ext3 and ext4 filesystems.

6. Swap

Swap filesystem allows you to create a virtual memory for your system using space on a physical storage drive. Once created the system can swap data out of normal memory into the swap space thereby providing a method of adding memory to your system.

With the brief overview of the formatting filesystem methods above, we now look at how to create filesystems.

Creating Filesystems

To create a Filesystem use the mkfs command.

The command syntax is as below:

mkfs [options] [-t type fs-options] device [size]

The command options include :

-t, –type typeSpecify the type of filesystem to create. If not specified ext4 will be created by default.
fs-optionsThis represents the specific filesystems options passed to mkfs command.
-V, –verboseProduces a verbose output that shows what is happening during the creation of a filesystem.
-V, –versionDisplays version information then exits
-h, –helpDisplay help and exit.

Let’s practically create an ext4 filesystem on a USB.

Step 1 : List all your drives.

To list all your drives in your system, execute the command below.

df -h

The command output.


My USB disk is the one marked /dev/sdb1 yours may have a different format.

Step 2 : Un-mounting the USB drive’s partition

Unmounting a device is necessary before formatting it.

To unmount /dev/sdb1 run the command below.

sudo umount /dev/sdb1

Note: The command is umount and NOT unmount.

Step 3 : Erase all the data on your USB drive.

Ensure that your data is backed up prior to following these steps.

To erase your data run the following command.

sudo dd if=/dev/zero of=/dev/sdb1 bs=2M count=2

The command output.


Step 4 : Create a new partition table.

This is achieved by issuing the following command.

sudo fdisk /dev/sdb1

The output is as shown in the screenshot.


Press enter then choose the option ‘o’ for creating an empty partition table as in the screenshot below.


Enter ‘n’ to create a new partition, then ‘p’ to create a primary partition, and finally ‘w’ to write the table and exit.

see the screenshot below.


Step 5: View partitions.

To view partitions run the command below.


The command output


Step 6 : Format the new volume created.

Our newly created volume is partition sdb1.

To format our new volume using the ext4 filesystem, run the following command.

sudo mkfs -t ext4 /dev/sdb1

The command output.


Step 7 : Verify your filesystem.

To verify the filesystem, execute this command.

sudo file -sL /dev/sdb1

The command output.


Step 8 : Eject your drive.

Lastly, eject your USB by running the command below.

sudo eject /dev/sdb1


The steps explained above describes how to Format and Create a Filesystem. We hope that the article was helpful to you. Please feel free to leave a comment below.

In the next article, we will look at partitioning tools and carry an example to demonstrate their usage. Thank you.



Please enter your comment!
Please enter your name here