To create an XFS file system, use the mkfs. xfs /dev/device command. In general, the default options are optimal for common use.

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.

Create an XFS filesystem on regular disk

Run command

mkfs -t xfs <blockdev>


mkfs.xfs <blockdev>

Below is a sample output of the mkfs. xfs command:

meta-data=/dev/<blkdev>          isize=256    agcount=4, agsize=100663296 blks
         =                       sectsz=512   attr=2, projid32bit=1
         =                       crc=0        finobt=0
data     =                       bsize=4096   blocks=402653184, imaxpct=5
         =                       sunit=0      swidth=0 blks
naming   =version 2              bsize=4096   ascii-ci=0 ftype=0
log      =internal log           bsize=4096   blocks=196608, version=2
         =                       sectsz=512   sunit=0 blks, lazy-count=1
realtime =none                   extsz=4096   blocks=0, rtextents=0


After an XFS file system is created, its size cannot be reduced. However, it can still be enlarged using the xfs_g rowfs command.

Unlike mke2fs, mkfs.xfs does not utilize a configuration file, they are all specified on the command line.

Create an XFS on striped block devices

For striped block devices (for example, RAID 5 arrays), the stripe geometry can be specified at the time of file system creation. Using proper stripe geometry greatly enhances the performance of an XFS filesystem.

When creating filesystems on LVM or MD volumes, mkfs. xfs chooses an optimal geometry. This may also be true on some hardware RAID s that export geometry information to the operating system.
If the device exports stripe geometry information, mkfs (for ext3, ext4, and xfs) will automatically use this geometry. If stripe geometry is not detected by mkfs and even though the storage does, in fact, have stripe geometry, it is possible to manually specify it at mkfs time using the following options:

su = value
Specifies a stripe unit or RAID chunk size. The value must be specified in bytes, with an optional k, m, or g suffix.
sw= value
Specifies the number of data disks in a RAID device, or the number of stripe units in the stripe.

The following example specifies a chunk size of 64k on a RAID device containing 4 stripe units:

# mkfs. xfs -d su= 64k,sw= 4 /dev/device

Mount an XFS File System

It's same as mounting other file systems

mount /dev/device /mount/point


Mount an XFS File System with Barriers

By default, XFS uses write barriers to ensure file system integrity even when power is lost to a device with write caches enabled. For devices without write caches, or with battery-backed write caches, disable the barriers by using the no barri er option:

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


Comments powered by CComment