.\" Man page generated from reStructuredText. . . .nr rst2man-indent-level 0 . .de1 rstReportMargin \\$1 \\n[an-margin] level \\n[rst2man-indent-level] level margin: \\n[rst2man-indent\\n[rst2man-indent-level]] - \\n[rst2man-indent0] \\n[rst2man-indent1] \\n[rst2man-indent2] .. .de1 INDENT .\" .rstReportMargin pre: . RS \\$1 . nr rst2man-indent\\n[rst2man-indent-level] \\n[an-margin] . nr rst2man-indent-level +1 .\" .rstReportMargin post: .. .de UNINDENT . RE .\" indent \\n[an-margin] .\" old: \\n[rst2man-indent\\n[rst2man-indent-level]] .nr rst2man-indent-level -1 .\" new: \\n[rst2man-indent\\n[rst2man-indent-level]] .in \\n[rst2man-indent\\n[rst2man-indent-level]]u .. .TH "BTRFS-FILESYSTEM" "8" "Mar 24, 2024" "6.6.3" "BTRFS" .SH NAME btrfs-filesystem \- command group that primarily does work on the whole filesystems .SH SYNOPSIS .sp \fBbtrfs filesystem\fP .SH DESCRIPTION .sp \fBbtrfs filesystem\fP is used to perform several whole filesystem level tasks, including all the regular filesystem operations like resizing, space stats, label setting/getting, and defragmentation. There are other whole filesystem tasks like scrub or balance that are grouped in separate commands. .SH SUBCOMMAND .INDENT 0.0 .TP .B df [options] Show a terse summary information about allocation of block group types of a given mount point. The original purpose of this command was a debugging helper. The output needs to be further interpreted and is not suitable for quick overview. .sp An example with description: .INDENT 7.0 .IP \(bu 2 device size: \fI1.9TiB\fP, one device, no RAID .IP \(bu 2 filesystem size: \fI1.9TiB\fP .IP \(bu 2 created with: \fBmkfs.btrfs \-d single \-m single\fP .UNINDENT .INDENT 7.0 .INDENT 3.5 .sp .EX $ btrfs filesystem df /path Data, single: total=1.15TiB, used=1.13TiB System, single: total=32.00MiB, used=144.00KiB Metadata, single: total=12.00GiB, used=6.45GiB GlobalReserve, single: total=512.00MiB, used=0.00B .EE .UNINDENT .UNINDENT .INDENT 7.0 .IP \(bu 2 \fIData\fP, \fISystem\fP and \fIMetadata\fP are separate block group types. \fIGlobalReserve\fP is an artificial and internal emergency space, see below. .IP \(bu 2 \fIsingle\fP \-\- the allocation profile, defined at mkfs time .IP \(bu 2 \fItotal\fP \-\- sum of space reserved for all allocation profiles of the given type, i.e. all Data/single. Note that it\(aqs not total size of filesystem. .IP \(bu 2 \fIused\fP \-\- sum of used space of the above, i.e. file extents, metadata blocks .UNINDENT .sp \fIGlobalReserve\fP is an artificial and internal emergency space. It is used e.g. when the filesystem is full. Its \fItotal\fP size is dynamic based on the filesystem size, usually not larger than 512MiB, \fIused\fP may fluctuate. .sp The GlobalReserve is a portion of Metadata. In case the filesystem metadata is exhausted, \fIGlobalReserve/total + Metadata/used = Metadata/total\fP\&. Otherwise there appears to be some unused space of Metadata. .sp \fBOptions\fP .INDENT 7.0 .TP .B \-b|\-\-raw raw numbers in bytes, without the \fIB\fP suffix .TP .B \-h|\-\-human\-readable print human friendly numbers, base 1024, this is the default .UNINDENT .INDENT 7.0 .TP .B \-H print human friendly numbers, base 1000 .TP .B \-\-iec select the 1024 base for the following options, according to the IEC standard .TP .B \-\-si select the 1000 base for the following options, according to the SI standard .UNINDENT .INDENT 7.0 .TP .B \-k|\-\-kbytes show sizes in KiB, or kB with \-\-si .TP .B \-m|\-\-mbytes show sizes in MiB, or MB with \-\-si .TP .B \-g|\-\-gbytes show sizes in GiB, or GB with \-\-si .TP .B \-t|\-\-tbytes show sizes in TiB, or TB with \-\-si .UNINDENT .sp If conflicting options are passed, the last one takes precedence. .UNINDENT .INDENT 0.0 .TP .B defragment [options] | [|...] Defragment file data on a mounted filesystem. Requires kernel 2.6.33 and newer. .sp If \fI\-r\fP is passed, files in dir will be defragmented recursively (not descending to subvolumes, mount points and directory symlinks). The start position and the number of bytes to defragment can be specified by start and length using \fI\-s\fP and \fI\-l\fP options below. Extents bigger than value given by \fI\-t\fP will be skipped, otherwise this value is used as a target extent size, but is only advisory and may not be reached if the free space is too fragmented. Use 0 to take the kernel default, which is 256KiB but may change in the future. You can also turn on compression in defragment operations. .sp \fBWARNING:\fP .INDENT 7.0 .INDENT 3.5 Defragmenting with Linux kernel versions < 3.9 or ≥ 3.14\-rc2 as well as with Linux stable kernel versions ≥ 3.10.31, ≥ 3.12.12 or ≥ 3.13.4 will break up the reflinks of COW data (for example files copied with \fBcp \-\-reflink\fP, snapshots or de\-duplicated data). This may cause considerable increase of space usage depending on the broken up reflinks. .UNINDENT .UNINDENT .sp \fBNOTE:\fP .INDENT 7.0 .INDENT 3.5 Directory arguments without \fI\-r\fP do not defragment files recursively but will defragment certain internal trees (extent tree and the subvolume tree). This has been confusing and could be removed in the future. .UNINDENT .UNINDENT .sp For \fIstart\fP, \fIlen\fP, \fIsize\fP it is possible to append units designator: \fIK\fP, \fIM\fP, \fIG\fP, \fIT\fP, \fIP\fP, or \fIE\fP, which represent KiB, MiB, GiB, TiB, PiB, or EiB, respectively (case does not matter). .sp \fBOptions\fP .INDENT 7.0 .TP .B \-c[] compress file contents while defragmenting. Optional argument selects the compression algorithm, \fIzlib\fP (default), \fIlzo\fP or \fIzstd\fP\&. Currently it\(aqs not possible to select no compression. See also section \fIEXAMPLES\fP\&. .UNINDENT .INDENT 7.0 .TP .B \-r defragment files recursively in given directories, does not descend to subvolumes or mount points .TP .B \-f flush data for each file before going to the next file. .sp This will limit the amount of dirty data to current file, otherwise the amount accumulates from several files and will increase system load. This can also lead to ENOSPC if there\(aqs too much dirty data to write and it\(aqs not possible to make the reservations for the new data (i.e. how the COW design works). .UNINDENT .INDENT 7.0 .TP .B \-s [kKmMgGtTpPeE] defragmentation will start from the given offset, default is beginning of a file .TP .B \-l [kKmMgGtTpPeE] defragment only up to \fIlen\fP bytes, default is the file size .TP .B \-t [kKmMgGtTpPeE] target extent size, do not touch extents bigger than \fIsize\fP, default: 32MiB .sp The value is only advisory and the final size of the extents may differ, depending on the state of the free space and fragmentation or other internal logic. Reasonable values are from tens to hundreds of megabytes. .UNINDENT .INDENT 7.0 .TP .BI \-\-step \ SIZE Perform defragmention in the range in SIZE steps and flush (\fI\-f\fP) after each one. The range is default (the whole file) or given by \fI\-s\fP and \fI\-l\fP, split into the steps or done in one go if the step is larger. Minimum range size is 256KiB. .TP .B \-v (deprecated) alias for global \fI\-v\fP option .UNINDENT .TP .B du [options] [..] Calculate disk usage of the target files using FIEMAP. For individual files, it will report a count of total bytes, and exclusive (not shared) bytes. We also calculate a \(aqset shared\(aq value which is described below. .sp Each argument to \fBbtrfs filesystem du\fP will have a \fIset shared\fP value calculated for it. We define each \fIset\fP as those files found by a recursive search of an argument (recursion descends to subvolumes but not mount points). The \fIset shared\fP value then is a sum of all shared space referenced by the set. .sp \fIset shared\fP takes into account overlapping shared extents, hence it isn\(aqt as simple as adding up shared extents. .sp \fBOptions\fP .INDENT 7.0 .TP .B \-s|\-\-summarize display only a total for each argument .UNINDENT .INDENT 7.0 .TP .B \-\-raw raw numbers in bytes, without the \fIB\fP suffix. .TP .B \-\-human\-readable print human friendly numbers, base 1024, this is the default .TP .B \-\-iec select the 1024 base for the following options, according to the IEC standard. .TP .B \-\-si select the 1000 base for the following options, according to the SI standard. .TP .B \-\-kbytes show sizes in KiB, or kB with \-\-si. .TP .B \-\-mbytes show sizes in MiB, or MB with \-\-si. .TP .B \-\-gbytes show sizes in GiB, or GB with \-\-si. .TP .B \-\-tbytes show sizes in TiB, or TB with \-\-si. .UNINDENT .UNINDENT .INDENT 0.0 .TP .B label [|] [] Show or update the label of a filesystem. This works on a mounted filesystem or a filesystem image. .sp The \fInewlabel\fP argument is optional. Current label is printed if the argument is omitted. .sp \fBNOTE:\fP .INDENT 7.0 .INDENT 3.5 The maximum allowable length shall be less than 256 chars and must not contain a newline. The trailing newline is stripped automatically. .UNINDENT .UNINDENT .TP .B mkswapfile [\-s size] file Create a new file that\(aqs suitable and formatted as a swapfile. Default size is 2GiB, fixed page size 4KiB, minimum size is 40KiB. .sp A swapfile must be created in a specific way: NOCOW and preallocated. Subvolume containing a swapfile cannot be snapshotted and blocks of an activated swapfile cannot be balanced. .sp Swapfile creation can be achieved by standalone commands too. Activation needs to be done by command \fBswapon(8)\fP\&. See also command \fBbtrfs inspect\-internal map\-swapfile\fP and the \fI\%Swapfile feature\fP description. .sp \fBNOTE:\fP .INDENT 7.0 .INDENT 3.5 The command is a simplified version of \(aqmkswap\(aq, if you want to set label, page size, or other parameters please use \(aqmkswap\(aq proper. .UNINDENT .UNINDENT .sp \fBOptions\fP .INDENT 7.0 .TP .B \-s|\-\-size SIZE Create swapfile of a given size SIZE (accepting k/m/g/e/p suffix). .TP .B \-U|\-\-uuid UUID specify UUID to use, or a special value: clear (all zeros), random, time (time\-based random) .UNINDENT .UNINDENT .INDENT 0.0 .TP .B resize [options] [:][+/\-][kKmMgGtTpPeE]|[:]max Resize a mounted filesystem identified by \fIpath\fP\&. A particular device can be resized by specifying a \fIdevid\fP\&. .sp \fBWARNING:\fP .INDENT 7.0 .INDENT 3.5 If \fIpath\fP is a file containing a BTRFS image then resize does not work as expected and does not resize the image. This would resize the underlying filesystem instead. .UNINDENT .UNINDENT .sp The \fIdevid\fP can be found in the output of \fBbtrfs filesystem show\fP and defaults to 1 if not specified. The \fIsize\fP parameter specifies the new size of the filesystem. If the prefix \fI+\fP or \fI\-\fP is present the size is increased or decreased by the quantity \fIsize\fP\&. If no units are specified, bytes are assumed for \fIsize\fP\&. Optionally, the size parameter may be suffixed by one of the following unit designators: \fIK\fP, \fIM\fP, \fIG\fP, \fIT\fP, \fIP\fP, or \fIE\fP, which represent KiB, MiB, GiB, TiB, PiB, or EiB, respectively (case does not matter). .sp If \fImax\fP is passed, the filesystem will occupy all available space on the device respecting \fIdevid\fP (remember, devid 1 by default). .sp The resize command does not manipulate the size of underlying partition. If you wish to enlarge/reduce a filesystem, you must make sure you can expand the partition before enlarging the filesystem and shrink the partition after reducing the size of the filesystem. This can done using \fBfdisk(8)\fP or \fBparted(8)\fP to delete the existing partition and recreate it with the new desired size. When recreating the partition make sure to use the same starting partition offset as before. .sp Growing is usually instant as it only updates the size. However, shrinking could take a long time if there are data in the device area that\(aqs beyond the new end. Relocation of the data takes time. .sp See also section \fIEXAMPLES\fP\&. .sp \fBOptions\fP .INDENT 7.0 .TP .B \-\-enqueue wait if there\(aqs another exclusive operation running, otherwise continue .UNINDENT .TP .B show [options] [|||