4.3. Creating an ext4 File System


After installation, it is sometimes necessary to create a new ext4 file system. For example, if you add a new disk drive to the system, you may want to partition the drive and use the ext4 file system.
The default options are optimal for most usage scenarios but if you need to set your ext4 file system in a specific way, see manual pages for the mke4fs and mkfs.ext4 commands for available options. Also, you may want to examine and modify the configuration file of mke4fs, /etc/mke4fs.conf, if you plan to create ext4 file systems more often.
The steps for creating an ext4 file system are as follows:
  1. Format the partition with the ext4 file system using the mkfs.ext4 or mke4fs command:
    ~]# mkfs.ext4 block_device
    ~]# mke4fs -t ext4 block_device
    where block_device is a partition which will contain the ext4 filesystem you wish to create.
  2. Label the partition using the e4label command.
    ~]# e4label <block_device> new-label
  3. Create a mount point and mount the new file system to that mount point:
    ~]# mkdir /mount/point
    ~]# mount block_device /mount/point
A valid block device could be one of two types of entries:
  • A mapped device — A logical volume in a volume group, for example, /dev/mapper/VolGroup00-LogVol02.
  • A static device — A traditional storage volume, for example, /dev/hdbX, where hdb is a storage device name and X is the partition number.
For striped block devices (for example RAID5 arrays), the stripe geometry can be specified at the time of file system creation. Using proper stripe geometry greatly enhances performance of an ext4 file system.
When creating file systems on lvm or md volumes, mkfs.ext4 chooses an optimal geometry. This may also be true on some hardware RAIDs which export geometry information to the operating system.
To specify stripe geometry, use the -E option of mkfs.ext4 (that is, extended file system options) with the following sub-options:
stride=value
Specifies the RAID chunk size.
stripe-width=value
Specifies the number of data disks in a RAID device, or the number of stripe units in the stripe.
For both sub-options, value must be specified in file system block units. For example, to create a file system with a 64k stride (that is, 16 x 4096) on a 4k-block file system, use the following command:
~]# mkfs.ext4 -E stride=16,stripe-width=64 block_device
For more information about creating file systems, refer to man mkfs.ext4.
Red Hat logoGithubRedditYoutubeTwitter

Learn

Try, buy, & sell

Communities

About Red Hat Documentation

We help Red Hat users innovate and achieve their goals with our products and services with content they can trust.

Making open source more inclusive

Red Hat is committed to replacing problematic language in our code, documentation, and web properties. For more details, see the Red Hat Blog.

About Red Hat

We deliver hardened solutions that make it easier for enterprises to work across platforms and environments, from the core datacenter to the network edge.

© 2024 Red Hat, Inc.