1 .TH FALLOCATE 1 "April 2014" "util-linux" "User Commands"
3 fallocate \- preallocate or deallocate space to a file
6 .RB [ \-c | \-p | \-z ]
29 is used to manipulate the allocated disk space for a file,
30 either to deallocate or preallocate it.
31 For filesystems which support the fallocate system call,
32 preallocation is done quickly by allocating blocks and marking them as
33 uninitialized, requiring no IO to the data blocks.
34 This is much faster than creating a file by filling it with zeroes.
36 The exit code returned by
38 is 0 on success and 1 on failure.
44 arguments may be followed by the multiplicative suffixes KiB (=1024),
45 MiB (=1024*1024), and so on for GiB, TiB, PiB, EiB, ZiB, and YiB (the "iB" is
46 optional, e.g., "K" has the same meaning as "KiB") or the suffixes
47 KB (=1000), MB (=1000*1000), and so on for GB, TB, PB, EB, ZB, and YB.
50 .BR \-\-collapse\-range ", " \-\-dig\-holes ", " \-\-punch\-hole ,
53 are mutually exclusive.
55 .BR \-c ", " \-\-collapse\-range
56 Removes a byte range from a file, without leaving a hole.
57 The byte range to be collapsed starts at
62 At the completion of the operation,
63 the contents of the file starting at the location
65 will be appended at the location
72 may not be specified for the collapse-range operation.
74 Available since Linux 3.15 for ext4 (only for extent-based files) and XFS.
76 A filesystem may place limitations on the granularity of the operation, in
77 order to ensure efficient implementation. Typically, offset and len must be a
78 multiple of the filesystem logical block size, which varies according to the
79 filesystem type and configuration. If a filesystem has such a requirement,
80 the operation will fail with the error EINVAL if this requirement is violated.
82 .BR \-d ", " \-\-dig\-holes
84 This makes the file sparse in-place, without using extra disk space.
85 The minimum size of the hole depends on filesystem I/O block size
87 Also, when using this option,
89 is implied. If no range is specified by
93 then the entire file is analyzed for holes.
95 You can think of this option as doing a
96 .RB """" "cp \-\-sparse" """"
97 and then renaming the destination file to the original,
98 without the need for extra disk space.
100 See \fB\-\-punch\-hole\fP for a list of supported filesystems.
102 .BR \-i ", " \-\-insert\-range
107 shifting existing data.
109 .BR \-l ", " "\-\-length " \fIlength
110 Specifies the length of the range, in bytes.
112 .BR \-n ", " \-\-keep\-size
113 Do not modify the apparent length of the file. This may effectively allocate
114 blocks past EOF, which can be removed with a truncate.
116 .BR \-o ", " "\-\-offset " \fIoffset
117 Specifies the beginning offset of the range, in bytes.
119 .BR \-p ", " \-\-punch\-hole
120 Deallocates space (i.e., creates a hole) in the byte range starting at
125 Within the specified range, partial filesystem blocks are zeroed,
126 and whole filesystem blocks are removed from the file.
127 After a successful call,
128 subsequent reads from this range will return zeroes.
129 This option may not be specified at the same time as the
132 Also, when using this option,
136 Supported for XFS (since Linux 2.6.38), ext4 (since Linux 3.0),
137 Btrfs (since Linux 3.7) and tmpfs (since Linux 3.5).
139 .BR \-v ", " \-\-verbose
142 .BR \-x ", " \-\-posix
143 Enable POSIX operation mode.
144 In that mode allocation operation always completes,
145 but it may take longer time when fast allocation is not supported by
146 the underlying filesystem.
148 .BR \-z ", " \-\-zero\-range
149 Zeroes space in the byte range starting at
154 Within the specified range, blocks are preallocated for the regions
155 that span the holes in the file.
156 After a successful call,
157 subsequent reads from this range will return zeroes.
159 Zeroing is done within the filesystem preferably by converting the
160 range into unwritten extents. This approach means that the specified
161 range will not be physically zeroed out on the device (except for
162 partial blocks at the either end of the range), and I/O is
163 (otherwise) required only to update metadata.
165 Option \fB\-\-keep\-size\fP can be specified to prevent file length
168 Available since Linux 3.14 for ext4 (only for extent-based files) and XFS.
170 .BR \-V ", " \-\-version
171 Display version information and exit.
173 .BR \-h ", " \-\-help
174 Display help text and exit.
176 .MT sandeen@redhat.com
186 .BR posix_fallocate (3)
188 The fallocate command is part of the util-linux package and is available from
189 .UR https://\:www.kernel.org\:/pub\:/linux\:/utils\:/util-linux/