blob: 7ed9e7e6b83322db29e7eaf12fe58da83802c542 [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 configuration a large number of 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 filesyste</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 block size of the filesystem.</para>
<para>The default value is 4096 bytes (4 KB), the minimum is 512, and the maximum is 65536 (64 KB).</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 –b size=2048 device</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>The data section of an XFS filesystem is divided into allocation groups</para>
<para>More allocation groups imply more parallelism when allocation blocks and inodes.</para>
<para>To create filesystem with 16 allocation groups you would use:</para>
<para><command>mkfs –d acount=16 device</command></para>
<para>To create a filesystem with fixed size allocation groups</para>
<para><command>mkfs –d agsize=4g device</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 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 –d sunit=2048,swidth=16384 device</command></para>
<para>or</para>
<para><command>mkfs –d su=1m,sw=8m device</command></para>
</section>
<section>
<title>mkfs – Unwritten Extents</title>
<para>Unwritten extents are used to support pre-allocation.</para>
<para>Default is enabled.</para>
<para>To disable unwritten extents you would use:</para>
<para><command>mkfs –d unwritten=0 device</command></para>
<para><emphasis>Filesystem write performance may be negatively affected for unwritten file extents,
since extra filesystem transactions are required to convert extent flags for the range
of the file written.</emphasis></para>
</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 –i size=512 device</command></para>
</section>
<section>
<title>mkfs – Extended Attributes</title>
<para>Specify the version of extended attribute inline allocation policy to be used.</para>
<para>Default is zero, when extended attributes are used for the first time the version
will be set to either one or two.</para>
<para>Version two uses a more efficient algorithm for managing the available inline inode space
than version one, however, for backward compatibility, version one is selected by default.</para>
<para>To force the use of version two extended attributes you would use:</para>
<para><command>mkfs –i attr=2 device</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>
<para>The naming (directory) version is 1 or 2, defaulting to 2 if unspecified.</para>
<para>XFS on Linux does not support naming (directory) version 1.</para>
<para>To create a filesystem with a directory block size of 16KB you would use:</para>
<para><command>mkfs –n size=16384 device</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 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=log_device device</command></para>
<para><command>mount –o logdev=log_device device path</command></para>
<para>XXX Image goes here</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=log_device –r rtdev=rt_device device</command></para>
<para><command>mount –o logdev=log_device,rtdev=rt_device device path</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>
<para>XXX Image goes here</para>
</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 –d file=1,name=filename,size=2g filename</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 –s size=1024 device</command></para>
</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 –L label device</command></para>
</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>