How to Mount XFS Filesystem

Last updated: July 5, 2022 | Linuxopsys

XFS is a high-performance 64-bit journaling file system created by SGI in 1993. It was introduced in the Linux kernel in 2001, XFS is supported by most Linux distributions, some of which use it as the default file system (RHEL/CentOS Stream).

XFS excels in the execution of parallel input/output (I/O) operations due to its design, which is based on allocation groups, because of this, XFS enables extreme scalability of I/O threads, file system bandwidth, and size of files and of the file system itself when spanning multiple physical storage devices. A disadvantage of the XFS file system is that it cannot be shrink, also metadata operations in have historically been slower than with other file systems, resulting in, for example, poor performance with operations such as deletions of large numbers of files. FAQ of xfs.org is a good place to read before you start implementing this filesystem.

In this guide, we focus on how to mount XFS filesystem.

Mounting XFS filesystem

To illustrate let's first create a partition and add xfs filesystem on it.

To create a new XFS file system you will first need a partition to format. You can use fdisk to create a new partition.

fdisk /dev/sdb
create a partition for xfs using fdisk

If the partition you want to format as XFS already exists on the system you must make sure it's not mounted by using the command umount command like this:

# umount /dev/sdb1

/dev/sdb1 should of course be replaced by the name of the partition you want to use.

Now that your partition is ready you can create an XFS filesystem by using the mkfs.xfs command, with the name of the partition you created like this:

# mkfs.xfs /dev/sdb1
add xfs filesystem

To mount the newly created partition you will have to first create a directory to be a mount point with the mkdir command, in our example we will use /mnt/db. Next, you can mount the xfs parttion using the mount command as you would with any partition. Afterward, you can use the mount command to check if the partition was correctly mounted.

# mkdir /mnt/db
# mount /dev/sdb1 /mnt/db
# mount | grep /dev/sdb1
mount xfs

If you have an environment with a filesystem above 2 TB, you could try benchmark with mounting with inode64 option.

# mount -o inode64 /dev/device /mount/point

XFS enable write barriers to ensure file system integrity which preserves it across power failure, interface resets, system crashes by default.  If your hardware has a healthy write cache feature then it's recommended to disable write barriers otherwise performance would be negatively affected. You can disable write barrier using mount option below.

# mount -o nobarrier /dev/device /mount/point

Conclusion

In this guide, we learned how to mount XFS filesystem and its options.

Thanks for reading, please provide your feedback and suggestion in the comment section.

SHARE

Comments

Please add comments below to provide the author your ideas, appreciation and feedback.

Leave a Reply

Leave a Comment