mkfs.xfs

From RaySoft

mkfs.xfs constructs an XFS filesystem by writing on a special file using the values found in the arguments of the command line. It is invoked automatically by mkfs when it is given the -t xfs option.[1]

Documentation

Syntax

mkfs.xfs [PARAMETER ...] [DEVICE]

Parameters

-b OPTIONS
This option specifies the fundamental block size of the filesystem. The valid OPTIONS are: log=value or size=value and only one can be supplied. The block size is specified either as a base two logarithm value with log=, or in bytes with size=. The default value is 4096 bytes (4 KiB), the minimum is 512, and the maximum is 65536 (64 KiB). XFS on Linux currently only supports pagesize or smaller blocks.
-d OPTIONS
These options specify the location, size, and other parameters of the data section of the filesystem. The valid OPTIONS are:
agcount=value
This is used to specify the number of allocation groups. The data section of the filesystem is divided into allocation groups to improve the performance of XFS. More allocation groups imply that more parallelism can be achieved when allocating blocks and inodes. The minimum allocation group size is 16 MiB; the maximum size is just under 1 TiB. The data section of the filesystem is divided into value allocation groups (default value is scaled automatically based on the underlying device size).
agsize=value
This is an alternative to using the agcount suboption. The value is the desired size of the allocation group expressed in bytes (usually using the m or g suffixes). This value must be a multiple of the filesystem block size, and must be at least 16MiB, and no more than 1TiB, and may be automatically adjusted to properly align with the stripe geometry. The agcount and agsize suboptions are mutually exclusive.
name=value
This can be used to specify the name of the special file containing the filesystem. In this case, the log section must be specified as internal (with a size, see the -l option below) and there can be no real-time section.
file[=value]
This is used to specify that the file given by the name suboption is a regular file. The value is either 0 or 1, with 1 signifying that the file is regular. This suboption is used only to make a filesystem image. If the value is omitted then 1 is assumed.
size=value
This is used to specify the size of the data section. This suboption is required if -d file[=1] is given. Otherwise, it is only needed if the filesystem should occupy less space than the size of the special file.
sunit=value
This is used to specify the stripe unit for a RAID device or a logical volume. The value has to be specified in 512-byte block units. Use the su suboption to specify the stripe unit size in bytes. This suboption ensures that data allocations will be stripe unit aligned when the current end of file is being extended and the file size is larger than 512KiB. Also inode allocations and the internal log will be stripe unit aligned.
su=value
This is an alternative to using sunit. The su suboption is used to specify the stripe unit for a RAID device or a striped logical volume. The value has to be specified in bytes, (usually using the m or g suffixes). This value must be a multiple of the filesystem block size.
swidth=value
This is used to specify the stripe width for a RAID device or a striped logical volume. The value has to be specified in 512-byte block units. Use the sw suboption to specify the stripe width size in bytes. This suboption is required if -d sunit has been specified and it has to be a multiple of the -d sunit suboption.
sw=value
suboption is an alternative to using swidth. The sw suboption is used to specify the stripe width for a RAID device or striped logical volume. The value is expressed as a multiplier of the stripe unit, usually the same as the number of stripe members in the logical volume configuration, or data disks in a RAID device.
When a filesystem is created on a logical volume device, mkfs.xfs will automatically query the logical volume for appropriate sunit and swidth values.
-f
Force overwrite when an existing filesystem is detected on the device. By default, mkfs.xfs will not write to the device if it suspects that there is a filesystem or partition table on the device already.
-i OPTIONS
This option specifies the inode size of the filesystem, and other inode allocation parameters. The XFS inode contains a fixed-size part and a variable-size part. The variable-size part, whose size is affected by this option, can contain: directory data, for small directories; attribute data, for small attribute sets; symbolic link data, for small symbolic links; the extent list for the file, for files with a small number of extents; and the root of a tree describing the location of extents for the file, for files with a large number of extents. The valid OPTIONS:
size=value | log=value | perblock=value
The inode size is specified either as a value in bytes with size=, a base two logarithm value with log=, or as the number fitting in a filesystem block with perblock=. The mininum (and default) value is 256 bytes. The maximum value is 2048 (2 KiB) subject to the restriction that the inode size cannot exceed one half of the filesystem block size.
XFS uses 64-bit inode numbers internally; however, the number of significant bits in an inode number is affected by filesystem geometry. In practice, filesystem size and inode size are the predominant factors. The Linux kernel (on 32 bit hardware platforms) and most applications cannot currently handle inode numbers greater than 32 significant bits, so if no inode size is given on the command line, mkfs.xfs will attempt to choose a size such that inode numbers will be < 32 bits. If an inode size is specified, or if a filesystem is sufficently large, mkfs.xfs will warn if this will create inode numbers > 32 significant bits.
maxpct=value
This specifies the maximum percentage of space in the filesystem that can be allocated to inodes. The default value is 25%. Setting the value to 0 means that essentially all of the filesystem can become inode blocks.
align[=value]
This is used to specify that inode allocation is or is not aligned. The value is either 0 or 1, with 1 signifying that inodes are allocated aligned. If the value is omitted, 1 is assumed. The default is that inodes are aligned. Aligned inode access is normally more efficient than unaligned access; alignment must be established at the time the filesystem is created, since inodes are allocated at that time. This option can be used to turn off inode alignment when the filesystem needs to be mountable by a version of IRIX that does not have the inode alignment feature (any release of IRIX before 6.2, and IRIX 6.2 without XFS patches).
attr[=value]
This is used to specify the version of extended attribute inline allocation policy to be used. By default, this is zero. Once extended attributes are used for the first time, the version will be set to either one or two. The current version (two) uses a more efficient algorithm for managing the available inline inode space than version one does, however, for backward compatibility reasons (and in the absence of the attr=2 mkfs option, or the attr2 mount option), version one will be selected by default when attributes are first used on a filesystem.
-l OPTIONS
These options specify the location, size, and other parameters of the log section of the filesystem. The OPTIONS are:
internal[=value]
This is used to specify that the log section is a piece of the data section instead of being another device or logical volume. The value is either 0 or 1, with 1 signifying that the log is internal. If the value is omitted, 1 is assumed.
logdev=device
This is used to specify that the log section should reside on the device separate from the data section. The internal=1 and logdev options are mutually exclusive.
size=value
This is used to specify the size of the log section.
If the log is contained within the data section and size isn't specified, mkfs.xfs will try to select a suitable log size depending on the size of the filesystem. The actual logsize depends on the filesystem block size and the directory block size.
Otherwise, the size suboption is only needed if the log section of the filesystem should occupy less space than the size of the special file. The value is specified in bytes or blocks, with a b suffix meaning multiplication by the filesystem block size, as described above. The overriding minimum value for size is 512 blocks. With some combinations of filesystem block size, inode size, and directory block size, the minimum log size is larger than 512 blocks.
version=value
This specifies the version of the log. The value is either 1 or 2. Specifying version=2 enables the sunit suboption, and allows the logbsize to be increased beyond 32K. Version 2 logs are automatically selected if a log stripe unit is specified. See sunit and su suboptions, below.
sunit=value
This specifies the alignment to be used for log writes. The value has to be specified in 512-byte block units. Use the su suboption to specify the log stripe unit size in bytes. Log writes will be aligned on this boundary, and rounded up to this boundary. This gives major improvements in performance on some configurations such as software RAID5 when the sunit is specified as the filesystem block size. The equivalent byte value must be a multiple of the filesystem block size. Version 2 logs are automatically selected if the log sunit suboption is specified.
The su suboption is an alternative to using sunit.
su=value
This is used to specify the log stripe. The value has to be specified in bytes, (usually using the s or b suffixes). This value must be a multiple of the filesystem block size. Version 2 logs are automatically selected if the log su suboption is specified.
lazy-count=value
This changes the method of logging various persistent counters in the superblock. Under metadata intensive workloads, these counters are updated and logged frequently enough that the superblock updates become a serialisation point in the filesystem. The value can be either 0 or 1.
With lazy-count=1, the superblock is not modified or logged on every change of the persistent counters. Instead, enough information is kept in other parts of the filesystem to be able to maintain the persistent counter values without needed to keep them in the superblock. This gives significant improvements in performance on some configurations. The default value is 0 (off) so you must specify lazy-count=1 if you want to make use of this feature.
-L LABEL
Set the filesystem LABEL. XFS filesystem labels can be at most 12 characters long; if label is longer than 12 characters, mkfs.xfs will not proceed with creating the filesystem. Refer to the mount and xfs_admin manual entries for additional information.
-n OPTIONS
These options specify the version and size parameters for the naming (directory) area of the filesystem. The valid OPTIONS:
size=value | log=value
The block size is specified either as a value in bytes with size=, or as a base two logarithm value with log=. The default size value for version 2 directories is 4096 bytes (4 KiB), unless the filesystem block size is larger than 4096, in which case the default value is the filesystem block size. For version 1 directories the block size is the same as the filesystem block size.
version=value
The naming (directory) version value can be either 1 or 2, defaulting to 2 if unspecified. With version 2 directories, the directory block size can be any power of 2 size from the filesystem block size up to 65536.
-N
Causes the file system parameters to be printed out without really creating the file system.
-p FILE
If the optional -p FILE argument is given, mkfs.xfs uses FILE as a prototype file and takes its directions from that file. The blocks and inodes specifiers in the FILE are provided for backwards compatibility, but are otherwise unused. The syntax of the FILE is defined by a number of tokens separated by spaces or newlines.
-q
Quiet option. Normally mkfs.xfs prints the parameters of the filesystem to be constructed; the -q flag suppresses this.
-r OPTIONS
These options specify the location, size, and other parameters of the real-time section of the filesystem. The valid OPTIONS are:
rtdev=device
This is used to specify the device which should contain the real-time section of the filesystem. The suboption value is the name of a block device.
extsize=value
This is used to specify the size of the blocks in the real-time section of the filesystem. This value must be a multiple of the filesystem block size. The minimum allowed size is the filesystem block size or 4 KiB (whichever is larger); the default size is the stripe width for striped volumes or 64 KiB for non-striped volumes; the maximum allowed size is 1 GiB. The real-time extent size should be carefully chosen to match the parameters of the physical media used.
size=value
This is used to specify the size of the real-time section. This suboption is only needed if the real-time section of the filesystem should occupy less space than the size of the partition or logical volume containing the section.
-s SIZE
This option specifies the fundamental sector SIZE of the filesystem. The sector_size is specified either as a value in bytes with size=value or as a base two logarithm value with log=value. The default sector_size is 512 bytes. The minimum value for sector size is 512; the maximum is 32768 (32 KiB). The sector_size must be a power of 2 size and cannot be made larger than the filesystem block size.

Examples

Create a XFS partition on /dev/hda3
mkfs.xfs -f -b 'size=2048' '/dev/hda3'

References

  1. man 8 'mkfs.xfs'