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