LinuxCommandLibrary

xfs_mkfile

Create large files, optimized for XFS

SYNOPSIS

xfs_mkfile [-v] [-n] size filename

PARAMETERS

-v
    Make xfs_mkfile verbose. This option causes xfs_mkfile to print additional information about the file creation process, which can be useful for debugging or understanding the allocation behavior.

-n
    Do not allocate blocks for the file. This creates a sparse file, where blocks are only allocated as data is actually written to the file. This is useful for quickly creating large files that consume minimal disk space until data is populated.

size
    Specifies the size of the file to be created. This argument can be suffixed with s (sectors), k (kilobytes), m (megabytes), or g (gigabytes) to denote the unit. If no suffix is given, bytes are assumed. For example, '100m' creates a 100 megabyte file.

filename
    The path and name of the file to be created. If the file already exists, xfs_mkfile will overwrite it.

DESCRIPTION

xfs_mkfile is a utility specifically designed for creating files, often large ones, on XFS filesystems. Unlike general-purpose file creation tools like touch or dd, xfs_mkfile is part of the XFS administrative toolkit and is particularly useful for performance testing, benchmarking, or simulating file system loads.

It allows users to quickly create files of a specified size, optionally pre-allocating all necessary data blocks without writing actual content, or creating them as sparse files. This makes it efficient for scenarios where the size and allocation characteristics of files are critical for testing filesystem behavior rather than the content itself. Its primary use case revolves around the development, testing, and administration of XFS filesystems.

CAVEATS

xfs_mkfile is primarily intended for use with XFS filesystems. While it might function on other filesystems in some environments, its behavior and efficiency are optimized for XFS.

It's a low-level utility often used for testing and benchmarking, not for general user file creation where data content is important.

The -n (no-block) option creates sparse files, meaning the disk space is not immediately consumed until data is written. This can be misleading if one expects full pre-allocation without explicit data writes.

PRIMARY USE CASE

xfs_mkfile is often used by system administrators and developers to simulate disk full conditions, test I/O performance with large files, or evaluate filesystem scalability. Its ability to quickly create files of specified sizes, with or without block allocation, makes it invaluable for stress testing and performance analysis of XFS environments.

PERFORMANCE CONSIDERATIONS

When creating very large files without the -n option, xfs_mkfile will pre-allocate all data blocks. While it doesn't write actual data to these blocks (unless the filesystem zeroes newly allocated blocks), this pre-allocation can still be a time-consuming operation for extremely large files on busy systems.

HISTORY

xfs_mkfile is part of the xfsprogs package, which provides a comprehensive suite of utilities for managing XFS filesystems. XFS was originally developed by Silicon Graphics, Inc. (SGI) in the early 1990s and released as open source under the GNU General Public License in 2000. xfs_mkfile, along with other xfsprogs tools, has evolved with the XFS filesystem itself, primarily to assist in testing and benchmarking its performance and allocation characteristics, particularly for large files and parallel I/O workloads.

SEE ALSO

mkfs.xfs(8), xfs_io(8), dd(1), fallocate(1)

Copied to clipboard