Debian Codegraph @

upstream/debian-trixie/man8/btrfs-filesystem.8

raw
1 .\" Man page generated from reStructuredText.
2 .
3 .
4 .nr rst2man-indent-level 0
5 .
6 .de1 rstReportMargin
7 \\$1 \\n[an-margin]
8 level \\n[rst2man-indent-level]
9 level margin: \\n[rst2man-indent\\n[rst2man-indent-level]]
10 -
11 \\n[rst2man-indent0]
12 \\n[rst2man-indent1]
13 \\n[rst2man-indent2]
14 ..
15 .de1 INDENT
16 .\" .rstReportMargin pre:
17 . RS \\$1
18 . nr rst2man-indent\\n[rst2man-indent-level] \\n[an-margin]
19 . nr rst2man-indent-level +1
20 .\" .rstReportMargin post:
21 ..
22 .de UNINDENT
23 . RE
24 .\" indent \\n[an-margin]
25 .\" old: \\n[rst2man-indent\\n[rst2man-indent-level]]
26 .nr rst2man-indent-level -1
27 .\" new: \\n[rst2man-indent\\n[rst2man-indent-level]]
28 .in \\n[rst2man-indent\\n[rst2man-indent-level]]u
29 ..
30 .TH "BTRFS-FILESYSTEM" "8" "May 18, 2026" "7.0" "BTRFS"
31 .SH NAME
32 btrfs-filesystem \- command group that primarily does work on the whole filesystems
33 .SH SYNOPSIS
34 .sp
35 \fBbtrfs filesystem\fP <subcommand> <args>
36 .SH DESCRIPTION
37 .sp
38 \fBbtrfs filesystem\fP is used to perform several whole filesystem level tasks,
39 including all the regular filesystem operations like resizing, space stats,
40 label setting/getting, and defragmentation. There are other whole filesystem
41 tasks like scrub or balance that are grouped in separate commands (\fI\%btrfs\-scrub(8)\fP, \fI\%btrfs\-balance(8)\fP).
42 .SH SUBCOMMAND
43 .INDENT 0.0
44 .TP
45 .B df [options] <path>
46 Show a terse summary information about allocation of block group types of a given
47 mount point. The original purpose of this command was a debugging helper. The
48 output needs to be further interpreted and is not suitable for quick overview.
49 .sp
50 An example with description:
51 .INDENT 7.0
52 .IP \(bu 2
53 device size: \fI1.9TiB\fP, one device, no RAID
54 .IP \(bu 2
55 filesystem size: \fI1.9TiB\fP
56 .IP \(bu 2
57 created with: \fBmkfs.btrfs \-d single \-m single\fP
58 .UNINDENT
59 .INDENT 7.0
60 .INDENT 3.5
61 .sp
62 .EX
63 $ btrfs filesystem df /path
64 Data, single: total=1.15TiB, used=1.13TiB
65 System, single: total=32.00MiB, used=144.00KiB
66 Metadata, single: total=12.00GiB, used=6.45GiB
67 GlobalReserve, single: total=512.00MiB, used=0.00B
68 .EE
69 .UNINDENT
70 .UNINDENT
71 .INDENT 7.0
72 .IP \(bu 2
73 \fIData\fP, \fISystem\fP and \fIMetadata\fP are separate block group types.
74 \fIGlobalReserve\fP is an artificial and internal emergency space, see
75 below.
76 .IP \(bu 2
77 \fIsingle\fP \-\- the allocation profile, defined at mkfs time
78 .IP \(bu 2
79 \fItotal\fP \-\- sum of space reserved for all allocation profiles of the
80 given type, i.e. all Data/single. Note that it\(aqs not total size of
81 filesystem.
82 .IP \(bu 2
83 \fIused\fP \-\- sum of used space of the above, i.e. file extents, metadata blocks
84 .UNINDENT
85 .sp
86 \fIGlobalReserve\fP is an artificial and internal emergency space. It is used e.g.
87 when the filesystem is full. Its \fItotal\fP size is dynamic based on the
88 filesystem size, usually not larger than 512MiB, \fIused\fP may fluctuate.
89 .sp
90 The GlobalReserve is a portion of Metadata. In case the filesystem metadata is
91 exhausted, \fIGlobalReserve/total + Metadata/used = Metadata/total\fP\&. Otherwise
92 there appears to be some unused space of Metadata.
93 .sp
94 \fBOptions\fP
95 .INDENT 7.0
96 .TP
97 .B \-b|\-\-raw
98 raw numbers in bytes, without the \fIB\fP suffix
99 .TP
100 .B \-h|\-\-human\-readable
101 print human friendly numbers, base 1024, this is the default
102 .UNINDENT
103 .INDENT 7.0
104 .TP
105 .B \-H
106 print human friendly numbers, base 1000
107 .TP
108 .B \-\-iec
109 select the 1024 base for the following options, according to the IEC standard
110 .TP
111 .B \-\-si
112 select the 1000 base for the following options, according to the SI standard
113 .UNINDENT
114 .INDENT 7.0
115 .TP
116 .B \-k|\-\-kbytes
117 show sizes in KiB, or kB with \-\-si
118 .TP
119 .B \-m|\-\-mbytes
120 show sizes in MiB, or MB with \-\-si
121 .TP
122 .B \-g|\-\-gbytes
123 show sizes in GiB, or GB with \-\-si
124 .TP
125 .B \-t|\-\-tbytes
126 show sizes in TiB, or TB with \-\-si
127 .UNINDENT
128 .sp
129 If conflicting options are passed, the last one takes precedence.
130 .UNINDENT
131 .INDENT 0.0
132 .TP
133 .B defragment [options] <file>|<dir> [<file>|<dir>...]
134 Defragment file data on a mounted filesystem. Requires kernel 2.6.33 and newer.
135 .sp
136 If \fI\-r\fP is passed, files in \fIdir\fP will be defragmented recursively (not
137 descending to subvolumes, mount points and directory symlinks).
138 The start position and the number of bytes to defragment can be specified by
139 start and length using \fI\-s\fP and \fI\-l\fP options below.
140 Extents bigger than value given by \fI\-t\fP will be skipped, otherwise this value
141 is used as a target extent size, but is only advisory and may not be reached
142 if the free space is too fragmented.
143 Use 0 to take the kernel default, which is 256KiB but may change in the future.
144 You can also turn on compression in defragment operations.
145 .sp
146 \fBWARNING:\fP
147 .INDENT 7.0
148 .INDENT 3.5
149 Defragmenting with Linux kernel versions < 3.9 or ≥ 3.14\-rc2 as well as
150 with Linux stable kernel versions ≥ 3.10.31, ≥ 3.12.12 or ≥ 3.13.4 will break up
151 the reflinks of COW data (for example files copied with \fBcp \-\-reflink\fP,
152 snapshots or de\-duplicated data).
153 This may cause considerable increase of space usage depending on the broken up
154 reflinks.
155 .UNINDENT
156 .UNINDENT
157 .sp
158 \fBNOTE:\fP
159 .INDENT 7.0
160 .INDENT 3.5
161 Directory arguments without \fI\-r\fP do not defragment files recursively but will
162 defragment certain internal trees (extent tree and the subvolume tree). This has been
163 confusing and could be removed in the future.
164 .UNINDENT
165 .UNINDENT
166 .sp
167 For \fIstart\fP, \fIlen\fP, \fIsize\fP it is possible to append
168 units designator: \fIK\fP, \fIM\fP, \fIG\fP, \fIT\fP, \fIP\fP, or \fIE\fP, which represent
169 KiB, MiB, GiB, TiB, PiB, or EiB, respectively (case does not matter).
170 .sp
171 \fBOptions\fP
172 .INDENT 7.0
173 .TP
174 .B \-c[<algo>]
175 compress file contents while defragmenting. Optional argument selects the compression
176 algorithm, \fIzlib\fP (default), \fIlzo\fP or \fIzstd\fP\&. Currently it\(aqs not possible to select no
177 compression. See also section \fIEXAMPLES\fP\&.
178 .TP
179 .B \-L|\-\-level <level>
180 Since kernel 6.15 the compression can also take the level parameter which will be used
181 only for the defragmentation and overrides the eventual mount option compression level.
182 Valid levels depend on the compression algorithms: \fIzlib\fP
183 1..9, \fIlzo\fP does not have any levels, \fIzstd\fP the standard levels 1..15 and also the
184 realtime \-1..\-15.
185 .UNINDENT
186 .INDENT 7.0
187 .TP
188 .B \-\-nocomp
189 Do not compress while defragmenting, uncompress extents if needed.
190 .TP
191 .B \-r
192 defragment files recursively in given directories, does not descend to
193 subvolumes or mount points
194 .TP
195 .B \-f
196 flush data for each file before going to the next file.
197 .sp
198 This will limit the amount of dirty data to current file, otherwise the amount
199 accumulates from several files and will increase system load. This can also lead
200 to ENOSPC if there\(aqs too much dirty data to write and it\(aqs not possible to make
201 the reservations for the new data (i.e. how the COW design works).
202 .UNINDENT
203 .INDENT 7.0
204 .TP
205 .B \-s <start>[kKmMgGtTpPeE]
206 defragmentation will start from the given offset, default is beginning of a file
207 .TP
208 .B \-l <len>[kKmMgGtTpPeE]
209 defragment only up to \fIlen\fP bytes, default is the file size
210 .TP
211 .B \-t <size>[kKmMgGtTpPeE]
212 target extent size, do not touch extents bigger than \fIsize\fP, default: 32MiB
213 .sp
214 The value is only advisory and the final size of the extents may differ,
215 depending on the state of the free space and fragmentation or other internal
216 logic. Reasonable values are from tens to hundreds of megabytes.
217 .UNINDENT
218 .INDENT 7.0
219 .TP
220 .BI \-\-step \ SIZE
221 Perform defragmentation in the range in SIZE steps and flush (\fI\-f\fP) after each one.
222 The range is default (the whole file) or given by \fI\-s\fP and \fI\-l\fP, split into
223 the steps or done in one go if the step is larger. Minimum range size is 256KiB.
224 With verbosity options the progress of defragmentation will be also printed.
225 .TP
226 .B \-v
227 (deprecated) alias for global \fI\-v\fP option
228 .UNINDENT
229 .TP
230 .B du [options] <path> [<path>..]
231 Calculate disk usage of the target files using FIEMAP. For individual
232 files, it will report a count of total bytes, and exclusive (not
233 shared) bytes. We also calculate a \(aqset shared\(aq value which is
234 described below.
235 .sp
236 Each argument to \fBbtrfs filesystem du\fP will have a \fIset shared\fP value
237 calculated for it. We define each \fIset\fP as those files found by a
238 recursive search of an argument (recursion descends to subvolumes but not
239 mount points). The \fIset shared\fP value then is a sum of all shared space
240 referenced by the set.
241 .sp
242 \fIset shared\fP takes into account overlapping shared extents, hence it
243 isn\(aqt as simple as adding up shared extents.
244 .sp
245 \fBOptions\fP
246 .INDENT 7.0
247 .TP
248 .B \-s|\-\-summarize
249 display only a total for each argument
250 .UNINDENT
251 .INDENT 7.0
252 .TP
253 .B \-\-raw
254 raw numbers in bytes, without the \fIB\fP suffix.
255 .TP
256 .B \-\-human\-readable
257 print human friendly numbers, base 1024, this is the default
258 .TP
259 .B \-\-iec
260 select the 1024 base for the following options, according to the IEC standard.
261 .TP
262 .B \-\-si
263 select the 1000 base for the following options, according to the SI standard.
264 .TP
265 .B \-\-kbytes
266 show sizes in KiB, or kB with \-\-si.
267 .TP
268 .B \-\-mbytes
269 show sizes in MiB, or MB with \-\-si.
270 .TP
271 .B \-\-gbytes
272 show sizes in GiB, or GB with \-\-si.
273 .TP
274 .B \-\-tbytes
275 show sizes in TiB, or TB with \-\-si.
276 .UNINDENT
277 .UNINDENT
278 .INDENT 0.0
279 .TP
280 .B label [<device>|<mountpoint>] [<newlabel>]
281 Show or update the label of a filesystem. This works on a mounted filesystem or
282 a filesystem image.
283 .sp
284 The \fInewlabel\fP argument is optional. Current label is printed if the argument
285 is omitted.
286 .sp
287 \fBNOTE:\fP
288 .INDENT 7.0
289 .INDENT 3.5
290 The maximum allowable length shall be less than 256 chars and must not contain
291 a newline. The trailing newline is stripped automatically.
292 .UNINDENT
293 .UNINDENT
294 .TP
295 .B mkswapfile [\-s size] file
296 Create a new file that\(aqs suitable and formatted as a swapfile. Default
297 size is 2GiB, fixed page size 4KiB, minimum size is 40KiB.
298 .sp
299 A swapfile must be created in a specific way: NOCOW and preallocated.
300 Subvolume containing a swapfile cannot be snapshotted and blocks of an
301 activated swapfile cannot be balanced.
302 .sp
303 Swapfile creation can be achieved by standalone commands too. Activation
304 needs to be done by command \X'tty: link https://man7.org/linux/man-pages/man8/swapon.8.html'\fI\%swapon(8)\fP\X'tty: link'\&. See also command
305 \fBbtrfs inspect\-internal map\-swapfile\fP
306 and the \fI\%Swapfile feature\fP description.
307 .sp
308 \fBNOTE:\fP
309 .INDENT 7.0
310 .INDENT 3.5
311 The command is a simplified version of \(aqmkswap\(aq, if you want to set
312 label, page size, or other parameters please use \(aqmkswap\(aq proper.
313 .UNINDENT
314 .UNINDENT
315 .sp
316 \fBOptions\fP
317 .INDENT 7.0
318 .TP
319 .B \-s|\-\-size SIZE
320 Create swapfile of a given size SIZE (accepting k/m/g/e/p
321 suffix).
322 .TP
323 .B \-U|\-\-uuid UUID
324 specify UUID to use, or a special value: clear (all zeros), random,
325 time (time\-based random)
326 .UNINDENT
327 .UNINDENT
328 .INDENT 0.0
329 .TP
330 .B resize [options] [<devid>:][+/\-]<size>[kKmMgGtTpPeE]|[<devid>:]max <path>
331 Resize a mounted filesystem identified by \fIpath\fP\&. A particular device
332 can be resized by specifying a \fIdevid\fP\&.
333 .sp
334 \fBNOTE:\fP
335 .INDENT 7.0
336 .INDENT 3.5
337 To resize a file containing a BTRFS image, please use the \-\-offline flag.
338 .UNINDENT
339 .UNINDENT
340 .sp
341 The \fIdevid\fP can be found in the output of \fBbtrfs filesystem show\fP and
342 defaults to 1 if not specified.
343 The \fIsize\fP parameter specifies the new size of the filesystem.
344 If the prefix \fI+\fP or \fI\-\fP is present the size is increased or decreased
345 by the quantity \fIsize\fP\&.
346 If no units are specified, bytes are assumed for \fIsize\fP\&.
347 Optionally, the size parameter may be suffixed by one of the following
348 unit designators: \fIK\fP, \fIM\fP, \fIG\fP, \fIT\fP, \fIP\fP, or \fIE\fP, which represent
349 KiB, MiB, GiB, TiB, PiB, or EiB, respectively (case does not matter).
350 .sp
351 If \fImax\fP is passed, the filesystem will occupy all available space on the
352 device respecting \fIdevid\fP (remember, devid 1 by default).
353 .sp
354 The resize command does not manipulate the size of underlying
355 partition. If you wish to enlarge/reduce a filesystem, you must make sure you
356 expand the partition before enlarging the filesystem and shrink the
357 partition after reducing the size of the filesystem. This can be done using
358 \X'tty: link https://man7.org/linux/man-pages/man8/fdisk.8.html'\fI\%fdisk(8)\fP\X'tty: link' or \X'tty: link https://man7.org/linux/man-pages/man8/parted.8.html'\fI\%parted(8)\fP\X'tty: link' to delete the existing partition and recreate
359 it with the new desired size. When recreating the partition make sure to use
360 the same starting partition offset as before.
361 .sp
362 The size of the portion that the filesystem uses of an underlying device can be
363 determined via the \fBbtrfs filesystem show \-\-raw\fP command on the
364 filesystem’s mount point (where it’s given for each \fIdevid\fP after the string
365 \fIsize\fP or via the \fBbtrfs inspect\-internal dump\-super\fP command on the
366 specific device (where it’s given as the value of \fIdev_item.total_bytes\fP, which
367 is not to be confused with \fItotal_bytes\fP).
368 The value is also the address of the first byte not used by the
369 filesystem.
370 .sp
371 Growing is usually instant as it only updates the size. However, shrinking could
372 take a long time if there are data in the device area that\(aqs beyond the new
373 end. Relocation of the data takes time.
374 .sp
375 Note that there\(aqs a lower limit on the new size (either specified
376 as an absolute size or difference) that is checked by kernel and
377 rejected eventually as invalid. Lower values will print a warning but
378 still pass the request to kernel. The currently known value is 256MiB.
379 .sp
380 See also section \fIEXAMPLES\fP\&.
381 .sp
382 \fBOptions\fP
383 .INDENT 7.0
384 .TP
385 .B \-\-enqueue
386 wait if there\(aqs another exclusive operation running, otherwise continue
387 .TP
388 .B \-\-offline
389 resize an unmounted (offline) filesystem
390 .sp
391 \fBWARNING:\fP
392 .INDENT 7.0
393 .INDENT 3.5
394 The offline resize functionality currently
395 supports \fBonly increasing\fP the size of \fBsingle\-device\fP
396 filesystems. IOW, shrinking and multi\-device filesystems are
397 \fBnot supported\fP with this option.
398 .UNINDENT
399 .UNINDENT
400 .sp
401 For filesystems stored in regular files, the file will be
402 truncated to the new size as part of the resize operation.
403 This flag is cannot be used together with with \-\-enqueue since
404 offline resizing is synchronous.
405 .UNINDENT
406 .TP
407 .B show [options] [<path>|<uuid>|<device>|<label>]
408 Show the btrfs filesystem with some additional info about devices and space
409 allocation.
410 .sp
411 If no option none of \fIpath\fP/\fIuuid\fP/\fIdevice\fP/\fIlabel\fP is passed, information
412 about all the BTRFS filesystems is shown, both mounted and unmounted.
413 .sp
414 \fBOptions\fP
415 .INDENT 7.0
416 .TP
417 .B \-m|\-\-mounted
418 probe kernel for mounted BTRFS filesystems
419 .TP
420 .B \-d|\-\-all\-devices
421 scan all devices under \fB/dev\fP, otherwise the devices list is extracted from the
422 \fB/proc/partitions\fP file. This is a fallback option if there\(aqs no device node
423 manager (like udev) available in the system.
424 .UNINDENT
425 .INDENT 7.0
426 .TP
427 .B \-\-raw
428 raw numbers in bytes, without the \fIB\fP suffix
429 .TP
430 .B \-\-human\-readable
431 print human friendly numbers, base 1024, this is the default
432 .TP
433 .B \-\-iec
434 select the 1024 base for the following options, according to the IEC standard
435 .TP
436 .B \-\-si
437 select the 1000 base for the following options, according to the SI standard
438 .TP
439 .B \-\-kbytes
440 show sizes in KiB, or kB with \-\-si
441 .TP
442 .B \-\-mbytes
443 show sizes in MiB, or MB with \-\-si
444 .TP
445 .B \-\-gbytes
446 show sizes in GiB, or GB with \-\-si
447 .TP
448 .B \-\-tbytes
449 show sizes in TiB, or TB with \-\-si
450 .UNINDENT
451 .TP
452 .B commit\-stats
453 Print number of commits and time stats since mount. This is also available
454 in \fB/sys/fs/btrfs/FSID/commit_stats\fP\&. The stats are not persistent
455 and are collected since mount of the filesystem, one of them can be reset
456 to zero (\fIMax commit duration\fP).
457 .INDENT 7.0
458 .INDENT 3.5
459 .sp
460 .EX
461 UUID: bd18ebe1\-7e1d\-414f\-a3d5\-2644388b51cc
462 Commit stats since mount:
463 Total commits: 1133
464 Last commit duration: 0ms
465 Max commit duration: 10ms
466 Total time spent in commit: 4543ms
467 .EE
468 .UNINDENT
469 .UNINDENT
470 .sp
471 \fBOptions\fP
472 .INDENT 7.0
473 .TP
474 .B \-z|\-\-reset
475 print stats and reset \(aqmax_commit_ms\(aq (needs root)
476 .UNINDENT
477 .TP
478 .B sync <path>
479 Force a sync of the filesystem at \fIpath\fP, similar to the \X'tty: link https://man7.org/linux/man-pages/man1/sync.1.html'\fI\%sync(1)\fP\X'tty: link' command. In
480 addition, it starts cleaning of deleted subvolumes. To wait for the subvolume
481 deletion to complete use the \fBbtrfs subvolume sync\fP command.
482 .TP
483 .B usage [options] <path> [<path>...]
484 Show detailed information about internal filesystem usage. This is supposed to
485 replace the \fBbtrfs filesystem df\fP command in the long run.
486 .sp
487 The level of detail can differ if the command is run under a regular or the
488 root user (due to use of restricted ioctl). For both there\(aqs a summary section
489 with information about space usage:
490 .INDENT 7.0
491 .INDENT 3.5
492 .sp
493 .EX
494 $ btrfs filesystem usage /path
495 WARNING: cannot read detailed chunk info, RAID5/6 numbers will be incorrect, run as root
496 Overall:
497 Device size: 1.82TiB
498 Device allocated: 1.17TiB
499 Device unallocated: 669.99GiB
500 Device missing: 0.00B
501 Device slack: 1.00GiB
502 Used: 1.14TiB
503 Free (estimated): 692.57GiB (min: 692.57GiB)
504 Free (statfs, df) 692.57GiB
505 Data ratio: 1.00
506 Metadata ratio: 1.00
507 Global reserve: 512.00MiB (used: 0.00B)
508 Multiple profiles: no
509 .EE
510 .UNINDENT
511 .UNINDENT
512 .INDENT 7.0
513 .IP \(bu 2
514 \fIDevice size\fP \-\- sum of raw device capacity available to the
515 filesystem, note that this may not be the same as the total device
516 size (the difference is accounted as slack)
517 .IP \(bu 2
518 \fIDevice allocated\fP \-\- sum of total space allocated for
519 data/metadata/system profiles, this also accounts space reserved but
520 not yet used for extents
521 .IP \(bu 2
522 \fIDevice unallocated\fP \-\- the remaining unallocated space for future
523 allocations (difference of the above two numbers)
524 .IP \(bu 2
525 \fIDevice missing\fP \-\- sum of capacity of all missing devices
526 .IP \(bu 2
527 \fIDevice slack\fP \-\- sum of slack space on all devices (difference
528 between entire device size and the space occupied by filesystem)
529 .IP \(bu 2
530 \fIUsed\fP \-\- sum of the used space of data/metadata/system profiles, not
531 including the reserved space
532 .IP \(bu 2
533 \fIFree (estimated)\fP \-\- approximate size of the remaining free space
534 usable for data, including currently allocated space and estimating
535 the usage of the unallocated space based on the block group profiles,
536 the \fImin\fP is the lower bound of the estimate in case multiple
537 profiles are present
538 .IP \(bu 2
539 \fIFree (statfs, df)\fP \-\- the amount of space available for data as
540 reported by the \fBstatfs/statvfs\fP syscall, also returned as \fIAvail\fP in the
541 output of \fBdf\fP\&. The value is calculated in a different way and may
542 not match the estimate in some cases (e.g. multiple profiles).
543 .IP \(bu 2
544 \fIData ratio\fP \-\- ratio of total space for data including redundancy or
545 parity to the effectively usable data space, e.g. single is 1.0, RAID1
546 is 2.0 and for RAID5/6 it depends on the number of devices
547 .IP \(bu 2
548 \fIMetadata ratio\fP \-\- ditto, for metadata
549 .IP \(bu 2
550 \fIGlobal reserve\fP \-\- portion of metadata currently used for global
551 block reserve, used for emergency purposes (like deletion on a full
552 filesystem)
553 .IP \(bu 2
554 \fIMultiple profiles\fP \-\- what block group types (data, metadata) have
555 more than one profile (single, raid1, ...), see \fI\%btrfs(5)\fP section
556 \fI\%FILESYSTEMS WITH MULTIPLE PROFILES\fP\&.
557 .UNINDENT
558 .sp
559 And on a zoned filesystem there are two more lines in the \fIDevice\fP section:
560 .INDENT 7.0
561 .INDENT 3.5
562 .sp
563 .EX
564 Device zone unusable: 5.13GiB
565 Device zone size: 256.00MiB
566 .EE
567 .UNINDENT
568 .UNINDENT
569 .INDENT 7.0
570 .IP \(bu 2
571 \fIDevice zone unusable\fP \-\- sum of of space that\(aqs been used in the
572 past but now is not due to COW and not referenced anymore, the chunks
573 have to be reclaimed and zones reset to make it usable again
574 .IP \(bu 2
575 \fIDevice zone size\fP \-\- the reported zone size of the host\-managed
576 device, same for all devices
577 .UNINDENT
578 .sp
579 The root user will also see stats broken down by block group types:
580 .INDENT 7.0
581 .INDENT 3.5
582 .sp
583 .EX
584 Data,single: Size:1.15TiB, Used:1.13TiB (98.26%)
585 /dev/sdb 1.15TiB
586
587 Metadata,single: Size:12.00GiB, Used:6.45GiB (53.75%)
588 /dev/sdb 12.00GiB
589
590 System,single: Size:32.00MiB, Used:144.00KiB (0.44%)
591 /dev/sdb 32.00MiB
592
593 Unallocated:
594 /dev/sdb 669.99GiB
595 .EE
596 .UNINDENT
597 .UNINDENT
598 .sp
599 \fIData\fP is block group type, \fIsingle\fP is block group profile, \fISize\fP is total
600 size occupied by this type, \fIUsed\fP is the actually used space, the percent is
601 ratio of \fIUsed/Size\fP\&. The \fIUnallocated\fP is remaining space.
602 .sp
603 \fBOptions\fP
604 .INDENT 7.0
605 .TP
606 .B \-b|\-\-raw
607 raw numbers in bytes, without the \fIB\fP suffix
608 .TP
609 .B \-h|\-\-human\-readable
610 print human friendly numbers, base 1024, this is the default
611 .UNINDENT
612 .INDENT 7.0
613 .TP
614 .B \-H
615 print human friendly numbers, base 1000
616 .TP
617 .B \-\-iec
618 select the 1024 base for the following options, according to the IEC standard
619 .TP
620 .B \-\-si
621 select the 1000 base for the following options, according to the SI standard
622 .UNINDENT
623 .INDENT 7.0
624 .TP
625 .B \-k|\-\-kbytes
626 show sizes in KiB, or kB with \-\-si
627 .TP
628 .B \-m|\-\-mbytes
629 show sizes in MiB, or MB with \-\-si
630 .TP
631 .B \-g|\-\-gbytes
632 show sizes in GiB, or GB with \-\-si
633 .TP
634 .B \-t|\-\-tbytes
635 show sizes in TiB, or TB with \-\-si
636 .UNINDENT
637 .INDENT 7.0
638 .TP
639 .B \-T
640 show data in tabular format
641 .UNINDENT
642 .sp
643 If conflicting options are passed, the last one takes precedence.
644 .UNINDENT
645 .SH EXAMPLES
646 .sp
647 \fB$ btrfs filesystem defrag \-v \-r dir/\fP
648 .sp
649 Recursively defragment files under \fBdir/\fP, print files as they are processed.
650 The file names will be printed in batches, similarly the amount of data triggered
651 by defragmentation will be proportional to last N printed files. The system dirty
652 memory throttling will slow down the defragmentation but there can still be a lot
653 of IO load and the system may stall for a moment.
654 .sp
655 \fB$ btrfs filesystem defrag \-v \-r \-f dir/\fP
656 .sp
657 Recursively defragment files under \fBdir/\fP, be verbose and wait until all blocks
658 are flushed before processing next file. You can note slower progress of the
659 output and lower IO load (proportional to currently defragmented file).
660 .sp
661 \fB$ btrfs filesystem defrag \-v \-r \-f \-clzo dir/\fP
662 .sp
663 Recursively defragment files under \fBdir/\fP, be verbose, wait until all blocks are
664 flushed and force file compression.
665 .sp
666 \fB$ btrfs filesystem defrag \-v \-r \-t 64M dir/\fP
667 .sp
668 Recursively defragment files under \fBdir/\fP, be verbose and try to merge extents
669 to be about 64MiB. As stated above, the success rate depends on actual free
670 space fragmentation and the final result is not guaranteed to meet the target
671 even if run repeatedly.
672 .sp
673 \fB$ btrfs filesystem resize \-1G /path\fP
674 .sp
675 \fB$ btrfs filesystem resize 1:\-1G /path\fP
676 .sp
677 Shrink size of the filesystem\(aqs device id 1 by 1GiB. The first syntax expects a
678 device with id 1 to exist, otherwise fails. The second is equivalent and more
679 explicit. For a single\-device filesystem it\(aqs typically not necessary to
680 specify the devid though.
681 .sp
682 \fB$ btrfs filesystem resize max /path\fP
683 .sp
684 \fB$ btrfs filesystem resize 1:max /path\fP
685 .sp
686 Let\(aqs assume that devid 1 exists and the filesystem does not occupy the whole
687 block device, e.g. it has been enlarged and we want to grow the filesystem. By
688 simply using \fImax\fP as size we will achieve that.
689 .sp
690 \fBNOTE:\fP
691 .INDENT 0.0
692 .INDENT 3.5
693 There are two ways to minimize the filesystem on a given device. The
694 \fBbtrfs inspect\-internal min\-dev\-size\fP command, or iteratively shrink in steps.
695 .UNINDENT
696 .UNINDENT
697 .SH EXIT STATUS
698 .sp
699 \fBbtrfs filesystem\fP returns a zero exit status if it succeeds. Non zero is
700 returned in case of failure.
701 .SH AVAILABILITY
702 .sp
703 \fBbtrfs\fP is part of btrfs\-progs. Please refer to the documentation at
704 \X'tty: link https://btrfs.readthedocs.io'\fI\%https://btrfs.readthedocs.io\fP\X'tty: link'\&.
705 .SH SEE ALSO
706 .sp
707 \fI\%btrfs\-subvolume(8)\fP,
708 \fI\%mkfs.btrfs(8)\fP
709 .\" Generated by docutils manpage writer.
710 .