How to Create XFS Filesystem in Redhat Linux 7

As you must be knowing XFS is now the default filesystem in Red Hat Linux 7 and has many benefits over EXT4 and other filesystems, so we thought to create tutorial on it. XFS was created by Silicon Graphics, Inc (SGI) in 1993. In this tutorial we will guide you on creating an XFS filesystem in Red hat Enterprise Linux 7.


How to Create XFS Filesystem in Redhat Linux 7


Benefits of XFS Filesystem


  • High-performance file system.
  • Highly scalable.
  • Metadata journaling which supports quicker crash recovery.
  • Sub-second timestamps.
  • Can also be defragmented and enlarged.
  • Quota Journaling
  • Excellent Bandwidth
  • Good for very large file systems


Steps to Create XFS filesystem on RHEL 7


Creating XFS filesystem is similar like creating any other filesystem. After a disk is assigned to UNIX/Linux server, use below steps to create new XFS filesystem in Red hat Linux 7.


1. After you have the raw storage disk, you can use the “mkfs.xfs” command.


Note: When using mkfs.xfs on a block device containing an existing file system, use the -f option to force an overwrite of that file system.


Example: Suppose we have a device called “/dev/sdc” and we want to use this device for creating a new filesystem for our use with XFS, so will use below syntax. First, we have created the partition of the device and then formatted it with XFS.



mkfs.xfs /dev/device


mkfs.xfs /dev/sdc1


[root@dev1 ~]# mkfs.xfs /dev/sdc1
meta-data=/dev/sdc1              isize=256    agcount=4, agsize=12992 blks
         =                       sectsz=512   attr=2, projid32bit=1
         =                       crc=0
data     =                       bsize=4096   blocks=51968, imaxpct=25
         =                       sunit=0      swidth=0 blks
naming   =version 2              bsize=4096   ascii-ci=0 ftype=0
log      =internal log           bsize=4096   blocks=853, version=2
         =                       sectsz=512   sunit=0 blks, lazy-count=1
realtime =none                   extsz=4096   blocks=0, rtextents=0


2. After creating your XFS filesystem you can mount it using “mount” command and for permanent mounting do entry in /etc/fstab file. First create directory where you want to mount the filesystem and then use mount command to mount it. Below is the example for your reference.



# mount /dev/device /mount/point
[root@dev1 ~]# mkdir /xfs-filesystem
[root@dev1 ~]# mount /dev/sdc1 /xfs-filesystem/
[root@dev1 ~]# cd /xfs-filesystem/
[root@dev1 xfs-filesystem]# ls -al
total 4
drwxr-xr-x.  2 root root    6 May 23 02:25 .
drwxr-xr-x. 20 root root 4096 May 23 02:25 ..
[root@dev1 xfs-filesystem]# touch file{1..4}
[root@dev1 xfs-filesystem]# ll
total 0
-rw-r--r--. 1 root root 0 May 23 02:26 file1
-rw-r--r--. 1 root root 0 May 23 02:26 file2
-rw-r--r--. 1 root root 0 May 23 02:26 file3
-rw-r--r--. 1 root root 0 May 23 02:26 file4


In the above example, we have also created some test files to test the filesystem. Now, in future if your filesystem is full, you can easily expand your XFS filesystem. We have also created video tutorial for creating XFS filesystem in RHEL 7 for better understanding. Watch video below.



Do let us know your feedback on this tutorial and if you have any questions, don’t forget to ask through comments and emails. If you like our tutorial, do share it with others.

Add Comment

This site uses Akismet to reduce spam. Learn how your comment data is processed.