1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167
|
'\" t
.\" Title: fallocate
.\" Author: [see the "AUTHOR(S)" section]
.\" Generator: Asciidoctor 2.0.20
.\" Date: 2026-02-18
.\" Manual: User Commands
.\" Source: util-linux 2.42-rc1
.\" Language: English
.\"
.TH "FALLOCATE" "1" "2026-02-18" "util\-linux 2.42\-rc1" "User Commands"
.ie \n(.g .ds Aq \(aq
.el .ds Aq '
.ss \n[.ss] 0
.nh
.ad l
.de URL
\fI\\$2\fP <\\$1>\\$3
..
.als MTO URL
.if \n[.g] \{\
. mso www.tmac
. am URL
. ad l
. .
. am MTO
. ad l
. .
. LINKSTYLE blue R < >
.\}
.SH "NAME"
fallocate \- preallocate or deallocate space to a file
.SH "SYNOPSIS"
.sp
\fBfallocate\fP [\fB\-c\fP|\fB\-p\fP|\fB\-z\fP|\fB\-w\fP] [\fB\-o\fP \fIoffset\fP] \fB\-l\fP \fIlength\fP [\fB\-n\fP] \fIfilename\fP
.sp
\fBfallocate\fP \fB\-d\fP [\fB\-o\fP \fIoffset\fP] [\fB\-l\fP \fIlength\fP] \fIfilename\fP
.sp
\fBfallocate\fP \fB\-r\fP [\fB\-o\fP \fIoffset\fP] \fIfilename\fP
.sp
\fBfallocate\fP \fB\-x\fP [\fB\-o\fP \fIoffset\fP] \fB\-l\fP \fIlength filename\fP
.SH "DESCRIPTION"
.sp
\fBfallocate\fP is used to manipulate the allocated disk space for a file, either to deallocate or preallocate it. For filesystems which support the \fBfallocate\fP(2) 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.
.sp
The exit status returned by \fBfallocate\fP is 0 on success and 1 on failure.
.SH "OPTIONS"
.sp
The \fIlength\fP and \fIoffset\fP 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.
.sp
The options \fB\-\-collapse\-range\fP, \fB\-\-dig\-holes\fP, \fB\-\-report\-holes\fP, \fB\-\-punch\-hole\fP, \fB\-\-zero\-range\fP, \fB\-\-write\-zeroes\fP and \fB\-\-posix\fP are mutually exclusive.
.sp
\fB\-c\fP, \fB\-\-collapse\-range\fP
.RS 4
Removes a byte range from a file, without leaving a hole. The byte range to be collapsed starts at \fIoffset\fP and continues for \fIlength\fP bytes. At the completion of the operation, the contents of the file starting at the location \fIoffset\fP+\fIlength\fP will be appended at the location \fIoffset\fP, and the file will be \fIlength\fP bytes smaller. The option \fB\-\-keep\-size\fP may not be specified for the collapse\-range operation.
.sp
Available since Linux 3.15 for ext4 (only for extent\-based files) and XFS.
.sp
A filesystem may place limitations on the granularity of the operation, in order to ensure efficient implementation. Typically, \fIoffset\fP and \fIlength\fP 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 \fBEINVAL\fP if this requirement is violated.
.RE
.sp
\fB\-d\fP, \fB\-\-dig\-holes\fP
.RS 4
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, \fB\-\-keep\-size\fP is implied. If no range is specified by \fB\-\-offset\fP and \fB\-\-length\fP, then the entire file is analyzed for holes.
.sp
You can think of this option as doing a "\fBcp \-\-sparse\fP" and then renaming the destination file to the original, without the need for extra disk space.
.sp
See \fB\-\-punch\-hole\fP for a list of supported filesystems.
.RE
.sp
\fB\-r\fP, \fB\-\-report\-holes\fP
.RS 4
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 by SEEK_HOLE);
data holes – ranges inside the file which are logically filled with zero bytes but still occupy disk space.
.sp
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 \fB\-\-offset\fP, the whole file is scanned.
.sp
This option is read\-only and can be used on any file to estimate how much space could be reclaimed by \fB\-\-dig\-holes\fP.
.sp
See \fB\-\-punch\-hole\fP for a list of supported filesystems.
.RE
.sp
\fB\-i\fP, \fB\-\-insert\-range\fP
.RS 4
Insert a hole of \fIlength\fP bytes from \fIoffset\fP, shifting existing data.
.RE
.sp
\fB\-l\fP, \fB\-\-length\fP \fIlength\fP
.RS 4
Specifies the length of the range, in bytes.
.RE
.sp
\fB\-n\fP, \fB\-\-keep\-size\fP
.RS 4
Do not modify the apparent length of the file. This may effectively allocate blocks past EOF, which can be removed with a truncate.
.RE
.sp
\fB\-o\fP, \fB\-\-offset\fP \fIoffset\fP
.RS 4
Specifies the beginning offset of the range, in bytes.
.RE
.sp
\fB\-p\fP, \fB\-\-punch\-hole\fP
.RS 4
Deallocates space (i.e., creates a hole) in the byte range starting at \fIoffset\fP and continuing for \fIlength\fP 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 \fB\-\-zero\-range\fP option. Also, when using this option, \fB\-\-keep\-size\fP is implied.
.sp
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).
.RE
.sp
\fB\-v\fP, \fB\-\-verbose\fP
.RS 4
Enable verbose mode.
.RE
.sp
\fB\-w\fP, \fB\-\-write\-zeroes\fP
.RS 4
Zeroes space in the byte range starting at \fIoffset\fP and continuing for \fIlength\fP 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.
.sp
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.
.sp
Option \fB\-\-keep\-size\fP cannot be specified for the write\-zeroes operation because allocating written blocks beyond the inode size is not permitted.
.RE
.sp
\fB\-x\fP, \fB\-\-posix\fP
.RS 4
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.
.RE
.sp
\fB\-z\fP, \fB\-\-zero\-range\fP
.RS 4
Zeroes space in the byte range starting at \fIoffset\fP and continuing for \fIlength\fP 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.
.sp
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.
.sp
Option \fB\-\-keep\-size\fP can be specified to prevent file length modification.
.sp
Available since Linux 3.14 for ext4 (only for extent\-based files) and XFS.
.RE
.sp
\fB\-h\fP, \fB\-\-help\fP
.RS 4
Display help text and exit.
.RE
.sp
\fB\-V\fP, \fB\-\-version\fP
.RS 4
Display version and exit.
.RE
.SH "AUTHORS"
.sp
.MTO "sandeen\(atredhat.com" "Eric Sandeen" ","
.MTO "kzak\(atredhat.com" "Karel Zak" ""
.SH "SEE ALSO"
.sp
\fBtruncate\fP(1),
\fBfallocate\fP(2),
\fBposix_fallocate\fP(3)
.SH "REPORTING BUGS"
.sp
For bug reports, use the \c
.URL "https://github.com/util\-linux/util\-linux/issues" "issue tracker" "."
.SH "AVAILABILITY"
.sp
The \fBfallocate\fP command is part of the util\-linux package which can be downloaded from \c
.URL "https://www.kernel.org/pub/linux/utils/util\-linux/" "Linux Kernel Archive" "."
|