blob: eb29d724fe828f7f1f31df2b12cab61297858872 [file] [log] [blame]
<?xml version='1.0' encoding='utf-8' ?>
<!DOCTYPE chapter PUBLIC "-//OASIS//DTD DocBook XML V4.4//EN" "http://www.oasis-open.org/docbook/xml/4.4/docbookx.dtd" [
]>
<chapter id="xfs-mkfs">
<title>mkfs</title>
<section>
<title>Creating XFS Filesystems</title>
<para>mkfs.xfs supports a large number of options for configuring many different XFS filesystems</para>
<itemizedlist>
<listitem><para>See <command>mkfs.xfs(8)</command></para></listitem>
</itemizedlist>
<para>Units</para>
<itemizedlist>
<listitem><para>100s = 100 sectors = 100 x 512 bytes*</para></listitem>
<listitem><para>100b = 100 blocks = 100 x 4 kilobytes*</para></listitem>
<listitem><para>100k = 100 * 1024 bytes</para></listitem>
<listitem><para>Assuming 512 bytes sectors and 4 KB filesystem block size</para></listitem>
</itemizedlist>
<para>-N option can be used to show filesystem parameters without creating a filesystem</para>
<para>Also provides the capability to pre-initialise the filesystem with directories and inodes, which is useful for testing</para>
</section>
<section>
<title>mkfs - Allocation Block Size</title>
<para>Specify the fundamental allocation block size of the filesystem.</para>
<para>The default value is 4KB, the minimum is 512 bytes, and the maximum is 64KB</para>
<para>XFS on Linux currently only supports pagesize or smaller blocks.</para>
<para>To create a filesystem with a block size of 2048 bytes you would use:</para>
<para><command>mkfs.xfs -b size=2048 <replaceable>device</replaceable> </command></para>
<para><emphasis>Smaller block sizes reduce wasted space for lots of small files.</emphasis></para>
</section>
<section>
<title>mkfs - Allocation groups</title>
<para>An XFS filesystem is divided into allocation groups</para>
<para>More allocation groups offer more parallelism when allocating blocks and inodes</para>
<para>To create filesystem with 16 allocation groups you would use</para>
<para><command>mkfs.xfs -d acount=16 <replaceable>device</replaceable></command></para>
<para>To create a filesystem with a specific size for the allocation groups</para>
<para><command>mkfs.xfs -d agsize=4g <replaceable>device</replaceable></command></para>
<para><emphasis>Filesystems with too few or too many allocation groups should be avoided.</emphasis></para>
</section>
<section>
<title>mkfs - Stripe Alignment</title>
<para>Aligning file data I/Os on stripe width boundaries can significantly improve performance on large RAIDs</para>
<itemizedlist>
<listitem><para>A 2MB write to filesystem with a 2MB stripe width and 512KB stripe unit will result in four
I/Os, one to each lun. Without alignment this would often require two I/Os to one disk,
and one I/O to the other three, taking longer than it should.</para></listitem>
</itemizedlist>
<para>To create a filesystem with a stripe unit of 1MB for an 8+1 RAID you would use:</para>
<para><command>mkfs.xfs -d sunit=2048,swidth=16384 <replaceable>device</replaceable></command></para>
<para>or</para>
<para><command>mkfs.xfs -d su=1m,sw=8m <replaceable>device</replaceable></command></para>
<note><para>xfsprogs 3.1.0 and newer will use the blkid library to correctly identify
stripe geometry for lvm, md, and some hardware raid devices which export this
information</para></note>
</section>
<section>
<title>mkfs - Inode Options</title>
<para>The mkfs inode options allow the user to change</para>
<itemizedlist>
<listitem><para>The size of the inode from the default 256 bytes to up 2048 bytes</para></listitem>
<listitem><para>The maximum number of inodes in the filesystem, defaults to 25%</para></listitem>
<listitem><para>Extended attribute allocation policy</para></listitem>
</itemizedlist>
<para>These options may impact</para>
<itemizedlist>
<listitem><para>where the inode is allocated in filesystem</para></listitem>
<listitem><para>how much data needs to be read from disk to read the inode</para></listitem>
<listitem><para>how much data may be associated with the inode before data goes out of line</para></listitem>
</itemizedlist>
<para>To allocate 512 bytes to each inode:</para>
<para><command>mkfs.xfs -i size=512 <replaceable>device</replaceable></command></para>
</section>
<section>
<title>mkfs - Extended Attributes</title>
<para>Specify the version of extended attribute inline allocation policy to be used.</para>
<itemizedlist>
<listitem><para>Version 1 has fixed regions for attribute and extent data</para></listitem>
<listitem><para>Version 2 (default) uses a more efficient algorithm for managing the available inline inode space</para></listitem>
<listitem><para>Version 1 inodes are automatically converted to version 2 on the fly</para></listitem>
</itemizedlist>
<para>To force the use of version two extended attributes you would use:</para>
<para><command>mkfs.xfs -i attr=2 <replaceable>device</replaceable></command></para>
</section>
<section>
<title>mkfs - Naming options</title>
<para>Specify the version and size parameters for the naming (directory) area of the filesystem.</para>
<itemizedlist>
<listitem><para>The naming (directory) version is either 2 (default) or ci (implies version 2).</para></listitem>
<listitem><para>Version 2 allows for the directory block size to be a multiple of the allocation block size</para></listitem>
<listitem><para>Version ci supports ASCII-only case-insensitive naming</para></listitem>
<listitem><para>XFS on Linux does not support naming (directory) version 1.</para></listitem>
</itemizedlist>
<para>To create a filesystem with a directory block size of 16KB you would use:</para>
<para><command>mkfs.xfs -n size=16384 <replaceable>device</replaceable></command></para>
<para>ASCII-only case-insensitive naming:</para>
<para><command>mkfs.xfs -n version=ci <replaceable>device</replaceable></command></para>
</section>
<section>
<title>mkfs - External Log</title>
<para>The journal log can be on a different device to the rest of the filesystem</para>
<itemizedlist>
<listitem><para>At least 512 filesystem blocks</para></listitem>
<listitem><para>No more than 64K blocks or 128MB, whichever is smaller</para></listitem>
<listitem><para>Defaults to maximum size for >1TB filesystems</para></listitem>
</itemizedlist>
<para>Log device could be a device with better IOPS performance</para>
<itemizedlist>
<listitem><para>15K RPM disk or battery-backed memory</para></listitem>
</itemizedlist>
<para><command>mkfs.xfs -l logdev=<replaceable>log_device</replaceable> <replaceable>device</replaceable></command></para>
<para><command>mount -o logdev=<replaceable>log_device</replaceable> <replaceable>device</replaceable> <replaceable>path</replaceable></command></para>
</section>
<section>
<title>mkfs - Realtime</title>
<para>Originally designed for media streaming requiring predictable latencies</para>
<itemizedlist>
<listitem><para>Realtime volume tuned for large files without small inode clusters</para></listitem>
</itemizedlist>
<para>Metadata and file data on separate volumes</para>
<itemizedlist>
<listitem><para>Bitmap allocator only has to manage file data allocations</para></listitem>
</itemizedlist>
<para><command>mkfs.xfs -l logdev=<replaceable>log_device</replaceable> -r rtdev=<replaceable>rt_device</replaceable> <replaceable>device</replaceable></command></para>
<para><command>mount -o logdev=<replaceable>log_device</replaceable>,rtdev=<replaceable>rt_device</replaceable> <replaceable>device</replaceable> <replaceable>path</replaceable></command></para>
<para><emphasis>rt_device</emphasis> is the device for the file data, device is for the metadata</para>
<para>Receives limited testing and support in Linux</para>
<note><para>Filesystems created with a realtime subvolume can only be mounted on kernels
with CONFIG_XFS_RT enabled</para></note>
</section>
<section>
<title>mkfs - Filesystem Image</title>
<para>mkfs allows you to create a filesystem as a regular file</para>
<para>This can be used to create a filesystem on a loop-back device</para>
<para><command>mkfs.xfs -d file=1,name=<replaceable>filename</replaceable>,size=2g <replaceable>filename</replaceable></command></para>
</section>
<section>
<title>mkfs - Sector Size</title>
<para>Specifies the fundamental sector size of the filesystem.</para>
<para>Default value is 512 bytes.</para>
<para>The minimum value for sector size is 512; the maximum is 32768 (32 KB) or the filesystem block size (whichever is smaller).</para>
<para>To create a filesystem on a device that has a sector size of 1KB you would use:</para>
<para><command>mkfs.xfs -s size=1024 <replaceable>device</replaceable></command></para>
<note><para>xfsprogs 3.1.0 and newer will automatically detect the appropriate sector size for a device</para></note>
</section>
<section>
<title>mkfs - Filesystem Label</title>
<para>Set the filesystem label.</para>
<para>XFS filesystem labels can be at most 12 characters long.</para>
<para>To create a filesystem and specify the label you would use:</para>
<para><command>mkfs.xfs -L <replaceable>label</replaceable> <replaceable>device</replaceable></command></para>
<note><para>A label may later be added or changed by using the <command>xfs_admin</command> command</para></note>
</section>
<section>
<title>mkfs - Prototype Filesystem</title>
<para>The -p option to mkfs allows you to specify a prototype file</para>
<para>The prototype file lists inodes and their metadata that mkfs will add to the filesystem when it is created</para>
<para>Since the filesystem is not mounted at this time no logging is required, so mkfs can create millions
of inodes at a much faster rate than on a live filesystem</para>
<para>This is mainly used for testing XFS when lots of inodes are required</para>
</section>
</chapter>