LinuxCommandLibrary

mkfile

creates files of specified size

TLDR

Create file of size

$ mkfile [100m] [filename]
copy
Create sparse file
$ mkfile -n [1g] [filename]
copy
Create file in bytes
$ mkfile [1048576] [filename]
copy
Create multiple files
$ mkfile [10m] [file1] [file2]
copy
Verbose output
$ mkfile -v [100m] [filename]
copy

SYNOPSIS

mkfile [options] size file

DESCRIPTION

mkfile creates files of specified size. It can create empty files or sparse files.
The tool is useful for testing and creating disk images. Sparse files don't allocate full space.

PARAMETERS

SIZE

File size (b, k, m, g suffixes).
FILE
Output filename.
-n
Create sparse file.
-v
Verbose output.
--help
Display help information.

CAVEATS

macOS/Solaris utility. Linux uses truncate/fallocate. Sparse file support varies.

HISTORY

mkfile originates from Solaris and is also available on macOS for creating files of arbitrary size.

SEE ALSO

truncate(1), fallocate(1), dd(1)

> TERMINAL_GEAR

Curated for the Linux community

Copied to clipboard

> TERMINAL_GEAR

Curated for the Linux community