]> git.ipfire.org Git - thirdparty/util-linux.git/blame - sys-utils/fallocate.1.adoc
unshare: Support multiple ID ranges for user and group maps
[thirdparty/util-linux.git] / sys-utils / fallocate.1.adoc
CommitLineData
295b3979 1//po4a: entry man manual
6d5b6948
MB
2= fallocate(1)
3:doctype: manpage
f42ed819 4:man manual: User Commands
6d5b6948
MB
5:man source: util-linux {release-version}
6:page-layout: base
7:command: fallocate
8
9== NAME
10
11fallocate - preallocate or deallocate space to a file
12
13== SYNOPSIS
14
15*fallocate* [*-c*|*-p*|*-z*] [*-o* _offset_] *-l* _length_ [*-n*] _filename_
16
17*fallocate* *-d* [*-o* _offset_] [*-l* _length_] _filename_
18
19*fallocate* *-x* [*-o* _offset_] *-l* _length filename_
20
21== DESCRIPTION
22
e6743239 23*fallocate* is used to manipulate the allocated disk space for a file, either to deallocate or preallocate it. For filesystems which support the *fallocate*(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.
6d5b6948
MB
24
25The exit status returned by *fallocate* is 0 on success and 1 on failure.
26
27== OPTIONS
28
29The _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.
30
31The options *--collapse-range*, *--dig-holes*, *--punch-hole*, and *--zero-range* are mutually exclusive.
32
33*-c*, *--collapse-range*::
68860732
MB
34Removes 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.
35+
36Available since Linux 3.15 for ext4 (only for extent-based files) and XFS.
37+
e6743239 38A 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.
6d5b6948
MB
39
40*-d*, *--dig-holes*::
68860732
MB
41Detect 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.
42+
43You 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.
44+
45See *--punch-hole* for a list of supported filesystems.
6d5b6948
MB
46
47*-i*, *--insert-range*::
68860732 48Insert a hole of _length_ bytes from _offset_, shifting existing data.
6d5b6948
MB
49
50*-l*, *--length* _length_::
68860732 51Specifies the length of the range, in bytes.
6d5b6948
MB
52
53*-n*, *--keep-size*::
68860732 54Do not modify the apparent length of the file. This may effectively allocate blocks past EOF, which can be removed with a truncate.
6d5b6948
MB
55
56*-o*, *--offset* _offset_::
68860732 57Specifies the beginning offset of the range, in bytes.
6d5b6948
MB
58
59*-p*, *--punch-hole*::
68860732
MB
60Deallocates 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.
61+
62Supported 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).
6d5b6948
MB
63
64*-v*, *--verbose*::
68860732 65Enable verbose mode.
6d5b6948
MB
66
67*-x*, *--posix*::
68860732 68Enable 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.
6d5b6948
MB
69
70*-z*, *--zero-range*::
68860732
MB
71Zeroes 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.
72+
73Zeroing 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.
74+
75Option *--keep-size* can be specified to prevent file length modification.
76+
77Available since Linux 3.14 for ext4 (only for extent-based files) and XFS.
6d5b6948 78
2b2d3172 79include::man-common/help-version.adoc[]
6d5b6948
MB
80
81== AUTHORS
82
68860732 83mailto:sandeen@redhat.com[Eric Sandeen],
6d5b6948
MB
84mailto:kzak@redhat.com[Karel Zak]
85
86== SEE ALSO
87
88*truncate*(1),
89*fallocate*(2),
90*posix_fallocate*(3)
91
625e9c61 92include::man-common/bugreports.adoc[]
6d5b6948 93
625e9c61 94include::man-common/footer.adoc[]
6d5b6948
MB
95
96ifdef::translation[]
625e9c61 97include::man-common/translation.adoc[]
6d5b6948 98endif::[]