Creating and Mounting an Ext File System

Use the mkfs.ext4 command to create an XFS file system on a block device, such as a partition, an LVM volume, a disk, or a similar hardware device.

You create Ext file systems by using the mkfs.ext4 command. The default options for the command are appropriate for most common use cases. For more information, see the mkfs.ext4(8) manual page.

Note that you can also format a device with Ext 2 or Ext 3 by using the mkfs.ext2 or mkfs.ext3 commands, instead.

  1. Identify the target device, partition, or file that you want to format with Ext.

    Typically, you might use the lsblk command to list block devices and partitions that are available to the system.

    Note that formatting a file system is a destructive operation and erases any data on the target device. Ensure that the following steps use the correct target device or file paths.

  2. To create an Ext4 file system on a device, run:
    sudo mkfs.ext4 [options] <device>

    For example, to format a file system on the device /dev/sdb1 with the default options, run:

    sudo mkfs.ext4 /dev/sdb1

    Use the appropriate flags to set any custom options on the file system if you need to do so.

  3. Mount the file system.

    For example, you can run:

    sudo mount /dev/sdb /mnt
  4. Validate the file system, by checking file system information with the dumpe2fs command.

    For example, you can run:

    dumpe2fs -h /dev/sdb