XFS is a high-performance file system for Linux designed to handle large files and handle high-performance I/O operations. XFS supports metadata journaling, which allows for rapid recovery in the event of a crash, and it also supports advanced features such as online resizing. The XFS filesystem has significant importance on servers and workstations, as well as for large storage arrays and high-performance computing clusters.
This article will explain the step-by-step instructions to create an XFS filesystem in Linux.
- How to Create an XFS Filesystem?
- Prerequisites: Install the xfsprogs Package
- Check the Partition For XFS FileSystem
- Specify the Partition to Create XFS Filesystem
- Set the File System Block Size
- Mount the File System
- Verify XFS Filesystem
How to Create an XFS Filesystem?
This section enlists the steps to create an XFS file system on Linux machines:
Prerequisite: Install the xfsprogs Package
The xfsprogs package, along with all dependencies, the installation commands of the “xfsprogs” package of different Linux distributions are provided below:
$ sudo apt install xfsprogs # Ubuntu, Debian, LinuxMint
$ sudo dnf install xfsprogs # Fedora
$ sudo yum install xfsprogs # CentOS
Step 1: Check the Partition For XFS FileSystem
Check the partition in the operating system using the command “fdisk -l” or “lsblk” commands. In our case, the “lsblk” command is utilized to visualize the partition size:
$ lsblk
Step 2: Specify the Partition to Create XFS Filesystem
To create an XFS file system in Linux, use the “mkfs.xfs” command by specifying the partition name. For instance, create an XFS file system on a partition called “/dev/sda2” as below:
$ sudo mkfs.xfs /dev/sda2
This command formats the partition and installs the XFS file system on “/dev/sda2”.
(Optional) Set the File System Block Size
You can set the block size for fine-tuning the filesystem as we set the block size to 64K using the “b” option:
$ sudo mkfs.xfs -f -b size=64k /dev/sda2
The output shows that “64K” has been assigned to “/dev/sda2” to create the XFS filesystem in Linux.
Step 3: Mount the File System
To mount the file system, use the “mount” command by specifying the partition as “/dev/sda2” and the mount point as “/mnt/” in the below script:
$ sudo mount /dev/sda2 /mnt/
This command will mount the filesystem to “/mnt” directory.
Step 4: Verify XFS Filesystem
Finally, users can check the mounted file system by using the “modinfo” command by specifying the “xfs” it shows detailed information about the XFS system:
$ modinfo xfs
The output displays the “filename”, “license”, “description” and many more in the terminal.
Conclusion
The XFS file system can be created using the command “sudo mkfs.xfs<partition-name>”. Before this, it is necessary to install the “xfsprogs” package in the operating system. Additionally, users can set the block size for the XFS filesystem. This article has explained the step-by-step instructions to create the XFS filesystem in Linux.