Linux "mkfs.xfs" Command Line Options and Examples
construct an XFS filesystem

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(8) when it is given the -t xfs option.


Usage:

mkfs.xfs [ -b block_size ] [ -m global_metadata_options ] [ -d data_section_options ] [ -f ] [ -i inode_options ] [ -l log_sec‐
tion_options ] [ -n naming_options ] [ -p protofile ] [ -q ] [ -r realtime_section_options ] [ -s sector_size ] [ -L label ] [ -N ] [
-K ] device
mkfs.xfs -V






Command Line Options:

-b
This option specifies the fundamental block size of the filesystem. The valid block_size_options are: log=value or size=valueand only one can be supplied. The block size is specified either as a base two logarithm value with log=, or in bytes withsize=. The default value is 4096 bytes (4 KiB), the minimum is 512, and the maximum is 65536 (64 KiB).To specify any options on the command line in units of filesystem blocks, this option must be specified first so that thefilesystem block size is applied consistently to all options.Although mkfs.xfs will accept any of these values and create a valid filesystem, XFS on Linux can only mount filesystems withpagesize or smaller blocks.
mkfs.xfs -b ...
-m
These options specify metadata format options that either apply to the entire filesystem or aren't easily characterised by aspecific functionality group. The valid global_metadata_options are:crc=valueThis is used to create a filesystem which maintains and checks CRC information in all metadata objects on disk.The value is either 0 to disable the feature, or 1 to enable the use of CRCs.CRCs enable enhanced error detection due to hardware issues, whilst the format changes also improves crash recov‐ery algorithms and the ability of various tools to validate and repair metadata corruptions when they are found.The CRC algorithm used is CRC32c, so the overhead is dependent on CPU architecture as some CPUs have hardwareacceleration of this algorithm. Typically the overhead of calculating and checking the CRCs is not noticeable innormal operation.By default, mkfs.xfs will enable metadata CRCs.finobt=valueThis option enables the use of a separate free inode btree index in each allocation group. The value is either 0to disable the feature, or 1 to create a free inode btree in each allocation group.The free inode btree mirrors the existing allocated inode btree index which indexes both used and free inodes. Thefree inode btree does not index used inodes, allowing faster, more consistent inode allocation performance asfilesystems age.By default, mkfs.xfs will create free inode btrees for filesystems created with the (default) -m crc=1 option set.When the option -m crc=0 is used, the free inode btree feature is not supported and is disabled.uuid=valueUse the given value as the filesystem UUID for the newly created filesystem. The default is to generate a randomUUID.rmapbt=valueThis option enables the creation of a reverse-mapping btree index in each allocation group. The value is either 0to disable the feature, or 1 to create the btree.The reverse mapping btree maps filesystem blocks to the owner of the filesystem block. Most of the mappings willbe to an inode number and an offset, though there will also be mappings to filesystem metadata. This secondarymetadata can be used to validate the primary metadata or to pinpoint exactly which data has been lost when a diskerror occurs.By default, mkfs.xfs will not create reverse mapping btrees. This feature is only available for filesystems cre‐ated with the (default) -m crc=1 option set. When the option -m crc=0 is used, the reverse mapping btree featureis not supported and is disabled.reflink=valueThis option enables the use of a separate reference count btree index in each allocation group. The value iseither 0 to disable the feature, or 1 to create a reference count btree in each allocation group.The reference count btree enables the sharing of physical extents between the data forks of different files, whichis commonly known as "reflink". Unlike traditional Unix filesystems which assume that every inode and logicalblock pair map to a unique physical block, a reflink-capable XFS filesystem removes the uniqueness requirement,allowing up to four billion arbitrary inode/logical block pairs to map to a physical block. If a program tries towrite to a multiply-referenced block in a file, the write will be redirected to a new block, and that file's logi‐cal-to-physical mapping will be changed to the new block ("copy on write"). This feature enables the creation ofper-file snapshots and deduplication. It is only available for the data forks of regular files.By default, mkfs.xfs will not create reference count btrees and therefore will not enable the reflink feature.This feature is only available for filesystems created with the (default) -m crc=1 option set. When the option -mcrc=0 is used, the reference count btree feature is not supported and reflink is disabled.
mkfs.xfs -m ...
-d
These options specify the location, size, and other parameters of the data section of the filesystem. The valid data_sec‐tion_options are:agcount=valueThis is used to specify the number of allocation groups. The data section of the filesystem is divided into allo‐cation groups to improve the performance of XFS. More allocation groups imply that more parallelism can beachieved when allocating blocks and inodes. The minimum allocation group size is 16 MiB; the maximum size is justunder 1 TiB. The data section of the filesystem is divided into value allocation groups (default value is scaledautomatically based on the underlying device size).agsize=valueThis is an alternative to using the agcount suboption. The value is the desired size of the allocation groupexpressed in bytes (usually using the m or g suffixes). This value must be a multiple of the filesystem blocksize, and must be at least 16MiB, and no more than 1TiB, and may be automatically adjusted to properly align withthe stripe geometry. The agcount and agsize suboptions are mutually exclusive.name=valueThis can be used to specify the name of the special file containing the filesystem. In this case, the log sectionmust 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 valueis omitted then 1 is assumed.size=valueThis is used to specify the size of the data section. This suboption is required if -d file[=1] is given. Other‐wise, it is only needed if the filesystem should occupy less space than the size of the special file.sunit=valueThis is used to specify the stripe unit for a RAID device or a logical volume. The value has to be specified in512-byte block units. Use the su suboption to specify the stripe unit size in bytes. This suboption ensures thatdata allocations will be stripe unit aligned when the current end of file is being extended and the file size islarger than 512KiB. Also inode allocations and the internal log will be stripe unit aligned.su=valueThis is an alternative to using sunit. The su suboption is used to specify the stripe unit for a RAID device or astriped logical volume. The value has to be specified in bytes, (usually using the m or g suffixes). This valuemust be a multiple of the filesystem block size.swidth=valueThis is used to specify the stripe width for a RAID device or a striped logical volume. The value has to be speci‐fied in 512-byte block units. Use the sw suboption to specify the stripe width size in bytes. This suboption isrequired if -d sunit has been specified and it has to be a multiple of the -d sunit suboption.sw=valuesuboption is an alternative to using swidth. The sw suboption is used to specify the stripe width for a RAIDdevice or striped logical volume. The value is expressed as a multiplier of the stripe unit, usually the same asthe 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 forappropriate sunit and swidth values.noalignThis option disables automatic geometry detection and creates the filesystem without stripe geometry alignmenteven if the underlying storage device provides this information.
mkfs.xfs -d ...
-i
This option specifies the inode size of the filesystem, and other inode allocation parameters. The XFS inode contains afixed-size part and a variable-size part. The variable-size part, whose size is affected by this option, can contain: direc‐tory data, for small directories; attribute data, for small attribute sets; symbolic link data, for small symbolic links; theextent list for the file, for files with a small number of extents; and the root of a tree describing the location of extentsfor the file, for files with a large number of extents.The valid inode_options are:size=value | log=value | perblock=valueThe inode size is specified either as a value in bytes with size=, a base two logarithm value with log=, or as thenumber fitting in a filesystem block with perblock=. The minimum (and default) value is 256 bytes without crc,512 bytes with crc enabled. The maximum value is 2048 (2 KiB) subject to the restriction that the inode size can‐not 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 affectedby filesystem geometry. In practice, filesystem size and inode size are the predominant factors. The Linux ker‐nel (on 32 bit hardware platforms) and most applications cannot currently handle inode numbers greater than 32significant bits, so if no inode size is given on the command line, mkfs.xfs will attempt to choose a size suchthat inode numbers will be < 32 bits. If an inode size is specified, or if a filesystem is sufficiently large,mkfs.xfs will warn if this will create inode numbers > 32 significant bits.maxpct=valueThis specifies the maximum percentage of space in the filesystem that can be allocated to inodes. The defaultvalue is 25% for filesystems under 1TB, 5% for filesystems under 50TB and 1% for filesystems over 50TB.In the default inode allocation mode, inode blocks are chosen such that inode numbers will not exceed 32 bits,which restricts the inode blocks to the lower portion of the filesystem. The data block allocator will avoid theselow blocks to accommodate the specified maxpct, so a high value may result in a filesystem with nothing but inodesin a significant portion of the lower blocks of the filesystem. (This restriction is not present when thefilesystem is mounted with the inode64 option on 64-bit platforms).Setting the value to 0 means that essentially all of the filesystem can become inode blocks, subject to inode32restrictions.This value can be modified with xfs_growfs(8).align[=value]This is used to specify that inode allocation is or is not aligned. The value is either 0 or 1, with 1 signifyingthat 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 timethe filesystem is created, since inodes are allocated at that time. This option can be used to turn off inodealignment when the filesystem needs to be mountable by a version of IRIX that does not have the inode alignmentfeature (any release of IRIX before 6.2, and IRIX 6.2 without XFS patches).attr=valueThis is used to specify the version of extended attribute inline allocation policy to be used. By default, thisis 2, which uses an efficient algorithm for managing the available inline inode space between attribute and extentdata.The previous version 1, which has fixed regions for attribute and extent data, is kept for backwards compatibilitywith kernels older than version 2.6.16.projid32bit[=value]This is used to enable 32bit quota project identifiers. The value is either 0 or 1, with 1 signifying that 32bitprojid are to be enabled. If the value is omitted, 1 is assumed. (This default changed in release version3.2.0.)sparse[=value]Enable sparse inode chunk allocation. The value is either 0 or 1, with 1 signifying that sparse allocation isenabled. If the value is omitted, 1 is assumed. Sparse inode allocation is disabled by default. This feature isonly available for filesystems formatted with -m crc=1.When enabled, sparse inode allocation allows the filesystem to allocate smaller than the standard 64-inode chunkwhen free space is severely limited. This feature is useful for filesystems that might fragment free space overtime such that no free extents are large enough to accommodate a chunk of 64 inodes. Without this feature enabled,inode allocations can fail with out of space errors under severe fragmented free space conditions.
mkfs.xfs -i ...
-l
These options specify the location, size, and other parameters of the log section of the filesystem. The valid log_sec‐tion_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 orlogical volume. The value is either 0 or 1, with 1 signifying that the log is internal. If the value is omitted, 1is assumed.logdev=deviceThis is used to specify that the log section should reside on the device separate from the data section. Theinternal=1 and logdev options are mutually exclusive.size=valueThis 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 suitablelog size depending on the size of the filesystem. The actual logsize depends on the filesystem block size and thedirectory block size.Otherwise, the size suboption is only needed if the log section of the filesystem should occupy less space thanthe size of the special file. The value is specified in bytes or blocks, with a b suffix meaning multiplication bythe filesystem block size, as described above. The overriding minimum value for size is 512 blocks. With somecombinations of filesystem block size, inode size, and directory block size, the minimum log size is larger than512 blocks.version=valueThis specifies the version of the log. The current default is 2, which allows for larger log buffer sizes, as wellas supporting stripe-aligned log writes (see the sunit and su options, below).The previous version 1, which is limited to 32k log buffers and does not support stripe-aligned writes, is keptfor backwards compatibility with very old 2.4 kernels.sunit=valueThis specifies the alignment to be used for log writes. The value has to be specified in 512-byte block units. Usethe su suboption to specify the log stripe unit size in bytes. Log writes will be aligned on this boundary, androunded up to this boundary. This gives major improvements in performance on some configurations such as softwareRAID5 when the sunit is specified as the filesystem block size. The equivalent byte value must be a multiple ofthe 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=valueThis is used to specify the log stripe. The value has to be specified in bytes, (usually using the s or b suf‐fixes). This value must be a multiple of the filesystem block size. Version 2 logs are automatically selected ifthe log su suboption is specified.lazy-count=valueThis changes the method of logging various persistent counters in the superblock. Under metadata intensive work‐loads, these counters are updated and logged frequently enough that the superblock updates become a serializationpoint 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 valueswithout needed to keep them in the superblock. This gives significant improvements in performance on some config‐urations. The default value is 1 (on) so you must specify lazy-count=0 if you want to disable this feature forolder kernels which don't support it.
mkfs.xfs -l ...
-n
These options specify the version and size parameters for the naming (directory) area of the filesystem. The valid nam‐ing_options are:size=value | log=valueThe block size is specified either as a value in bytes with size=, or as a base two logarithm value with log=.The block size must be a power of 2 and cannot be less than the filesystem block size. The default size value forversion 2 directories is 4096 bytes (4 KiB), unless the filesystem block size is larger than 4096, in which casethe default value is the filesystem block size. For version 1 directories the block size is the same as thefilesystem block size.version=valueThe naming (directory) version value can be either 2 or 'ci', defaulting to 2 if unspecified. With version 2directories, the directory block size can be any power of 2 size from the filesystem block size up to 65536.The version=ci option enables ASCII only case-insensitive filename lookup and version 2 directories. Filenames arecase-preserving, that is, the names are stored in directories using the case they were created with.Note: Version 1 directories are not supported.ftype=valueThis feature allows the inode type to be stored in the directory structure so that the readdir(3) and getdents(2)do not need to look up the inode to determine the inode type.The value is either 0 or 1, with 1 signifying that filetype information will be stored in the directory structure.The default value is 1.When CRCs are enabled (the default), the ftype functionality is always enabled, and cannot be turned off.
mkfs.xfs -n ...
-p
If the optional -p protofile argument is given, mkfs.xfs uses protofile as a prototype file and takes its directions from thatfile. The blocks and inodes specifiers in the protofile are provided for backwards compatibility, but are otherwise unused.The syntax of the protofile is defined by a number of tokens separated by spaces or newlines. Note that the line numbers arenot part of the syntax but are meant to help you in the following discussion of the file contents.1 /stand/diskboot2 4872 1103 d--777 3 14 usr d--777 3 15 sh ---755 3 1 /bin/sh6 ken d--755 6 17 $8 b0 b--644 3 1 0 09 c0 c--644 3 1 0 010 fifo p--644 3 111 slink l--644 3 1 /a/symbolic/link12 : This is a comment line13 $14 $Line 1 is a dummy string. (It was formerly the bootfilename.) It is present for backward compatibility; boot blocks are notused on SGI systems.Note that some string of characters must be present as the first line of the proto file to cause it to be parsed correctly;the value of this string is immaterial since it is ignored.Line 2 contains two numeric values (formerly the numbers of blocks and inodes). These are also merely for backward compati‐bility: two numeric values must appear at this point for the proto file to be correctly parsed, but their values are immate‐rial since they are ignored.The lines 3 through 11 specify the files and directories you want to include in this filesystem. Line 3 defines the rootdirectory. Other directories and files that you want in the filesystem are indicated by lines 4 through 6 and lines 8 through10. Line 11 contains symbolic link syntax.Notice the dollar sign ($) syntax on line 7. This syntax directs the mkfs.xfs command to terminate the branch of the filesys‐tem it is currently on and then continue from the directory specified by the next line, in this case line 8. It must be thelast character on a line. The colon on line 12 introduces a comment; all characters up until the following newline areignored. Note that this means you cannot have a file in a prototype file whose name contains a colon. The $ on lines 13 and14 end the process, since no additional specifications follow.File specifications provide the following:* file mode* user ID* group ID* the file's beginning contentsA 6-character string defines the mode for a file. The first character of this string defines the file type. The characterrange for this first character is -bcdpl. A file may be a regular file, a block special file, a character special file,directory files, named pipes (first-in, first out files), and symbolic links. The second character of the mode string is usedto specify setuserID mode, in which case it is u. If setuserID mode is not specified, the second character is -. The thirdcharacter of the mode string is used to specify the setgroupID mode, in which case it is g. If setgroupID mode is not speci‐fied, the third character is -. The remaining characters of the mode string are a three digit octal number. This octal numberdefines the owner, group, and other read, write, and execute permissions for the file, respectively. For more information onfile permissions, see the chmod(1) command.Following the mode character string are two decimal number tokens that specify the user and group IDs of the file's owner.In a regular file, the next token specifies the pathname from which the contents and size of the file are copied. In a blockor character special file, the next token are two decimal numbers that specify the major and minor device numbers. When afile is a symbolic link, the next token specifies the contents of the link.When the file is a directory, the mkfs.xfs command creates the entries dot (.) and dot-dot (..) and then reads the list ofnames and file specifications in a recursive manner for all of the entries in the directory. A scan of the protofile is alwaysterminated with the dollar ( $ ) token.
mkfs.xfs -p ...
-q
Quiet option. Normally mkfs.xfs prints the parameters of the filesystem to be constructed; the -q flag suppresses this.
mkfs.xfs -q ...
-r
These options specify the location, size, and other parameters of the real-time section of the filesystem. The valid real‐time_section_options are:rtdev=deviceThis is used to specify the device which should contain the real-time section of the filesystem. The suboptionvalue is the name of a block device.extsize=valueThis is used to specify the size of the blocks in the real-time section of the filesystem. This value must be amultiple of the filesystem block size. The minimum allowed size is the filesystem block size or 4 KiB (whicheveris larger); the default size is the stripe width for striped volumes or 64 KiB for non-striped volumes; the maxi‐mum allowed size is 1 GiB. The real-time extent size should be carefully chosen to match the parameters of thephysical media used.size=valueThis is used to specify the size of the real-time section. This suboption is only needed if the real-time sectionof the filesystem should occupy less space than the size of the partition or logical volume containing the sec‐tion.noalignThis option disables stripe size detection, enforcing a realtime device with no stripe geometry.
mkfs.xfs -r ...
-s
This option specifies the fundamental sector size of the filesystem. The sector_size is specified either as a value in byteswith size=value or as a base two logarithm value with log=value. The default sector_size is 512 bytes. The minimum value forsector size is 512; the maximum is 32768 (32 KiB). The sector_size must be a power of 2 size and cannot be made larger thanthe filesystem block size.To specify any options on the command line in units of sectors, this option must be specified first so that the sector size isapplied consistently to all options.
mkfs.xfs -s ...
-L
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(8) and xfs_admin(8) manual entries for additionalinformation.
mkfs.xfs -L ...
-N
Causes the file system parameters to be printed out without really creating the file system.
mkfs.xfs -N ...
-K
Do not attempt to discard blocks at mkfs time.
mkfs.xfs -K ...
-V
Prints the version number and exits.
mkfs.xfs -V ...