]> git.ipfire.org Git - thirdparty/util-linux.git/blob - sys-utils/fallocate.1
Merge branch 'maybe-for-v2.32' of https://github.com/rudimeier/util-linux
[thirdparty/util-linux.git] / sys-utils / fallocate.1
1 .TH FALLOCATE 1 "April 2014" "util-linux" "User Commands"
2 .SH NAME
3 fallocate \- preallocate or deallocate space to a file
4 .SH SYNOPSIS
5 .B fallocate
6 .RB [ \-c | \-p | \-z ]
7 .RB [ \-o
8 .IR offset ]
9 .B \-l
10 .IR length
11 .RB [ \-n ]
12 .I filename
13 .PP
14 .B fallocate \-d
15 .RB [ \-o
16 .IR offset ]
17 .RB [ \-l
18 .IR length ]
19 .I filename
20 .PP
21 .B fallocate \-x
22 .RB [ \-o
23 .IR offset ]
24 .RB \-l
25 .IR length
26 .I filename
27 .SH DESCRIPTION
28 .B fallocate
29 is used to manipulate the allocated disk space for a file, either to deallocate
30 or preallocate it. For filesystems which support the fallocate system call,
31 preallocation is done quickly by allocating blocks and marking them as
32 uninitialized, requiring no IO to the data blocks. This is much faster than
33 creating a file by filling it with zeroes.
34 .PP
35 The exit code returned by
36 .B fallocate
37 is 0 on success and 1 on failure.
38 .SH OPTIONS
39 The \fIlength\fR and \fIoffset\fR
40 arguments may be followed by the multiplicative suffixes KiB (=1024),
41 MiB (=1024*1024), and so on for GiB, TiB, PiB, EiB, ZiB and YiB (the "iB" is
42 optional, e.g., "K" has the same meaning as "KiB") or the suffixes
43 KB (=1000), MB (=1000*1000), and so on for GB, TB, PB, EB, ZB and YB.
44 .PP
45 The options \fB\-\-collapse\-range\fP, \fB\-\-dig\-holes\fP, \fB\-\-punch\-hole\fP and
46 \fB\-\-zero\-range\fP are mutually exclusive.
47 .TP
48 .BR \-c , " \-\-collapse\-range"
49 Removes a byte range from a file, without leaving a hole. The byte range
50 to be collapsed starts at \fIoffset\fP and continues
51 for \fIlength\fR bytes. At the completion of the operation, the contents of
52 the file starting at the location \fIoffset\fR+\fIlength\fR will be appended at the
53 location \fIoffset\fR, and the file will be \fIlength\fR bytes smaller. The option
54 \fB\-\-keep\-size\fR may not be specified for the collapse-range operation.
55 .sp
56 Available since Linux 3.15 for ext4 (only for extent-based files) and XFS.
57 .TP
58 .BR \-d , " \-\-dig\-holes"
59 Detect and dig holes. This makes the file sparse in-place, without using extra
60 disk space. The minimum size of the hole depends on filesystem I/O block size
61 (usually 4096 bytes). Also, when using this option, \fB\-\-keep\-size\fP is
62 implied. If no range is specified by \fB\-\-offset\fP and \fB\-\-length\fP,
63 then the entire file is analyzed for holes.
64 .sp
65 You can think of this option as doing a "\fBcp --sparse\fP" and then renaming
66 the destination file to the original, without the need for extra disk space.
67 .sp
68 See \fB\-\-punch\-hole\fP for a list of supported filesystems.
69 .TP
70 .BR \-i , " \-\-insert\-range"
71 Insert a hole of \fIlength\fR bytes from \fIoffset\fR, shifting existing data.
72 .TP
73 .BR \-l , " \-\-length " \fIlength
74 Specifies the length of the range, in bytes.
75 .TP
76 .BR \-n , " \-\-keep\-size"
77 Do not modify the apparent length of the file. This may effectively allocate
78 blocks past EOF, which can be removed with a truncate.
79 .TP
80 .BR \-o , " \-\-offset " \fIoffset
81 Specifies the beginning offset of the range, in bytes.
82 .TP
83 .BR \-p , " \-\-punch\-hole"
84 Deallocates space (i.e., creates a hole) in the byte range starting at
85 \fIoffset\fP and continuing for \fIlength\fR bytes. Within the
86 specified range, partial filesystem blocks are zeroed, and whole
87 filesystem blocks are removed from the file. After a successful
88 call, subsequent reads from this range will return zeroes. This option
89 may not be specified at the same time as the \fB\-\-zero\-range\fP option.
90 Also, when using this option, \fB\-\-keep\-size\fP is implied.
91 .sp
92 Supported for XFS (since Linux 2.6.38), ext4 (since Linux 3.0),
93 Btrfs (since Linux 3.7) and tmpfs (since Linux 3.5).
94 .TP
95 .BR \-v , " \-\-verbose"
96 Enable verbose mode.
97 .TP
98 .BR \-x , " \-\-posix"
99 Enable POSIX operation mode. In that mode allocation operation always completes,
100 but it may take longer time when fast allocation is not supported by the underlying filesystem.
101 .TP
102 .BR \-z , " \-\-zero\-range"
103 Zeroes space in the byte range starting at \fIoffset\fP and
104 continuing for \fIlength\fR 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 zeroes.
107 .sp
108 Zeroing is done within the filesystem preferably by converting the
109 range into unwritten extents. This approach means that the specified
110 range will not be physically zeroed out on the device (except for
111 partial blocks at the either end of the range), and I/O is
112 (otherwise) required only to update metadata.
113 .sp
114 Option \fB\-\-keep\-size\fP can be specified to prevent file length
115 modification.
116 .sp
117 Available since Linux 3.14 for ext4 (only for extent-based files) and XFS.
118 .TP
119 .BR \-V , " \-\-version"
120 Display version information and exit.
121 .TP
122 .BR \-h , " \-\-help"
123 Display help text and exit.
124 .SH AUTHORS
125 .UR sandeen@redhat.com
126 Eric Sandeen
127 .UE
128 .br
129 .UR kzak@redhat.com
130 Karel Zak
131 .UE
132 .SH SEE ALSO
133 .BR truncate (1),
134 .BR fallocate (2),
135 .BR posix_fallocate (3)
136 .SH AVAILABILITY
137 The fallocate command is part of the util-linux package and is available from
138 .UR https://\:www.kernel.org\:/pub\:/linux\:/utils\:/util-linux/
139 Linux Kernel Archive
140 .UE .