FALLOCATE(1)
๐
fallocate โ the fallocate(1) glow-up
okay bestie, welcome to the User Commands section of the manual, section 1, and today's main character is fallocate. it's the util-linux girlie who preallocates or deallocates space to a file. no cap, she's iconic. ๐
โจ NAME โจ
fallocate โ preallocate or deallocate space to a file
๐ฆ SYNOPSIS ๐ฆ
fallocate [-c|-p|-z|-w] [-o offset] -l length [-n] filename
fallocate -d [-o offset] [-l length] filename
fallocate -r [-o offset] filename
fallocate -x [-o offset] -l length filename
๐ธ DESCRIPTION ๐ธ
so fallocate is your girl for manipulating the allocated disk space of a file โ either to deallocate it or preallocate it. and here's the slay: for filesystems that support the fallocate(2) system call, preallocation gets done quickly, by allocating blocks and marking them as uninitialized, which means no IO to the data blocks at all. literally so much faster than creating a file by filling it with zeroes. it's giving efficiency. it's giving main character energy. ๐ฅ
the exit status returned by fallocate is 0 on success and 1 on failure. periodt.
๐ OPTIONS ๐
first things first, bestie โ 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.
also important, and I need you to hear me on this one: the options --collapse-range, --dig-holes, --report-holes, --punch-hole, --zero-range, --write-zeroes and --posix are mutually exclusive. pick one, babe, you can't have all of them at the same time. ๐
-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 locationoffset+lengthwill be appended at the locationoffset, and the file will be length bytes smaller. The option--keep-sizemay 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 length 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 (usually4096bytes). Also, when using this option,--keep-sizeis implied. If no range is specified by--offsetand--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.
See --punch-hole for a list of supported filesystems.
-r,--report-holesโ Scan the file and report the distribution of holes without modifying it. Two kinds of holes are shown: file holes โ blocks that the filesystem has not allocated (reported bySEEK_HOLE); data holes โ ranges inside the file which are logically filled with zero bytes but still occupy disk space.
For each hole the offset, end and size in bytes are printed in verbose mode, followed by a summary that gives the total size and percentage of the file that each hole type represents by default. If no offset is specified with --offset, the whole file is scanned.
This option is read-only and can be used on any file to estimate how much space could be reclaimed by --dig-holes.
See --punch-hole for a list of supported filesystems.
-i,--insert-rangeโ Insert a hole of length bytes from offset, shifting existing data.
Supported for XFS (since Linux 4.1) and ext4 (since Linux 4.2).
-l,--lengthlength โ 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 atruncate.-o,--offsetoffset โ 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-rangeoption. Also, when using this option,--keep-sizeis 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.-w,--write-zeroesโ Zeroes space in the byte range starting at offset and continuing for length bytes. Within the specified range, written 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 and subsequent writes to that range do not require further changes to the file mapping metadata.
Zeroing is done within the filesystem. The filesystem may use a hardware-accelerated zeroing command or may submit regular writes. The behavior depends on the filesystem design and the available hardware.
Option --keep-size cannot be specified for the write-zeroes operation because allocating written blocks beyond the inode size is not permitted.
-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.-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 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.
-h,--helpโ Display help text and exit.-V,--versionโ Display version and exit.
๐ AUTHORS ๐
Eric Sandeen <sandeen@redhat.com>, Karel Zak <kzak@redhat.com>
the icons who built her. we stan. ๐ซถ
๐ SEE ALSO ๐
truncate(1), fallocate(2), posix_fallocate(3)
๐ REPORTING BUGS ๐
For bug reports, use the issue tracker <https://github.com/util-linux/util-linux/issues>.
bestie if something's broken, don't suffer in silence โ go file it. the devs wanna know fr fr. ๐
โญ 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/>.
and that's the whole page, gorgeous ๐ this is util-linux 2.42.4, dated 2026-09-21, and it lives under FALLOCATE(1). go preallocate something responsibly, mwah ๐โจ
๐ฆ where this page comes from
- arch rolling: util-linux 2.42.4-1 ยท BSD-2-Clause AND BSD-3-Clause AND BSD-4-Clause-UC AND GPL-2.0-only AND GPL-2.0-or-later AND GPL-3.0-or-later AND ISC AND LGPL-2.1-or-later AND LicenseRef-PublicDomain
- ๐ girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms