Skip to main content
In this lesson, you will learn how to create and configure file systems on a storage partition. By default, Red Hat operating systems use the XFS file system while Ubuntu typically uses ext4. Keep in mind that these default choices may evolve with newer OS releases.

Creating an XFS File System

To format a partition with the XFS file system, run the following command. In this example, /dev/sdb1 is the target partition:
The mkfs command stands for “make file system.” If you prefer an ext4 file system instead, simply change the suffix as shown below:
Most file systems are created with default settings that cater to standard use cases. However, you may need to adjust specific parameters—like setting a custom label or modifying the inode size—using additional command-line options. For a complete list of available options, consult the manual page:
The manual displays options specific to XFS. For example, the -L option lets you assign a label to your file system. Consider these examples:
If you search within the manual by typing the forward slash and then -L, you’ll notice that the label must not exceed 12 characters. To set the label “BackupVolume” on /dev/sdb1, execute:
Before making any changes, verify your devices by listing available file systems. Below is a sample output from using fdisk:
To modify additional settings, such as setting a custom inode size of 512 bytes, use the -i option:
If an existing file system is detected, the utility will display a warning similar to:
Ensure you have the correct partition selected before using the -f option, as it will force an overwrite of any existing file system.
To force a format that includes a 512-byte inode size and a custom label, combine the options as follows:
Upon successful execution, you will see output that details parameters such as inode size, allocation groups, block size, and related metadata.

XFS Administrative Utilities

XFS comes with a suite of administrative utilities. By typing xfs and pressing the Tab key, you can view available XFS-related commands. One of the most useful utilities is xfs_admin, which enables you to modify file system properties. For example, to display the current label for /dev/sdb1, run:
To change the label to “FirstFS” (note the uppercase -L), execute:

Creating and Configuring an ext4 File System

Ubuntu and similar distributions often utilize the ext4 file system by default. To view configuration options for ext4, refer to the manual page of mkfs.ext4, which internally calls the mke2fs program:
The manual details various options for setting block size, inode count, file system label, and more. To create an ext4 file system with default settings on /dev/sdb2, use the command:
The output might resemble the following:
Running the command again on the same partition will trigger a warning that a file system already exists, preventing accidental overwrites. For scenarios where a higher number of inodes is required—especially on systems handling many small files—use the -N option to specify the exact number of inodes:
Remember, in ext4, each file or directory uses an inode. Even with ample disk space, a shortage of inodes can restrict file creation.

Managing ext4 File System Properties

The tune2fs utility allows you to display and modify ext4 file system properties. To view current properties of /dev/sdb2, run:
Although the exact command to change the label with tune2fs is not included here, the manual provides detailed guidance for modifying properties, including updating the label to “SecondFS” using the appropriate options. Finally, tools like cfdisk can be used to inspect the /dev/sdb device, ensuring that partitions have the correct file system types and labels. In our demonstration, the XFS file system was labeled “FirstFS” and the ext4 file system on /dev/sdb2 was set to “SecondFS.”
This concludes our lesson on creating and configuring file systems with XFS and ext4. For detailed reference material and further reading, consider reviewing the following resources:

Watch Video