1FALLOCATE(1)                     User Commands                    FALLOCATE(1)
2
3
4

NAME

6       fallocate - preallocate or deallocate space to a file
7

SYNOPSIS

9       fallocate [-c|-p|-z] [-o offset] -l length [-n] filename
10
11       fallocate -d [-o offset] [-l length] filename
12
13       fallocate -x [-o offset] -l length filename
14

DESCRIPTION

16       fallocate is used to manipulate the allocated disk space for a file,
17       either to deallocate or preallocate it. For filesystems which support
18       the fallocate(2) system call, preallocation is done quickly by
19       allocating blocks and marking them as uninitialized, requiring no IO to
20       the data blocks. This is much faster than creating a file by filling it
21       with zeroes.
22
23       The exit status returned by fallocate is 0 on success and 1 on failure.
24

OPTIONS

26       The length and offset arguments may be followed by the multiplicative
27       suffixes KiB (=1024), MiB (=1024*1024), and so on for GiB, TiB, PiB,
28       EiB, ZiB, and YiB (the "iB" is optional, e.g., "K" has the same meaning
29       as "KiB") or the suffixes KB (=1000), MB (=1000*1000), and so on for
30       GB, TB, PB, EB, ZB, and YB.
31
32       The options --collapse-range, --dig-holes, --punch-hole, and
33       --zero-range are mutually exclusive.
34
35       -c, --collapse-range
36           Removes a byte range from a file, without leaving a hole. The byte
37           range to be collapsed starts at offset and continues for length
38           bytes. At the completion of the operation, the contents of the file
39           starting at the location offset+length will be appended at the
40           location offset, and the file will be length bytes smaller. The
41           option --keep-size may not be specified for the collapse-range
42           operation.
43
44           Available since Linux 3.15 for ext4 (only for extent-based files)
45           and XFS.
46
47           A filesystem may place limitations on the granularity of the
48           operation, in order to ensure efficient implementation. Typically,
49           offset and length must be a multiple of the filesystem logical
50           block size, which varies according to the filesystem type and
51           configuration. If a filesystem has such a requirement, the
52           operation will fail with the error EINVAL if this requirement is
53           violated.
54
55       -d, --dig-holes
56           Detect and dig holes. This makes the file sparse in-place, without
57           using extra disk space. The minimum size of the hole depends on
58           filesystem I/O block size (usually 4096 bytes). Also, when using
59           this option, --keep-size is implied. If no range is specified by
60           --offset and --length, then the entire file is analyzed for holes.
61
62           You can think of this option as doing a "cp --sparse" and then
63           renaming the destination file to the original, without the need for
64           extra disk space.
65
66           See --punch-hole for a list of supported filesystems.
67
68       -i, --insert-range
69           Insert a hole of length bytes from offset, shifting existing data.
70
71       -l, --length length
72           Specifies the length of the range, in bytes.
73
74       -n, --keep-size
75           Do not modify the apparent length of the file. This may effectively
76           allocate blocks past EOF, which can be removed with a truncate.
77
78       -o, --offset offset
79           Specifies the beginning offset of the range, in bytes.
80
81       -p, --punch-hole
82           Deallocates space (i.e., creates a hole) in the byte range starting
83           at offset and continuing for length bytes. Within the specified
84           range, partial filesystem blocks are zeroed, and whole filesystem
85           blocks are removed from the file. After a successful call,
86           subsequent reads from this range will return zeroes. This option
87           may not be specified at the same time as the --zero-range option.
88           Also, when using this option, --keep-size is implied.
89
90           Supported for XFS (since Linux 2.6.38), ext4 (since Linux 3.0),
91           Btrfs (since Linux 3.7), tmpfs (since Linux 3.5) and gfs2 (since
92           Linux 4.16).
93
94       -v, --verbose
95           Enable verbose mode.
96
97       -x, --posix
98           Enable POSIX operation mode. In that mode allocation operation
99           always completes, but it may take longer time when fast allocation
100           is not supported by the underlying filesystem.
101
102       -z, --zero-range
103           Zeroes space in the byte range starting at offset and continuing
104           for length bytes. Within the specified range, blocks are
105           preallocated for the regions that span the holes in the file. After
106           a successful call, subsequent reads from this range will return
107           zeroes.
108
109           Zeroing is done within the filesystem preferably by converting the
110           range into unwritten extents. This approach means that the
111           specified range will not be physically zeroed out on the device
112           (except for partial blocks at the either end of the range), and I/O
113           is (otherwise) required only to update metadata.
114
115           Option --keep-size can be specified to prevent file length
116           modification.
117
118           Available since Linux 3.14 for ext4 (only for extent-based files)
119           and XFS.
120
121       -h, --help
122           Display help text and exit.
123
124       -V, --version
125           Print version and exit.
126

AUTHORS

128       Eric Sandeen <sandeen@redhat.com>, Karel Zak <kzak@redhat.com>
129

SEE ALSO

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

REPORTING BUGS

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

AVAILABILITY

138       The fallocate command is part of the util-linux package which can be
139       downloaded from Linux Kernel Archive
140       <https://www.kernel.org/pub/linux/utils/util-linux/>.
141
142
143
144util-linux 2.39.2                 2023-06-14                      FALLOCATE(1)
Impressum