{"id":3090,"date":"2022-12-20T16:43:27","date_gmt":"2022-12-20T19:43:27","guid":{"rendered":"http:\/\/lode.uno\/linux-man\/index.php\/2022\/12\/20\/btrfsfilesystem-man8\/"},"modified":"2022-12-20T16:43:27","modified_gmt":"2022-12-20T19:43:27","slug":"btrfsfilesystem-man8","status":"publish","type":"post","link":"https:\/\/lode.uno\/linux-man\/2022\/12\/20\/btrfsfilesystem-man8\/","title":{"rendered":"BTRFS&minus;FILESYSTEM (man8)"},"content":{"rendered":"<h1 align=\"center\">BTRFS\u2212FILESYSTEM<\/h1>\n<p> <a href=\"#NAME\">NAME<\/a><br \/> <a href=\"#SYNOPSIS\">SYNOPSIS<\/a><br \/> <a href=\"#DESCRIPTION\">DESCRIPTION<\/a><br \/> <a href=\"#SUBCOMMAND\">SUBCOMMAND<\/a><br \/> <a href=\"#EXAMPLES\">EXAMPLES<\/a><br \/> <a href=\"#EXIT STATUS\">EXIT STATUS<\/a><br \/> <a href=\"#AVAILABILITY\">AVAILABILITY<\/a><br \/> <a href=\"#SEE ALSO\">SEE ALSO<\/a> <\/p>\n<hr>\n<h2>NAME <a name=\"NAME\"><\/a> <\/h2>\n<p style=\"margin-left:11%; margin-top: 1em\">btrfs-filesystem \u2212 command group that primarily does work on the whole filesystems<\/p>\n<h2>SYNOPSIS <a name=\"SYNOPSIS\"><\/a> <\/h2>\n<p style=\"margin-left:11%; margin-top: 1em\"><b>btrfs filesystem<\/b> <i><subcommand> <args><\/i><\/p>\n<h2>DESCRIPTION <a name=\"DESCRIPTION\"><\/a> <\/h2>\n<p style=\"margin-left:11%; margin-top: 1em\"><i><b>btrfs filesystem<\/b><\/i> 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.<\/p>\n<h2>SUBCOMMAND <a name=\"SUBCOMMAND\"><\/a> <\/h2>\n<p style=\"margin-left:11%; margin-top: 1em\"><b>df<\/b> [options] <i><path><\/i><\/p>\n<p style=\"margin-left:17%;\">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.<\/p>\n<p style=\"margin-left:17%; margin-top: 1em\">An example with description:<\/p>\n<p style=\"margin-left:23%; margin-top: 1em\">\u2022 device size: <i>1.9TiB<\/i>, one device, no RAID<\/p>\n<p style=\"margin-left:23%; margin-top: 1em\">\u2022 filesystem size: <i>1.9TiB<\/i><\/p>\n<p style=\"margin-left:23%; margin-top: 1em\">\u2022 created with: <i>mkfs.btrfs \u2212d single \u2212m single<\/i><\/p>\n<p style=\"margin-left:23%; margin-top: 1em\">$ btrfs filesystem df \/path <br \/> Data, single: total=1.15TiB, used=1.13TiB <br \/> System, single: total=32.00MiB, used=144.00KiB <br \/> Metadata, single: total=12.00GiB, used=6.45GiB <br \/> GlobalReserve, single: total=512.00MiB, used=0.00B<\/p>\n<p style=\"margin-left:23%; margin-top: 1em\">\u2022 <i>Data<\/i>, <i>System<\/i> and <i>Metadata<\/i> are separate block group types. <i>GlobalReserve<\/i> is an artificial and internal emergency space, see below.<\/p>\n<p style=\"margin-left:23%; margin-top: 1em\">\u2022 <i>single<\/i> \u2014 the allocation profile, defined at mkfs time<\/p>\n<p style=\"margin-left:23%; margin-top: 1em\">\u2022 <i>total<\/i> \u2014 sum of space reserved for all allocation profiles of the given type, ie. all Data\/single. Note that it\u2019s not total size of filesystem.<\/p>\n<p style=\"margin-left:23%; margin-top: 1em\">\u2022 <i>used<\/i> \u2014 sum of used space of the above, ie. file extents, metadata blocks<\/p>\n<p style=\"margin-left:17%; margin-top: 1em\"><i>GlobalReserve<\/i> is an artificial and internal emergency space. It is used eg. when the filesystem is full. Its <i>total<\/i> size is dynamic based on the filesystem size, usually not larger than 512MiB, <i>used<\/i> may fluctuate.<\/p>\n<p style=\"margin-left:17%; margin-top: 1em\">The GlobalReserve is a portion of Metadata. In case the filesystem metadata is exhausted, <i>GlobalReserve\/total + Metadata\/used = Metadata\/total<\/i>. Otherwise there appears to be some unused space of Metadata.<\/p>\n<p style=\"margin-left:17%; margin-top: 1em\"><b>Options<\/b><\/p>\n<p style=\"margin-left:17%; margin-top: 1em\">\u2212b|\u2212\u2212raw<\/p>\n<p style=\"margin-left:23%;\">raw numbers in bytes, without the <i>B<\/i> suffix<\/p>\n<p style=\"margin-left:17%; margin-top: 1em\">\u2212h|\u2212\u2212human\u2212readable<\/p>\n<p style=\"margin-left:23%;\">print human friendly numbers, base 1024, this is the default<\/p>\n<p style=\"margin-left:17%; margin-top: 1em\">\u2212H<\/p>\n<p style=\"margin-left:23%;\">print human friendly numbers, base 1000<\/p>\n<p style=\"margin-left:17%; margin-top: 1em\">\u2212\u2212iec<\/p>\n<p style=\"margin-left:23%;\">select the 1024 base for the following options, according to the IEC standard<\/p>\n<p style=\"margin-left:17%; margin-top: 1em\">\u2212\u2212si<\/p>\n<p style=\"margin-left:23%;\">select the 1000 base for the following options, according to the SI standard<\/p>\n<p style=\"margin-left:17%; margin-top: 1em\">\u2212k|\u2212\u2212kbytes<\/p>\n<p style=\"margin-left:23%;\">show sizes in KiB, or kB with \u2212\u2212si<\/p>\n<p style=\"margin-left:17%; margin-top: 1em\">\u2212m|\u2212\u2212mbytes<\/p>\n<p style=\"margin-left:23%;\">show sizes in MiB, or MB with \u2212\u2212si<\/p>\n<p style=\"margin-left:17%; margin-top: 1em\">\u2212g|\u2212\u2212gbytes<\/p>\n<p style=\"margin-left:23%;\">show sizes in GiB, or GB with \u2212\u2212si<\/p>\n<p style=\"margin-left:17%; margin-top: 1em\">\u2212t|\u2212\u2212tbytes<\/p>\n<p style=\"margin-left:23%;\">show sizes in TiB, or TB with \u2212\u2212si<\/p>\n<p style=\"margin-left:23%; margin-top: 1em\">If conflicting options are passed, the last one takes precedence.<\/p>\n<p style=\"margin-left:11%; margin-top: 1em\"><b>defragment<\/b> [options] <i><file><\/i>|<i><dir><\/i> [<i><file><\/i>|<i><dir><\/i>&#8230;]<\/p>\n<p style=\"margin-left:17%;\">Defragment file data on a mounted filesystem. Requires kernel 2.6.33 and newer.<\/p>\n<p style=\"margin-left:17%; margin-top: 1em\">If <i>\u2212r<\/i> 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 <i>\u2212s<\/i> and <i>\u2212l<\/i> options below. Extents bigger than value given by <i>\u2212t<\/i> 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 256kB but may change in the future. You can also turn on compression in defragment operations.<\/p>\n<p style=\"margin-left:23%; margin-top: 1em\"><b><big>Warning<\/big><\/b> <br \/> Defragmenting with Linux kernel versions < 3.9 or \u2265 3.14\u2212rc2 as well as with Linux stable kernel versions \u2265 3.10.31, \u2265 3.12.12 or \u2265 3.13.4 will break up the reflinks of COW data (for example files copied with <b>cp \u2212\u2212reflink<\/b>, snapshots or de\u2212duplicated data). This may cause considerable increase of space usage depending on the broken up reflinks.<\/p>\n<p style=\"margin-left:23%; margin-top: 1em\"><b><big>Note<\/big><\/b> <br \/> Directory arguments without <i>\u2212r<\/i> 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.<\/p>\n<p style=\"margin-left:17%;\">For <i>start<\/i>, <i>len<\/i>, <i>size<\/i> it is possible to append units designator: &#8216;K&#8217;, &#8216;M&#8217;, &#8216;G&#8217;, &#8216;T&#8217;, &#8216;P&#8217;, or &#8216;E&#8217;, which represent KiB, MiB, GiB, TiB, PiB, or EiB, respectively (case does not matter).<\/p>\n<p style=\"margin-left:17%; margin-top: 1em\"><b>Options<\/b><\/p>\n<p style=\"margin-left:17%; margin-top: 1em\"><big>\u2212c[<i><algo><\/i>]<\/big><\/p>\n<p style=\"margin-left:23%;\"><big>compress file contents while defragmenting. Optional argument selects the compression algorithm, <i>zlib<\/i> (default), <i>lzo<\/i> or <i>zstd<\/i>. Currently it\u2019s not possible to select no compression. See also section <i>EXAMPLES<\/i>.<\/big><\/p>\n<p style=\"margin-left:17%; margin-top: 1em\"><big>\u2212r<\/big><\/p>\n<p style=\"margin-left:23%;\"><big>defragment files recursively in given directories, does not descend to subvolumes or mount points<\/big><\/p>\n<p style=\"margin-left:17%; margin-top: 1em\"><big>\u2212f<\/big><\/p>\n<p style=\"margin-left:23%;\"><big>flush data for each file before going to the next file.<\/big><\/p>\n<p style=\"margin-left:23%; margin-top: 1em\"><big>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\u2019s too much dirty data to write and it\u2019s not possible to make the reservations for the new data (ie. how the COW design works).<\/big><\/p>\n<p style=\"margin-left:17%; margin-top: 1em\"><big>\u2212s <i><start><\/i>[kKmMgGtTpPeE]<\/big><\/p>\n<p style=\"margin-left:23%;\"><big>defragmentation will start from the given offset, default is beginning of a file<\/big><\/p>\n<p style=\"margin-left:17%; margin-top: 1em\"><big>\u2212l <i><len><\/i>[kKmMgGtTpPeE]<\/big><\/p>\n<p style=\"margin-left:23%;\"><big>defragment only up to <i>len<\/i> bytes, default is the file size<\/big><\/p>\n<p style=\"margin-left:17%; margin-top: 1em\"><big>\u2212t <i><size><\/i>[kKmMgGtTpPeE]<\/big><\/p>\n<p style=\"margin-left:23%;\"><big>target extent size, do not touch extents bigger than <i>size<\/i>, default: 32M<\/big><\/p>\n<p style=\"margin-left:23%; margin-top: 1em\"><big>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.<\/big><\/p>\n<p style=\"margin-left:17%; margin-top: 1em\"><big>\u2212v<\/big><\/p>\n<p style=\"margin-left:23%;\"><big>(deprecated) alias for global <i>\u2212v<\/i> option<\/big><\/p>\n<p style=\"margin-left:11%; margin-top: 1em\"><big><b>du<\/b> [options] <i><path><\/i> [<i><path><\/i>..]<\/big><\/p>\n<p style=\"margin-left:17%;\"><big>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 <i>set shared<\/i> value which is described below.<\/big><\/p>\n<p style=\"margin-left:17%; margin-top: 1em\"><big>Each argument to <i>btrfs filesystem du<\/i> will have a <i>set shared<\/i> value calculated for it. We define each <i>set<\/i> as those files found by a recursive search of an argument (recursion descends to subvolumes but not mount points). The <i>set shared<\/i> value then is a sum of all shared space referenced by the set.<\/big><\/p>\n<p style=\"margin-left:17%; margin-top: 1em\"><big><i>set shared<\/i> takes into account overlapping shared extents, hence it isn\u2019t as simple as adding up shared extents.<\/big><\/p>\n<p style=\"margin-left:17%; margin-top: 1em\"><big><b>Options<\/b><\/big><\/p>\n<p style=\"margin-left:17%; margin-top: 1em\"><big>\u2212s|\u2212\u2212summarize<\/big><\/p>\n<p style=\"margin-left:23%;\"><big>display only a total for each argument<\/big><\/p>\n<p style=\"margin-left:17%; margin-top: 1em\"><big>\u2212\u2212raw<\/big><\/p>\n<p style=\"margin-left:23%;\"><big>raw numbers in bytes, without the <i>B<\/i> suffix.<\/big><\/p>\n<p style=\"margin-left:17%; margin-top: 1em\"><big>\u2212\u2212human\u2212readable<\/big><\/p>\n<p style=\"margin-left:23%;\"><big>print human friendly numbers, base 1024, this is the default<\/big><\/p>\n<p style=\"margin-left:17%; margin-top: 1em\"><big>\u2212\u2212iec<\/big><\/p>\n<p style=\"margin-left:23%;\"><big>select the 1024 base for the following options, according to the IEC standard.<\/big><\/p>\n<p style=\"margin-left:17%; margin-top: 1em\"><big>\u2212\u2212si<\/big><\/p>\n<p style=\"margin-left:23%;\"><big>select the 1000 base for the following options, according to the SI standard.<\/big><\/p>\n<p style=\"margin-left:17%; margin-top: 1em\"><big>\u2212\u2212kbytes<\/big><\/p>\n<p style=\"margin-left:23%;\"><big>show sizes in KiB, or kB with \u2212\u2212si.<\/big><\/p>\n<p style=\"margin-left:17%; margin-top: 1em\"><big>\u2212\u2212mbytes<\/big><\/p>\n<p style=\"margin-left:23%;\"><big>show sizes in MiB, or MB with \u2212\u2212si.<\/big><\/p>\n<p style=\"margin-left:17%; margin-top: 1em\"><big>\u2212\u2212gbytes<\/big><\/p>\n<p style=\"margin-left:23%;\"><big>show sizes in GiB, or GB with \u2212\u2212si.<\/big><\/p>\n<p style=\"margin-left:17%; margin-top: 1em\"><big>\u2212\u2212tbytes<\/big><\/p>\n<p style=\"margin-left:23%;\"><big>show sizes in TiB, or TB with \u2212\u2212si.<\/big><\/p>\n<p style=\"margin-left:11%; margin-top: 1em\"><big><b>label<\/b> [<i><device><\/i>|<i><mountpoint><\/i>] [<i><newlabel><\/i>]<\/big><\/p>\n<p style=\"margin-left:17%;\"><big>Show or update the label of a filesystem. This works on a mounted filesystem or a filesystem image.<\/big><\/p>\n<p style=\"margin-left:17%; margin-top: 1em\"><big>The <i>newlabel<\/i> argument is optional. Current label is printed if the argument is omitted.<\/big><\/p>\n<p style=\"margin-left:23%; margin-top: 1em\"><big><b><big>Note<\/big><\/b> <br \/> the maximum allowable length shall be less than 256 chars and must not contain a newline. The trailing newline is stripped automatically.<\/big><\/p>\n<p style=\"margin-left:11%; margin-top: 1em\"><big><b><big>resize<\/big><\/b> <big>[options] [<i><devid><\/i>:][+\/\u2212]<i><size><\/i>[kKmMgGtTpPeE]|[<i><devid><\/i>:]max <i><path><\/i><\/big><\/big><\/p>\n<p style=\"margin-left:17%;\"><big><big>Resize a mounted filesystem identified by <i>path<\/i>. A particular device can be resized by specifying a <i>devid<\/i>.<\/big><\/big><\/p>\n<p style=\"margin-left:23%; margin-top: 1em\"><big><big><b><big>Warning<\/big><\/b> <br \/> If <i>path<\/i> 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.<\/big><\/big><\/p>\n<p style=\"margin-left:17%;\"><big><big>The <i>devid<\/i> can be found in the output of <b>btrfs filesystem show<\/b> and defaults to 1 if not specified. The <i>size<\/i> parameter specifies the new size of the filesystem. If the prefix <i>+<\/i> or <i>\u2212<\/i> is present the size is increased or decreased by the quantity <i>size<\/i>. If no units are specified, bytes are assumed for <i>size<\/i>. Optionally, the size parameter may be suffixed by one of the following unit designators: &#8216;K&#8217;, &#8216;M&#8217;, &#8216;G&#8217;, &#8216;T&#8217;, &#8216;P&#8217;, or &#8216;E&#8217;, which represent KiB, MiB, GiB, TiB, PiB, or EiB, respectively (case does not matter).<\/big><\/big><\/p>\n<p style=\"margin-left:17%; margin-top: 1em\"><big><big>If <i>max<\/i> is passed, the filesystem will occupy all available space on the device respecting <i>devid<\/i> (remember, devid 1 by default).<\/big><\/big><\/p>\n<p style=\"margin-left:17%; margin-top: 1em\"><big><big>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 <b>fdisk<\/b>(8) or <b>parted<\/b>(8) 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.<\/big><\/big><\/p>\n<p style=\"margin-left:17%; margin-top: 1em\"><big><big>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\u2019s beyond the new end. Relocation of the data takes time.<\/big><\/big><\/p>\n<p style=\"margin-left:17%; margin-top: 1em\"><big><big>See also section <i>EXAMPLES<\/i>.<\/big><\/big><\/p>\n<p style=\"margin-left:17%; margin-top: 1em\"><big><big><b>Options<\/b><\/big><\/big><\/p>\n<p style=\"margin-left:17%; margin-top: 1em\"><big><big><big>\u2212\u2212enqueue<\/big><\/big><\/big><\/p>\n<p style=\"margin-left:23%;\"><big><big><big>wait if there\u2019s another exclusive operation running, otherwise continue<\/big><\/big><\/big><\/p>\n<p style=\"margin-left:11%; margin-top: 1em\"><big><big><big><b>show<\/b> [options] [<i><path><\/i>|<i><uuid><\/i>|<i><device><\/i>|<i><label><\/i>]<\/big><\/big><\/big><\/p>\n<p style=\"margin-left:17%;\"><big><big><big>Show the btrfs filesystem with some additional info about devices and space allocation.<\/big><\/big><\/big><\/p>\n<p style=\"margin-left:17%; margin-top: 1em\"><big><big><big>If no option none of <i>path<\/i>\/<i>uuid<\/i>\/<i>device<\/i>\/<i>label<\/i> is passed, information about all the BTRFS filesystems is shown, both mounted and unmounted.<\/big><\/big><\/big><\/p>\n<p style=\"margin-left:17%; margin-top: 1em\"><big><big><big><b>Options<\/b><\/big><\/big><\/big><\/p>\n<p style=\"margin-left:17%; margin-top: 1em\"><big><big><big>\u2212m|\u2212\u2212mounted<\/big><\/big><\/big><\/p>\n<p style=\"margin-left:23%;\"><big><big><big>probe kernel for mounted BTRFS filesystems<\/big><\/big><\/big><\/p>\n<p style=\"margin-left:17%; margin-top: 1em\"><big><big><big>\u2212d|\u2212\u2212all\u2212devices<\/big><\/big><\/big><\/p>\n<p style=\"margin-left:23%;\"><big><big><big>scan all devices under \/dev, otherwise the devices list is extracted from the \/proc\/partitions file. This is a fallback option if there\u2019s no device node manager (like udev) available in the system.<\/big><\/big><\/big><\/p>\n<p style=\"margin-left:17%; margin-top: 1em\"><big><big><big>\u2212\u2212raw<\/big><\/big><\/big><\/p>\n<p style=\"margin-left:23%;\"><big><big><big>raw numbers in bytes, without the <i>B<\/i> suffix<\/big><\/big><\/big><\/p>\n<p style=\"margin-left:17%; margin-top: 1em\"><big><big><big>\u2212\u2212human\u2212readable<\/big><\/big><\/big><\/p>\n<p style=\"margin-left:23%;\"><big><big><big>print human friendly numbers, base 1024, this is the default<\/big><\/big><\/big><\/p>\n<p style=\"margin-left:17%; margin-top: 1em\"><big><big><big>\u2212\u2212iec<\/big><\/big><\/big><\/p>\n<p style=\"margin-left:23%;\"><big><big><big>select the 1024 base for the following options, according to the IEC standard<\/big><\/big><\/big><\/p>\n<p style=\"margin-left:17%; margin-top: 1em\"><big><big><big>\u2212\u2212si<\/big><\/big><\/big><\/p>\n<p style=\"margin-left:23%;\"><big><big><big>select the 1000 base for the following options, according to the SI standard<\/big><\/big><\/big><\/p>\n<p style=\"margin-left:17%; margin-top: 1em\"><big><big><big>\u2212\u2212kbytes<\/big><\/big><\/big><\/p>\n<p style=\"margin-left:23%;\"><big><big><big>show sizes in KiB, or kB with \u2212\u2212si<\/big><\/big><\/big><\/p>\n<p style=\"margin-left:17%; margin-top: 1em\"><big><big><big>\u2212\u2212mbytes<\/big><\/big><\/big><\/p>\n<p style=\"margin-left:23%;\"><big><big><big>show sizes in MiB, or MB with \u2212\u2212si<\/big><\/big><\/big><\/p>\n<p style=\"margin-left:17%; margin-top: 1em\"><big><big><big>\u2212\u2212gbytes<\/big><\/big><\/big><\/p>\n<p style=\"margin-left:23%;\"><big><big><big>show sizes in GiB, or GB with \u2212\u2212si<\/big><\/big><\/big><\/p>\n<p style=\"margin-left:17%; margin-top: 1em\"><big><big><big>\u2212\u2212tbytes<\/big><\/big><\/big><\/p>\n<p style=\"margin-left:23%;\"><big><big><big>show sizes in TiB, or TB with \u2212\u2212si<\/big><\/big><\/big><\/p>\n<p style=\"margin-left:11%; margin-top: 1em\"><big><big><big><b>sync<\/b> <i><path><\/i><\/big><\/big><\/big><\/p>\n<p style=\"margin-left:17%;\"><big><big><big>Force a sync of the filesystem at <i>path<\/i>, similar to the <b>sync<\/b>(1) command. In addition, it starts cleaning of deleted subvolumes. To wait for the subvolume deletion to complete use the <b>btrfs subvolume sync<\/b> command.<\/big><\/big><\/big><\/p>\n<p style=\"margin-left:11%; margin-top: 1em\"><big><big><big><b>usage<\/b> [options] <i><path><\/i> [<i><path><\/i>&#8230;]<\/big><\/big><\/big><\/p>\n<p style=\"margin-left:17%;\"><big><big><big>Show detailed information about internal filesystem usage. This is supposed to replace the <b>btrfs filesystem df<\/b> command in the long run.<\/big><\/big><\/big><\/p>\n<p style=\"margin-left:17%; margin-top: 1em\"><big><big><big>The level of detail can differ if the command is run under a regular or the root user (due to use of restricted ioctl). For both there\u2019s a summary section with information about space usage:<\/big><\/big><\/big><\/p>\n<p style=\"margin-left:23%; margin-top: 1em\"><big><big><big>$ btrfs filesystem usage \/path <br \/> WARNING: cannot read detailed chunk info, RAID5\/6 numbers will be incorrect, run as root <br \/> Overall: <br \/> Device size: 1.82TiB <br \/> Device allocated: 1.17TiB <br \/> Device unallocated: 669.99GiB <br \/> Device missing: 0.00B <br \/> Used: 1.14TiB <br \/> Free (estimated): 692.57GiB (min: 692.57GiB) <br \/> Free (statfs, df) 692.57GiB <br \/> Data ratio: 1.00 <br \/> Metadata ratio: 1.00 <br \/> Global reserve: 512.00MiB (used: 0.00B) <br \/> Multiple profiles: no<\/big><\/big><\/big><\/p>\n<p style=\"margin-left:23%; margin-top: 1em\"><big><big><big>\u2022 <i>Device size<\/i> \u2014 sum of raw device capacity available to the filesystem<\/big><\/big><\/big><\/p>\n<p style=\"margin-left:23%; margin-top: 1em\"><big><big><big>\u2022 <i>Device allocated<\/i> \u2014 sum of total space allocated for data\/metadata\/system profiles, this also accounts space reserved but not yet used for extents<\/big><\/big><\/big><\/p>\n<p style=\"margin-left:23%; margin-top: 1em\"><big><big><big>\u2022 <i>Device unallocated<\/i> \u2014 the remaining unallocated space for future allocations (difference of the above two numbers)<\/big><\/big><\/big><\/p>\n<p style=\"margin-left:23%; margin-top: 1em\"><big><big><big>\u2022 <i>Device missing<\/i> \u2014 sum of capacity of all missing devices<\/big><\/big><\/big><\/p>\n<p style=\"margin-left:23%; margin-top: 1em\"><big><big><big>\u2022 <i>Used<\/i> \u2014 sum of the used space of data\/metadata\/system profiles, not including the reserved space<\/big><\/big><\/big><\/p>\n<p style=\"margin-left:23%; margin-top: 1em\"><big><big><big>\u2022 <i>Free (estimated)<\/i> \u2014 approximate size of the remaining free space usable for data, including currently allocated space and estimating the usage of the unallocated space based on the block group profiles, the <i>min<\/i> is the lower bound of the estimate in case multiple profiles are present<\/big><\/big><\/big><\/p>\n<p style=\"margin-left:23%; margin-top: 1em\"><big><big><big>\u2022 <i>Free (statfs, df)<\/i> \u2014 the amount of space available for data as reported by the <b>statfs<\/b> syscall, also returned as <i>Avail<\/i> in the output of <i>df<\/i>. The value is calculated in a different way and may not match the estimate in some cases (eg. multiple profiles).<\/big><\/big><\/big><\/p>\n<p style=\"margin-left:23%; margin-top: 1em\"><big><big><big>\u2022 <i>Data ratio<\/i> \u2014 ratio of total space for data including redundancy or parity to the effectively usable data space, eg. single is 1.0, RAID1 is 2.0 and for RAID5\/6 it depends on the number of devices<\/big><\/big><\/big><\/p>\n<p style=\"margin-left:23%; margin-top: 1em\"><big><big><big>\u2022 <i>Metadata ratio<\/i> \u2014 dtto, for metadata<\/big><\/big><\/big><\/p>\n<p style=\"margin-left:23%; margin-top: 1em\"><big><big><big>\u2022 <i>Global reserve<\/i> \u2014 portion of metadata currently used for global block reserve, used for emergency purposes (like deletion on a full filesystem)<\/big><\/big><\/big><\/p>\n<p style=\"margin-left:23%; margin-top: 1em\"><big><big><big>\u2022 <i>Multiple profiles<\/i> \u2014 what block group types (data, metadata) have more than one profile (single, raid1, &#8230;), see <b>btrfs<\/b>(5) section <i>FILESYSTEMS WITH MULTIPLE BLOCK GROUP PROFILES<\/i>.<\/big><\/big><\/big><\/p>\n<p style=\"margin-left:17%; margin-top: 1em\"><big><big><big>And on a zoned filesystem there are two more lines in the <i>Device<\/i> section:<\/big><\/big><\/big><\/p>\n<p style=\"margin-left:23%; margin-top: 1em\"><big><big><big>Device zone unusable: 5.13GiB <br \/> Device zone size: 256.00MiB<\/big><\/big><\/big><\/p>\n<p style=\"margin-left:23%; margin-top: 1em\"><big><big><big>\u2022 <i>Device zone unusable<\/i> \u2014 sum of of space that\u2019s been used in the past but now is not due to COW and not referenced anymory, the chunks have to be reclaimed and zones reset to make it usable again<\/big><\/big><\/big><\/p>\n<p style=\"margin-left:23%; margin-top: 1em\"><big><big><big>\u2022 <i>Device zone size<\/i> \u2014 the reported zone size of the host\u2212managed device, same for all devices<\/big><\/big><\/big><\/p>\n<p style=\"margin-left:17%; margin-top: 1em\"><big><big><big>The root user will also see stats broken down by block group types:<\/big><\/big><\/big><\/p>\n<p style=\"margin-left:23%; margin-top: 1em\"><big><big><big>Data,single: Size:1.15TiB, Used:1.13TiB (98.26%) <br \/> \/dev\/sdb 1.15TiB<\/big><\/big><\/big><\/p>\n<p style=\"margin-left:23%; margin-top: 1em\"><big><big><big>Metadata,single: Size:12.00GiB, Used:6.45GiB (53.75%) <br \/> \/dev\/sdb 12.00GiB<\/big><\/big><\/big><\/p>\n<p style=\"margin-left:23%; margin-top: 1em\"><big><big><big>System,single: Size:32.00MiB, Used:144.00KiB (0.44%) <br \/> \/dev\/sdb 32.00MiB<\/big><\/big><\/big><\/p>\n<p style=\"margin-left:23%; margin-top: 1em\"><big><big><big>Unallocated: <br \/> \/dev\/sdb 669.99GiB<\/big><\/big><\/big><\/p>\n<p style=\"margin-left:17%; margin-top: 1em\"><big><big><big><i>Data<\/i> is block group type, <i>single<\/i> is block group profile, <i>Size<\/i> is total size occupied by this type, <i>Used<\/i> is the actually used space, the percent is ratio of <i>Used\/Size<\/i>. The <i>Unallocated<\/i> is remaining space.<\/big><\/big><\/big><\/p>\n<p style=\"margin-left:17%; margin-top: 1em\"><big><big><big><b>Options<\/b><\/big><\/big><\/big><\/p>\n<p style=\"margin-left:17%; margin-top: 1em\"><big><big><big>\u2212b|\u2212\u2212raw<\/big><\/big><\/big><\/p>\n<p style=\"margin-left:23%;\"><big><big><big>raw numbers in bytes, without the <i>B<\/i> suffix<\/big><\/big><\/big><\/p>\n<p style=\"margin-left:17%; margin-top: 1em\"><big><big><big>\u2212h|\u2212\u2212human\u2212readable<\/big><\/big><\/big><\/p>\n<p style=\"margin-left:23%;\"><big><big><big>print human friendly numbers, base 1024, this is the default<\/big><\/big><\/big><\/p>\n<p style=\"margin-left:17%; margin-top: 1em\"><big><big><big>\u2212H<\/big><\/big><\/big><\/p>\n<p style=\"margin-left:23%;\"><big><big><big>print human friendly numbers, base 1000<\/big><\/big><\/big><\/p>\n<p style=\"margin-left:17%; margin-top: 1em\"><big><big><big>\u2212\u2212iec<\/big><\/big><\/big><\/p>\n<p style=\"margin-left:23%;\"><big><big><big>select the 1024 base for the following options, according to the IEC standard<\/big><\/big><\/big><\/p>\n<p style=\"margin-left:17%; margin-top: 1em\"><big><big><big>\u2212\u2212si<\/big><\/big><\/big><\/p>\n<p style=\"margin-left:23%;\"><big><big><big>select the 1000 base for the following options, according to the SI standard<\/big><\/big><\/big><\/p>\n<p style=\"margin-left:17%; margin-top: 1em\"><big><big><big>\u2212k|\u2212\u2212kbytes<\/big><\/big><\/big><\/p>\n<p style=\"margin-left:23%;\"><big><big><big>show sizes in KiB, or kB with \u2212\u2212si<\/big><\/big><\/big><\/p>\n<p style=\"margin-left:17%; margin-top: 1em\"><big><big><big>\u2212m|\u2212\u2212mbytes<\/big><\/big><\/big><\/p>\n<p style=\"margin-left:23%;\"><big><big><big>show sizes in MiB, or MB with \u2212\u2212si<\/big><\/big><\/big><\/p>\n<p style=\"margin-left:17%; margin-top: 1em\"><big><big><big>\u2212g|\u2212\u2212gbytes<\/big><\/big><\/big><\/p>\n<p style=\"margin-left:23%;\"><big><big><big>show sizes in GiB, or GB with \u2212\u2212si<\/big><\/big><\/big><\/p>\n<p style=\"margin-left:17%; margin-top: 1em\"><big><big><big>\u2212t|\u2212\u2212tbytes<\/big><\/big><\/big><\/p>\n<p style=\"margin-left:23%;\"><big><big><big>show sizes in TiB, or TB with \u2212\u2212si<\/big><\/big><\/big><\/p>\n<p style=\"margin-left:17%; margin-top: 1em\"><big><big><big>\u2212T<\/big><\/big><\/big><\/p>\n<p style=\"margin-left:23%;\"><big><big><big>show data in tabular format<\/big><\/big><\/big><\/p>\n<p style=\"margin-left:23%; margin-top: 1em\"><big><big><big>If conflicting options are passed, the last one takes precedence.<\/big><\/big><\/big><\/p>\n<h2>EXAMPLES <a name=\"EXAMPLES\"><\/a> <\/h2>\n<p style=\"margin-left:11%; margin-top: 1em\"><big><big><big><b>$ btrfs filesystem defrag \u2212v \u2212r dir\/<\/b><\/big><\/big><\/big><\/p>\n<p style=\"margin-left:11%; margin-top: 1em\"><big><big><big>Recursively defragment files under <i>dir\/<\/i>, print files as they are processed. The file names will be printed in batches, similarly the amount of data triggered by defragmentation will be proportional to last N printed files. The system dirty memory throttling will slow down the defragmentation but there can still be a lot of IO load and the system may stall for a moment.<\/big><\/big><\/big><\/p>\n<p style=\"margin-left:11%; margin-top: 1em\"><big><big><big><b>$ btrfs filesystem defrag \u2212v \u2212r \u2212f dir\/<\/b><\/big><\/big><\/big><\/p>\n<p style=\"margin-left:11%; margin-top: 1em\"><big><big><big>Recursively defragment files under <i>dir\/<\/i>, be verbose and wait until all blocks are flushed before processing next file. You can note slower progress of the output and lower IO load (proportional to currently defragmented file).<\/big><\/big><\/big><\/p>\n<p style=\"margin-left:11%; margin-top: 1em\"><big><big><big><b>$ btrfs filesystem defrag \u2212v \u2212r \u2212f \u2212clzo dir\/<\/b><\/big><\/big><\/big><\/p>\n<p style=\"margin-left:11%; margin-top: 1em\"><big><big><big>Recursively defragment files under <i>dir\/<\/i>, be verbose, wait until all blocks are flushed and force file compression.<\/big><\/big><\/big><\/p>\n<p style=\"margin-left:11%; margin-top: 1em\"><big><big><big><b>$ btrfs filesystem defrag \u2212v \u2212r \u2212t 64M dir\/<\/b><\/big><\/big><\/big><\/p>\n<p style=\"margin-left:11%; margin-top: 1em\"><big><big><big>Recursively defragment files under <i>dir\/<\/i>, be verbose and try to merge extents to be about 64MiB. As stated above, the success rate depends on actual free space fragmentation and the final result is not guaranteed to meet the target even if run repeatedly.<\/big><\/big><\/big><\/p>\n<p style=\"margin-left:11%; margin-top: 1em\"><big><big><big><b>$ btrfs filesystem resize \u22121G \/path<\/b><\/big><\/big><\/big><\/p>\n<p style=\"margin-left:11%; margin-top: 1em\"><big><big><big><b>$ btrfs filesystem resize 1:\u22121G \/path<\/b><\/big><\/big><\/big><\/p>\n<p style=\"margin-left:11%; margin-top: 1em\"><big><big><big>Shrink size of the filesystem\u2019s device id 1 by 1GiB. The first syntax expects a device with id 1 to exist, otherwise fails. The second is equivalent and more explicit. For a single\u2212device filesystem it\u2019s typically not necessary to specify the devid though.<\/big><\/big><\/big><\/p>\n<p style=\"margin-left:11%; margin-top: 1em\"><big><big><big><b>$ btrfs filesystem resize max \/path<\/b><\/big><\/big><\/big><\/p>\n<p style=\"margin-left:11%; margin-top: 1em\"><big><big><big><b>$ btrfs filesystem resize 1:max \/path<\/b><\/big><\/big><\/big><\/p>\n<p style=\"margin-left:11%; margin-top: 1em\"><big><big><big>Let\u2019s assume that devid 1 exists and the filesystem does not occupy the whole block device, eg. it has been enlarged and we want to grow the filesystem. By simply using <i>max<\/i> as size we will achieve that.<\/big><\/big><\/big><\/p>\n<p style=\"margin-left:17%; margin-top: 1em\"><big><big><big><b><big>Note<\/big><\/b> <br \/> There are two ways to minimize the filesystem on a given device. The <b>btrfs inspect\u2212internal min\u2212dev\u2212size<\/b> command, or iteratively shrink in steps.<\/big><\/big><\/big><\/p>\n<h2>EXIT STATUS <a name=\"EXIT STATUS\"><\/a> <\/h2>\n<p style=\"margin-left:11%; margin-top: 1em\"><big><big><big><b><big>btrfs filesystem<\/big><\/b> <big>returns a zero exit status if it succeeds. Non zero is returned in case of failure.<\/big><\/big><\/big><\/big><\/p>\n<h2>AVAILABILITY <a name=\"AVAILABILITY\"><\/a> <\/h2>\n<p style=\"margin-left:11%; margin-top: 1em\"><big><big><big><big><b>btrfs<\/b> is part of btrfs\u2212progs. Please refer to the btrfs wiki <b><font color=\"#0000FF\">http:\/\/btrfs.wiki.kernel.org<\/font><\/b> <font color=\"#000000\">for further details.<\/font><\/big><\/big><\/big><\/big><\/p>\n<h2>SEE ALSO <a name=\"SEE ALSO\"><\/a> <\/h2>\n<p style=\"margin-left:11%; margin-top: 1em\"><big><big><big><big><font color=\"#000000\"><b>btrfs\u2212subvolume<\/b>(8), <b>mkfs.btrfs<\/b>(8),<\/font><\/big><\/big><\/big><\/big><\/p>\n<hr>\n","protected":false},"excerpt":{"rendered":"<p>  btrfs-filesystem \u2212 command group that primarily does work on the whole filesystems <\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[2],"tags":[5,52,239,4],"class_list":["post-3090","post","type-post","status-publish","format-standard","hentry","category-8-administracion-del-sistema","tag-5","tag-administracion","tag-btrfs-filesystem","tag-man8"],"gutentor_comment":0,"_links":{"self":[{"href":"https:\/\/lode.uno\/linux-man\/wp-json\/wp\/v2\/posts\/3090","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/lode.uno\/linux-man\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/lode.uno\/linux-man\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/lode.uno\/linux-man\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/lode.uno\/linux-man\/wp-json\/wp\/v2\/comments?post=3090"}],"version-history":[{"count":0,"href":"https:\/\/lode.uno\/linux-man\/wp-json\/wp\/v2\/posts\/3090\/revisions"}],"wp:attachment":[{"href":"https:\/\/lode.uno\/linux-man\/wp-json\/wp\/v2\/media?parent=3090"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/lode.uno\/linux-man\/wp-json\/wp\/v2\/categories?post=3090"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/lode.uno\/linux-man\/wp-json\/wp\/v2\/tags?post=3090"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}