man > fallocate(1)

๐ŸŒ NAME

fallocate - preallocate or deallocate space to a file

๐Ÿš€ Quick Reference

Use CaseCommandDescription
Preallocate spacefallocate -l <length> <filename>๐Ÿ“ฆ Allocate disk blocks without initializing data (fast)
Collapse a rangefallocate -c -o <offset> -l <length> <filename>โœ‚๏ธ Remove a byte range, shifting remaining data left
Dig holes (sparsify)fallocate -d <filename>๐Ÿ•ณ๏ธ Convert existing allocated blocks into holes
Insert a holefallocate -i -o <offset> -l <length> <filename>๐Ÿ“ฅ Insert a hole, shifting data to the right
Punch a holefallocate -p -o <offset> -l <length> <filename>โ›๏ธ Deallocate space, creating a hole
Zero a rangefallocate -z -o <offset> -l <length> <filename>0๏ธโƒฃ Preallocate and zero a range (unwritten extents)

๐Ÿ“– SYNOPSIS

fallocate [-c|-p|-z] [-o offset] -l length [-n] filename
fallocate -d [-o offset] [-l length] filename
fallocate -x [-o offset] -l length filename

๐Ÿ“ DESCRIPTION

fallocate is used to manipulate the allocated disk space for a file, either to deallocate or preallocate it. For filesystems which support the fallocate system call, preallocation is done quickly by allocating blocks and marking them as uninitialized, requiring no IO to the data blocks. This is much faster than creating a file by filling it with zeroes.

๐Ÿšช Exit Codes

0 on success, 1 on failure.

โš™๏ธ OPTIONS

The length and offset arguments may be followed by the multiplicative suffixes KiB (=1024), MiB (=1024*1024), and so on for GiB, TiB, PiB, EiB, ZiB, and YiB (the "iB" is optional, e.g., "K" has the same meaning as "KiB") or the suffixes KB (=1000), MB (=1000*1000), and so on for GB, TB, PB, EB, ZB, and YB.

The options --collapse-range, --dig-holes, --punch-hole, and --zero-range are mutually exclusive.

โœ‚๏ธ -c, --collapse-range

๐Ÿ—‘๏ธ Removes a byte range from a file, without leaving a hole. The byte range to be collapsed starts at offset and continues for length bytes. At the completion of the operation, the contents of the file starting at the location offset+length will be appended at the location offset, and the file will be length bytes smaller. The option --keep-size may not be specified for the collapse-range operation.

Available since Linux 3.15 for ext4 (only for extent-based files) and XFS.

A filesystem may place limitations on the granularity of the operation, in order to ensure efficient implementation. Typically, offset and len must be a multiple of the filesystem logical block size, which varies according to the filesystem type and configuration. If a filesystem has such a requirement, the operation will fail with the error EINVAL if this requirement is violated.

๐Ÿ•ณ๏ธ -d, --dig-holes

๐Ÿ” Detect and dig holes. This makes the file sparse in-place, without using extra disk space. The minimum size of the hole depends on filesystem I/O block size (usually 4096 bytes). Also, when using this option, --keep-size is implied. If no range is specified by --offset and --length, then the entire file is analyzed for holes.

You can think of this option as doing a "cp --sparse" and then renaming the destination file to the original, without the need for extra disk space.

๐Ÿ“ฅ -i, --insert-range

๐Ÿ“Œ Insert a hole of length bytes from offset, shifting existing data.

๐Ÿ“ -l, --length length

๐Ÿ“ Specifies the length of the range, in bytes.

๐Ÿ“ -n, --keep-size

๐Ÿ›ก๏ธ Do not modify the apparent length of the file. This may effectively allocate blocks past EOF, which can be removed with a truncate.

๐Ÿ“ -o, --offset offset

๐ŸŽฏ Specifies the beginning offset of the range, in bytes.

โ›๏ธ -p, --punch-hole

๐Ÿ•ณ๏ธ Deallocates space (i.e., creates a hole) in the byte range starting at offset and continuing for length bytes. Within the specified range, partial filesystem blocks are zeroed, and whole filesystem blocks are removed from the file. After a successful call, subsequent reads from this range will return zeroes. This option may not be specified at the same time as the --zero-range option. Also, when using this option, --keep-size is implied.

Supported for XFS (since Linux 2.6.38), ext4 (since Linux 3.0), Btrfs (since Linux 3.7), tmpfs (since Linux 3.5) and gfs2 (since Linux 4.16).

๐Ÿ—ฃ๏ธ -v, --verbose

๐Ÿ”Š Enable verbose mode.

โœ… -x, --posix

๐Ÿ“‹ Enable POSIX operation mode. In that mode allocation operation always completes, but it may take longer time when fast allocation is not supported by the underlying filesystem.

0๏ธโƒฃ -z, --zero-range

๐Ÿงน Zeroes space in the byte range starting at offset and continuing for length bytes. Within the specified range, blocks are preallocated for the regions that span the holes in the file. After a successful call, subsequent reads from this range will return zeroes.

Zeroing is done within the filesystem preferably by converting the range into unwritten extents. This approach means that the specified range will not be physically zeroed out on the device (except for partial blocks at the either end of the range), and I/O is (otherwise) required only to update metadata.

Option --keep-size can be specified to prevent file length modification.

Available since Linux 3.14 for ext4 (only for extent-based files) and XFS.

โ„น๏ธ -V, --version

๐Ÿ“ƒ Display version information and exit.

โ“ -h, --help

๐Ÿ’ก Display help text and exit.

๐Ÿ‘ค AUTHORS

Eric Sandeen <sandeen AT redhat.com>, Karel Zak <kzak AT redhat.com>

๐Ÿ“š SEE ALSO

truncate(1), fallocate(2), posix_fallocate(3)

๐Ÿ› REPORTING BUGS

For bug reports, use the issue tracker at https://github.com/karelzak/util-linux/issues.

๐Ÿ“ฆ AVAILABILITY

The fallocate command is part of the util-linux package which can be downloaded from Linux Kernel Archive <https://www.kernel.org/pub/linux/utils/util-linux/>.

fallocate(1)
๐ŸŒ NAME ๐Ÿš€ Quick Reference ๐Ÿ“– SYNOPSIS ๐Ÿ“ DESCRIPTION ๐Ÿšช Exit Codes โš™๏ธ OPTIONS
โœ‚๏ธ -c, --collapse-range ๐Ÿ•ณ๏ธ -d, --dig-holes ๐Ÿ“ฅ -i, --insert-range ๐Ÿ“ -l, --length length ๐Ÿ“ -n, --keep-size ๐Ÿ“ -o, --offset offset โ›๏ธ -p, --punch-hole ๐Ÿ—ฃ๏ธ -v, --verbose โœ… -x, --posix 0๏ธโƒฃ -z, --zero-range โ„น๏ธ -V, --version โ“ -h, --help
๐Ÿ‘ค AUTHORS ๐Ÿ“š SEE ALSO ๐Ÿ› REPORTING BUGS ๐Ÿ“ฆ AVAILABILITY

Generated by phpman v4.10.0-7-g98e9fd5 · Markdown · JSON · MCP Author: Che Dong Under GNU General Public License
2026-09-17 04:47 @216.73.217.113
CrawledBy Mozilla/5.0 AppleWebKit/537.36 (KHTML, like Gecko; compatible; ClaudeBot/1.0; +claudebot@anthropic.com)
Valid XHTML 1.0 Transitional!Valid CSS!

^_top_^