btrfs-progs: docs: compression is disabled with nodatasum/nodatacow
[platform/upstream/btrfs-progs.git] / Documentation / btrfs-man5.asciidoc
1 btrfs-man5(5)
2 ==============
3
4 NAME
5 ----
6 btrfs-man5 - topics about the BTRFS filesystem (mount options, supported file attributes and other)
7
8 DESCRIPTION
9 -----------
10 This document describes topics related to BTRFS that are not specific to the
11 tools.  Currently covers:
12
13 1. mount options
14
15 2. file attributes
16
17 MOUNT OPTIONS
18 -------------
19
20 This section describes mount options specific to BTRFS.  For the generic mount
21 options please refer to `mount`(8) manpage. The options are sorted alphabetically
22 (discarding the 'no' prefix).
23
24 *acl*::
25 *noacl*::
26 (default: on)
27 +
28 Enable/disable support for Posix Access Control Lists (ACLs).  See the
29 `acl`(5) manual page for more information about ACLs.
30 +
31 The support for ACL is build-time configurable (BTRFS_FS_POSIX_ACL) and
32 mount fails if 'acl' is requested but the feature is not compiled in.
33
34 *alloc_start='bytes'*::
35 (default: 1M, minimum: 1M)
36 +
37 Debugging option to force all block allocations above a certain
38 byte threshold on each block device.  The value is specified in
39 bytes, optionally with a K, M, or G suffix (case insensitive).
40 +
41 This option was used for testing and has no practical use, it's slated to be
42 removed in the future.
43
44 *autodefrag*::
45 *noautodefrag*::
46 (since: 3.0, default: off)
47 +
48 Enable automatic file defragmentation.
49 When enabled, small random writes into files (in a range of tens of kilobytes,
50 currently it's 64K) are detected and queued up for the defragmentation process.
51 Not well suited for large database workloads.
52 +
53 The read latency may increase due to reading the adjacent blocks that make up the
54 range for defragmentation, successive write will merge the blocks in the new
55 location.
56 +
57 WARNING: Defragmenting with Linux kernel versions < 3.9 or ≥ 3.14-rc2 as
58 well as with Linux stable kernel versions ≥ 3.10.31, ≥ 3.12.12 or
59 ≥ 3.13.4 will break up the ref-links of CoW data (for example files
60 copied with `cp --reflink`, snapshots or de-duplicated data).
61 This may cause considerable increase of space usage depending on the
62 broken up ref-links.
63
64 *barrier*::
65 *nobarrier*::
66 (default: on)
67 +
68 Ensure that all IO write operations make it through the device cache and are stored
69 permanently when the filesystem is at it's consistency checkpoint. This
70 typically means that a flush command is sent to the device that will
71 synchronize all pending data and ordinary metadata blocks, then writes the
72 superblock and issues another flush.
73 +
74 The write flushes incur a slight hit and also prevent the IO block
75 scheduler to reorder requests in a more effective way. Disabling barriers gets
76 rid of that penalty but will most certainly lead to a corrupted filesystem in
77 case of a crash or power loss. The ordinary metadata blocks could be yet
78 unwritten at the time the new superblock is stored permanently, expecting that
79 the block pointers to metadata were stored permanently before.
80 +
81 On a device with a volatile battery-backed write-back cache, the 'nobarrier'
82 option will not lead to filesystem corruption as the pending blocks are
83 supposed to make it to the permanent storage.
84
85 *check_int*::
86 *check_int_data*::
87 *check_int_print_mask='value'*::
88 (since: 3.0, default: off)
89 +
90 These debugging options control the behavior of the integrity checking
91 module (the BTRFS_FS_CHECK_INTEGRITY config option required). +
92 +
93 `check_int` enables the integrity checker module, which examines all
94 block write requests to ensure on-disk consistency, at a large
95 memory and CPU cost. +
96 +
97 `check_int_data` includes extent data in the integrity checks, and
98 implies the check_int option. +
99 +
100 `check_int_print_mask` takes a bitmask of BTRFSIC_PRINT_MASK_* values
101 as defined in 'fs/btrfs/check-integrity.c', to control the integrity
102 checker module behavior. +
103 +
104 See comments at the top of 'fs/btrfs/check-integrity.c'
105 for more info.
106
107 *clear_cache*::
108 Force clearing and rebuilding of the disk space cache if something
109 has gone wrong. See also: 'space_cache'.
110
111 *commit='seconds'*::
112 (since: 3.12, default: 30)
113 +
114 Set the interval of periodic commit. Higher
115 values defer data being synced to permanent storage with obvious
116 consequences when the system crashes. The upper bound is not forced,
117 but a warning is printed if it's more than 300 seconds (5 minutes).
118
119 *compress*::
120 *compress='type'*::
121 *compress-force*::
122 *compress-force='type'*::
123 (default: off)
124 +
125 Control BTRFS file data compression.  Type may be specified as 'zlib',
126 'lzo' or 'no' (for no compression, used for remounting).  If no type
127 is specified, 'zlib' is used.  If 'compress-force' is specified,
128 all files will be compressed, whether or not they compress well. Otherwise
129 some simple heuristics are applied to detect an incompressible file. If the
130 first blocks written to a file are not compressible, the whole file is
131 permanently marked to skip compression.
132 +
133 NOTE: If compression is enabled, 'nodatacow' and 'nodatasum' are disabled.
134
135 *datacow*::
136 *nodatacow*::
137 (default: on)
138 +
139 Enable data copy-on-write for newly created files.
140 'Nodatacow' implies 'nodatasum', and disables 'compression'. All files created
141 under 'nodatacow' are also set the NOCOW file attribute (see `chattr`(1)).
142 +
143 NOTE: If 'nodatacow' or 'nodatasum' are enabled, compression is disabled.
144
145 *datasum*::
146 *nodatasum*::
147 (default: on)
148 +
149 Enable data checksumming for newly created files.
150 'Datasum' implies 'datacow', ie. the normal mode of operation. All files created
151 under 'nodatasum' inherit the "no checksums" property, however there's no
152 corresponding file attribute (see `chattr`(1)).
153 +
154 NOTE: If 'nodatacow' or 'nodatasum' are enabled, compression is disabled.
155
156 *degraded*::
157 (default: off)
158 +
159 Allow mounts with less devices than the raid profile constraints
160 require.  A read-write mount (or remount) may fail with too many devices
161 missing, for example if a stripe member is completely missing from RAID0.
162
163 *device='devicepath'*::
164 Specify a path to a device that will be scanned for BTRFS filesystem during
165 mount. This is usually done automatically by a device manager (like udev) or
166 using the *btrfs device scan* command (eg. run from the initial ramdisk). In
167 cases where this is not possible the 'device' mount option can help.
168 +
169 NOTE: booting eg. a RAID1 system may fail even if all filesystem's 'device'
170 paths are provided as the actual device nodes may not be discovered by the
171 system at that point.
172
173 *discard*::
174 *nodiscard*::
175 (default: off)
176 +
177 Enable discarding of freed file blocks using TRIM operation.  This is useful
178 for SSD devices, thinly provisioned LUNs or virtual machine images where the
179 backing device understands the operation. Depending on support of the
180 underlying device, the operation may severely hurt performance in case the TRIM
181 operation is synchronous (eg. with SATA devices up to revision 3.0).
182 +
183 If discarding is not necessary to be done at the block freeing time, there's
184 `fstrim` tool that lets the filesystem discard all free blocks in a batch,
185 possibly not much interfering with other operations. Also, the the device may
186 ignore the TRIM command if the range is too small, so running the batch discard
187 can actually discard the blocks.
188
189 *enospc_debug*::
190 *noenospc_debug*::
191 (default: off)
192 +
193 Enable verbose output for some ENOSPC conditions. It's safe to use but can
194 be noisy if the system reaches near-full state.
195
196 *fatal_errors='action'*::
197 (since: 3.4, default: bug)
198 +
199 Action to take when encountering a fatal error.
200 +
201 *bug*::::
202 'BUG()' on a fatal error, the system will stay in the crashed state and may be
203 still partially usable, but reboot is required for full operation
204 +
205 *panic*::::
206 'panic()' on a fatal error, depending on other system configuration, this may
207 be followed by a reboot. Please refer to the documentation of kernel boot
208 parameters, eg. 'panic', 'oops' or 'crashkernel'.
209
210 *flushoncommit*::
211 *noflushoncommit*::
212 (default: on)
213 +
214 This option forces any data dirtied by a write in a prior transaction to commit
215 as part of the current commit.  This makes the committed state a fully
216 consistent view of the file system from the application's perspective (i.e., it
217 includes all completed file system operations).  This was previously the
218 behavior only when a snapshot was created.
219 +
220 Disabling flushing may improve performance but is not crash-safe.
221
222 *fragment='type'*::
223 (depends on compile-time option BTRFS_DEBUG, since: 4.4, default: off)
224 +
225 A debugging helper to intentionally fragment given 'type' of block groups. The
226 type can be 'data', 'metadata' or 'all'. This mount option should not be used
227 outside of debugging environments and is not recognized if the kernel config
228 option 'BTRFS_DEBUG' is not enabled.
229
230 *inode_cache*::
231 *noinode_cache*::
232 (since: 3.0, default: off)
233 +
234 Enable free inode number caching. Not recommended to use unless files on your
235 filesystem get assigned inode numbers that are approaching 2^64^. Normally, new
236 files in each subvolume get assigned incrementally (plus one from the last
237 time) and are not reused. The mount option turns on caching of the existing
238 inode numbers and reuse of inode numbers of deleted files.
239 +
240 This option may slow down your system at first run, or after mounting without
241 the option.
242 +
243 NOTE: Defaults to off due to a potential overflow problem when the free space
244 checksums don't fit inside a single page.
245
246 *logreplay*::
247 *nologreplay*::
248 (default: on, even read-only)
249 +
250 Enable/disable log replay at mount time. See also 'treelog'.
251 +
252 WARNING: currently, the tree log is replayed even with a read-only mount! To
253 disable that behaviour, mount also with 'nologreplay'.
254
255 *max_inline='bytes'*::
256 (default: min(2048, page size) )
257 +
258 Specify the maximum amount of space, in bytes, that can be inlined in
259 a metadata B-tree leaf.  The value is specified in bytes, optionally
260 with a K suffix (case insensitive).  In practice, this value
261 is limited by the filesystem block size (named 'sectorsize' at mkfs time),
262 and memory page size of the system. In case of sectorsize limit, there's
263 some space unavailable due to leaf headers.  For example, a 4k sectorsize,
264 maximum size of inline data is about 3900 bytes.
265 +
266 Inlining can be completely turned off by specifying 0. This will increase data
267 block slack if file sizes are much smaller than block size but will reduce
268 metadata consumption in return.
269 +
270 NOTE: the default value has changed to 2048 in kernel 4.6.
271
272 *metadata_ratio='value'*::
273 (default: 0, internal logic)
274 +
275 Specifies that 1 metadata chunk should be allocated after every 'value' data
276 chunks. Default behaviour depends on internal logic, some percent of unused
277 metadata space is attempted to be maintained but is not always possible if
278 there's not enough space left for chunk allocation. The option could be useful to
279 override the internal logic in favor of the metadata allocation if the expected
280 workload is supposed to be metadata intense (snapshots, reflinks, xattrs,
281 inlined files).
282
283 *recovery*::
284 (since: 3.2, default: off, deprecated since: 4.5)
285 +
286 NOTE: this option has been replaced by 'usebackuproot' and should not be used
287 but will work on 4.5+ kernels.
288
289 *norecovery*::
290 (since: 4.5, default: off)
291 +
292 Do not attempt any data recovery at mount time. This will disable 'logreplay'
293 and avoids other write operations.
294 +
295 NOTE: The opposite option 'recovery' used to have different meaning but was
296 changed for consistency with other filesystems, where 'norecovery' is used for
297 skipping log replay. BTRFS does the same and in general will try to avoid any
298 write operations.
299
300 *rescan_uuid_tree*::
301 (since: 3.12, default: off)
302 +
303 Force check and rebuild procedure of the UUID tree. This should not
304 normally be needed.
305
306 *skip_balance*::
307 (since: 3.3, default: off)
308 +
309 Skip automatic resume of interrupted balance operation after mount.
310 May be resumed with *btrfs balance resume* or the paused state can be removed
311 by *btrfs balance cancel*. The default behaviour is to start interrutpd balance.
312
313 *space_cache*::
314 *space_cache=v2*::
315 *nospace_cache*::
316 ('nospace_cache' since: 3.2, 'space_cache=v2' since 4.5, default: on)
317 +
318 Options to control the free space cache.  This affects performance as searching
319 for new free blocks could take longer if the space cache is not enabled. On the
320 other hand, managing the space cache consumes some resources.  It can be
321 disabled without clearing at mount time.
322 +
323 There are two implementations of how the space is tracked. The safe default is
324 'v1'.  On large filesystems (many-terabytes) and certain workloads the 'v1'
325 performance may degrade.  This problem is addressed by 'v2', that is based on
326 b-trees, sometimes referred to as 'free-space-tree'.
327 +
328 'Compatibility notes:'
329 +
330 * the 'v2' has to be enabled manually at mount time, once
331 * kernel without 'v2' support will be able to mount the filesystem in read-only mode
332 * 'v2' can be removed by mounting with 'clear_cache'
333
334 *ssd*::
335 *nossd*::
336 *ssd_spread*::
337 (default: SSD autodetected)
338 +
339 Options to control SSD allocation schemes.  By default, BTRFS will
340 enable or disable SSD allocation heuristics depending on whether a
341 rotational or non-rotational disk is in use (contents of
342 '/sys/block/DEV/queue/rotational').  The 'ssd' and 'nossd' options
343 can override this autodetection.
344 +
345 The 'ssd_spread' mount option attempts to allocate into bigger and aligned
346 chunks of unused space, and may perform better on low-end SSDs.  'ssd_spread'
347 implies 'ssd', enabling all other SSD heuristics as well.
348
349 *subvol='path'*::
350 Mount subvolume from 'path' rather than the toplevel subvolume. The
351 'path' is absolute (ie. starts at the toplevel subvolume).
352 This mount option overrides the default subvolume set for the given filesystem.
353
354 *subvolid='subvolid'*::
355 Mount subvolume specified by a 'subvolid' number rather than the toplevel
356 subvolume.  You can use *btrfs subvolume list* to see subvolume ID numbers.
357 This mount option overrides the default subvolume set for the given filesystem.
358 +
359 NOTE: if both 'subvolid' and 'subvol' are specified, they must point at the
360 same subvolume, otherwise mount will fail.
361
362 *subvolrootid='objectid'*::
363 (irrelevant since: 3.2, formally deprecated since: 3.10)
364 +
365 A workaround option from times (pre 3.2) when it was not possible to mount a
366 subvolume that did not reside directly under the toplevel subvolume.
367
368 *thread_pool='number'*::
369 (default: min(NRCPUS + 2, 8) )
370 +
371 The number of worker threads to allocate. NRCPUS is number of on-line CPUs
372 detected at the time of mount. Small number leads to less parallelism in
373 processing data and metadata, higher numbers could lead to a performance hit
374 due to increased locking contention, cache-line bouncing or costly data
375 transfers between local CPU memories.
376
377 *treelog*::
378 *notreelog*::
379 (default: on)
380 +
381 Enable the tree logging used for 'fsync' and 'O_SYNC' writes. The tree log
382 stores changes without the need of a full filesystem sync. The log operations
383 are flushed at sync and transaction commit. If the system crashes between two
384 such syncs, the pending tree log operations are replayed during mount.
385 +
386 WARNING: currently, the tree log is replayed even with a read-only mount! To
387 disable that behaviour, mount also with 'nologreplay'.
388 +
389 The tree log could contain new files/directories, these would not exist on
390 a mounted filesystem if the log is not replayed.
391
392 *usebackuproot*::
393 *nousebackuproot*::
394 +
395 Enable autorecovery attempts if a bad tree root is found at mount time.
396 Currently this scans a backup list of several previous tree roots and tries to
397 use the first readable. This can be used with read-only mounts as well.
398 +
399 NOTE: This option has replaced 'recovery'.
400
401 *user_subvol_rm_allowed*::
402 (default: off)
403 +
404 Allow subvolumes to be deleted by their respective owner. Otherwise, only the
405 root user can do that.
406
407 FILE ATTRIBUTES
408 ---------------
409 The btrfs filesystem supports setting the following file attributes using the
410 `chattr`(1) utility:
411
412 *a*::
413 'append only', new writes are always written at the end of the file
414
415 *A*::
416 'no atime updates'
417
418 *c*::
419 'compress data', all data written after this attribute is set will be compressed.
420 Please note that compression is also affected by the mount options or the parent
421 directory attributes.
422 +
423 When set on a directory, all newly created files will inherit this attribute.
424
425 *C*::
426 'no copy-on-write', file modifications are done in-place
427 +
428 When set on a directory, all newly created files will inherit this attribute.
429 +
430 NOTE: due to implementation limitations, this flag can be set/unset only on
431 empty files.
432
433 *d*::
434 'no dump', makes sense with 3rd party tools like `dump`(8), on BTRFS the
435 attribute can be set/unset on no other special handling is done
436
437 *D*::
438 'synchronous directory updates', for more details search `open`(2) for 'O_SYNC'
439 and 'O_DSYNC'
440
441 *i*::
442 'immutable', no file data and metadata changes allowed even to the root user as
443 long as this attribute is set (obviously the exception is unsetting the attribute)
444
445 *S*::
446 'synchronous updates', for more details search `open`(2) for 'O_SYNC' and
447 'O_DSYNC'
448
449 *X*::
450 'no compression', permanently turn off compression on the given file, other
451 compression mount options will not affect that
452 +
453 When set on a directory, all newly created files will inherit this attribute.
454
455 No other attributes are supported.  For the complete list please refer to the
456 `chattr`(1) manual page.
457
458 SEE ALSO
459 --------
460 `acl`(5),
461 `btrfs`(8),
462 `chattr`(1),
463 `fstrim`(8),
464 `mkfs.btrfs`(8),
465 `mount`(8)