Step-by-Step Guide to Ext4 Setup

Author name

July 20, 2025

How to Format and Mount Ext4 Filesystems in Linux – Step-by-Step Guide

Published on: July 20, 2025 | Category: Linux Storage | Author: wowstorage.com

Creating Partitions, Formatting, Mounting, Fstab Entry

Ext4 is one of the most widely used Linux filesystems due to its stability, performance, and ease of use. In this tutorial, we’ll walk through how to create an Ext4 partition, format it, mount it manually, and configure your system to mount it automatically on boot using the /etc/fstab file.

Step 1: Identify the Disk

Before partitioning, identify the device you want to format. Use the following command:

lsblk

Example output:


NAME   MAJ:MIN RM  SIZE RO TYPE MOUNTPOINT
sda      8:0    0   50G  0 disk
├─sda1   8:1    0   48G  0 part /
└─sda2   8:2    0    2G  0 part [SWAP]
sdb      8:16   0  100G  0 disk
    

We’ll use /dev/sdb in this guide.

Step 2: Create a Partition

Use fdisk or parted to create a partition on the target disk.

<php>

ecgi
sudo fdisk /dev/sdb

Inside fdisk:

  • Press n to create a new partition
  • Press p for primary
  • Press w to write changes

This creates /dev/sdb1.

Step 3: Format the Partition with Ext4

Once the partition is created, format it using mkfs.ext4:

sudo mkfs.ext4 /dev/sdb1

This formats the partition with Ext4 filesystem.

Step 4: Create Mount Point

Create a directory where the partition will be mounted:

sudo mkdir /mnt/data

Step 5: Mount the Partition

Mount the partition manually to verify it works:

sudo mount /dev/sdb1 /mnt/data

Check the mount with:

df -h | grep sdb1

Step 6: Make the Mount Persistent with fstab

Find the UUID of the partition using:

sudo blkid /dev/sdb1

Output:

/dev/sdb1: UUID="a1b2c3d4-5678-9eab-cdef-1234567890ab" TYPE="ext4"

Edit /etc/fstab and add:

UUID=a1b2c3d4-5678-9eab-cdef-1234567890ab /mnt/data ext4 defaults 0 2

Then test fstab entry:

sudo mount -a

No errors means it worked!

Tips & Best Practices

  • Use UUID instead of device name to avoid boot issues after disk renumbering.
  • For external drives, consider noatime or nodiratime to improve performance.
  • Always back up data before formatting disks.

Conclusion

That’s it! You’ve successfully formatted and mounted an Ext4 filesystem in Linux. This is the most common and beginner-friendly setup for secondary storage in Linux environments, including servers and desktops.

For advanced setups, you can explore LVM on top of Ext4, encryption with LUKS, or performance tuning using mount options.

© 2025 wowstorage.com | ← Back to Filesystems Guide

Related Posts

Featured imageFeatured image
Understanding Linux Filesystems (Ext4, XFS, Btrfs, ZFS)
Introduction In the world of Linux, filesystems are critical for ensuring...
Featured imageFeatured image
Innovative business strategies to boost your company’s...
This is placeholder text for a H2 headline Lorem ipsum amet...
Featured imageFeatured image
The rise of artificial intelligence in everyday...
This is placeholder text for a H2 headline Lorem ipsum amet...

Leave a Comment