1BTRFS-FILESYSTEM(8)              Btrfs Manual              BTRFS-FILESYSTEM(8)
2
3
4

NAME

6       btrfs-filesystem - command group of btrfs that usually work on the
7       whole filesystem
8

SYNOPSIS

10       btrfs filesystem <subcommand> <args>
11

DESCRIPTION

13       btrfs filesystem is used to perform several whole filesystem level
14       tasks, including all the regular filesystem operations like resizing,
15       space stats, label setting/getting, and defragmentation. There are
16       other whole filesystem taks like scrub or balance that are grouped in
17       separate commands.
18

SUBCOMMAND

20       df [options] <path>
21           Show a terse summary information about allocation of block group
22           types of a given mount point. The original purpose of this command
23           was a debugging helper. The output needs to be further interpreted
24           and is not suitable for quick overview.
25
26           An example with description:
27
28           ·   device size: 1.9TiB, one device, no RAID
29
30           ·   filesystem size: 1.9TiB
31
32           ·   created with: mkfs.btrfs -d single -m single
33
34               $ btrfs filesystem df /path
35               Data, single: total=1.15TiB, used=1.13TiB
36               System, single: total=32.00MiB, used=144.00KiB
37               Metadata, single: total=12.00GiB, used=6.45GiB
38               GlobalReserve, single: total=512.00MiB, used=0.00B
39
40           ·   Data, System and Metadata are separate block group types.
41               GlobalReserve is an artificial and internal emergency space,
42               see below.
43
44           ·   single — the allocation profile, defined at mkfs time
45
46           ·   total — sum of space reserved for all allocation profiles of
47               the given type, ie. all Data/single. Note that it’s not total
48               size of filesystem.
49
50           ·   used — sum of used space of the above, ie. file extents,
51               metadata blocks
52
53           GlobalReserve is an artificial and internal emergency space. It is
54           used eg. when the filesystem is full. Its total size is dynamic
55           based on the filesystem size, usually not larger than 512MiB, used
56           may fluctuate.
57
58           The global block reserve is accounted within Metadata. In case the
59           filesystem metadata are exhausted, GlobalReserve/total +
60           Metadata/used = Metadata/total.
61
62           Options
63
64           -b|--raw
65               raw numbers in bytes, without the B suffix
66
67           -h|--human-readable
68               print human friendly numbers, base 1024, this is the default
69
70           -H
71               print human friendly numbers, base 1000
72
73           --iec
74               select the 1024 base for the following options, according to
75               the IEC standard
76
77           --si
78               select the 1000 base for the following options, according to
79               the SI standard
80
81           -k|--kbytes
82               show sizes in KiB, or kB with --si
83
84           -m|--mbytes
85               show sizes in MiB, or MB with --si
86
87           -g|--gbytes
88               show sizes in GiB, or GB with --si
89
90           -t|--tbytes
91               show sizes in TiB, or TB with --si
92
93               If conflicting options are passed, the last one takes
94               precedence.
95
96       defragment [options] <file>|<dir> [<file>|<dir>...]
97           Defragment file data on a mounted filesystem. Requires kernel
98           2.6.33 and newer.
99
100           If -r is passed, files in dir will be defragmented recursively. The
101           start position and the number of bytes to defragment can be
102           specified by start and length using -s and -l options below.
103           Extents bigger than value given by -t will be skipped, otherwise
104           this value is used as a target extent size, but is only advisory
105           and may not be reached if the free space is too fragmented. Use 0
106           to take the kernel default, which is 256kB but may change in the
107           future. You can also turn on compression in defragment operations.
108
109               Warning
110               Defragmenting with Linux kernel versions < 3.9 or ≥ 3.14-rc2 as
111               well as with Linux stable kernel versions ≥ 3.10.31, ≥ 3.12.12
112               or ≥ 3.13.4 will break up the ref-links of COW data (for
113               example files copied with cp --reflink, snapshots or
114               de-duplicated data). This may cause considerable increase of
115               space usage depending on the broken up ref-links.
116
117               Note
118               Directory arguments without -r do not defragment files
119               recursively but will defragment certain internal trees (extent
120               tree and the subvolume tree). This has been confusing and could
121               be removed in the future.
122           For start, len, size it is possible to append units designator:
123           'K', 'M', 'G', 'T', 'P', or 'E', which represent KiB, MiB, GiB,
124           TiB, PiB, or EiB, respectively (case does not matter).
125
126           Options
127
128           -v
129               be verbose, print file names as they’re submitted for
130               defragmentation
131
132           -c[<algo>]
133               compress file contents while defragmenting. Optional argument
134               selects the compression algorithm, zlib (default) or lzo.
135               Currently it’s not possible to select no compression. See also
136               section EXAMPLES.
137
138           -r
139               defragment files recursively in given directories
140
141           -f
142               flush data for each file before going to the next file.
143
144               This will limit the amount of dirty data to current file,
145               otherwise the amount cumulates from several files and will
146               increase system load. This can also lead to ENOSPC if there’s
147               too much dirty data to write and it’s not possible to make the
148               reservations for the new data (ie. how the COW design works).
149
150           -s <start>[kKmMgGtTpPeE]
151               defragmentation will start from the given offset, default is
152               beginning of a file
153
154           -l <len>[kKmMgGtTpPeE]
155               defragment only up to len bytes, default is the file size
156
157           -t <size>[kKmMgGtTpPeE]
158               target extent size, do not touch extents bigger than size,
159               default: 32M
160
161               The value is only advisory and the final size of the extents
162               may differ, depending on the state of the free space and
163               fragmentation or other internal logic. Reasonable values are
164               from tens to hundreds of megabytes.
165
166       du [options] <path> [<path>..]
167           Calculate disk usage of the target files using FIEMAP. For
168           individual files, it will report a count of total bytes, and
169           exclusive (not shared) bytes. We also calculate a set shared value
170           which is described below.
171
172           Each argument to btrfs fi du will have a set shared value
173           calculated for it. We define each set as those files found by a
174           recursive search of an argument. The set shared value then is a sum
175           of all shared space referenced by the set.
176
177           set shared takes into account overlapping shared extents, hence it
178           isn’t as simple as adding up shared extents.
179
180           Options
181
182           -s|--summarize
183               display only a total for each argument
184
185           --raw
186               raw numbers in bytes, without the B suffix.
187
188           --human-readable
189               print human friendly numbers, base 1024, this is the default
190
191           --iec
192               select the 1024 base for the following options, according to
193               the IEC standard.
194
195           --si
196               select the 1000 base for the following options, according to
197               the SI standard.
198
199           --kbytes
200               show sizes in KiB, or kB with --si.
201
202           --mbytes
203               show sizes in MiB, or MB with --si.
204
205           --gbytes
206               show sizes in GiB, or GB with --si.
207
208           --tbytes
209               show sizes in TiB, or TB with --si.
210
211       label [<dev>|<mountpoint>] [<newlabel>]
212           Show or update the label of a filesystem. This works on a mounted
213           filesystem or a filesystem image.
214
215           The newlabel argument is optional. Current label is printed if the
216           the argument is omitted.
217
218               Note
219               the maximum allowable length shall be less than 256 chars and
220               must not contain a newline. The trailing newline is stripped
221               automatically.
222
223       resize [<devid>:][+/-]<size>[kKmMgGtTpPeE]|[<devid>:]max <path>
224           Resize a mounted filesystem identified by path. A particular device
225           can be resized by specifying a devid.
226
227               Warning
228               If path is a file containing a BTRFS image then resize does not
229               work as expected and does not resize the image. This would
230               resize the underlying filesystem instead.
231           The devid can be found in the output of btrfs filesystem show and
232           defaults to 1 if not specified. The size parameter specifies the
233           new size of the filesystem. If the prefix + or - is present the
234           size is increased or decreased by the quantity size. If no units
235           are specified, bytes are assumed for size. Optionally, the size
236           parameter may be suffixed by one of the following units
237           designators: 'K', 'M', 'G', 'T', 'P', or 'E', which represent KiB,
238           MiB, GiB, TiB, PiB, or EiB, respectively (case does not matter).
239
240           If max is passed, the filesystem will occupy all available space on
241           the device respecting devid (remember, devid 1 by default).
242
243           The resize command does not manipulate the size of underlying
244           partition. If you wish to enlarge/reduce a filesystem, you must
245           make sure you can expand the partition before enlarging the
246           filesystem and shrink the partition after reducing the size of the
247           filesystem. This can done using fdisk(8) or parted(8) to delete the
248           existing partition and recreate it with the new desired size. When
249           recreating the partition make sure to use the same starting
250           partition offset as before.
251
252           Growing is usually instant as it only updates the size. However,
253           shrinking could take a long time if there are data in the device
254           area that’s beyond the new end. Relocation of the data takes time.
255
256           See also section EXAMPLES.
257
258       show [options] [<path>|<uuid>|<device>|<label>]
259           Show the btrfs filesystem with some additional info about devices
260           and space allocation.
261
262           If no option none of path/uuid/device/label is passed, information
263           about all the BTRFS filesystems is shown, both mounted and
264           unmounted.
265
266           Options
267
268           -m|--mounted
269               probe kernel for mounted BTRFS filesystems
270
271           -d|--all-devices
272               scan all devices under /dev, otherwise the devices list is
273               extracted from the /proc/partitions file. This is a fallback
274               option if there’s no device node manager (like udev) available
275               in the system.
276
277           --raw
278               raw numbers in bytes, without the B suffix
279
280           --human-readable
281               print human friendly numbers, base 1024, this is the default
282
283           --iec
284               select the 1024 base for the following options, according to
285               the IEC standard
286
287           --si
288               select the 1000 base for the following options, according to
289               the SI standard
290
291           --kbytes
292               show sizes in KiB, or kB with --si
293
294           --mbytes
295               show sizes in MiB, or MB with --si
296
297           --gbytes
298               show sizes in GiB, or GB with --si
299
300           --tbytes
301               show sizes in TiB, or TB with --si
302
303       sync <path>
304           Force a sync of the filesystem at path. This is done via a special
305           ioctl and will also trigger cleaning of deleted subvolumes. Besides
306           that it’s equivalent to the sync(1) command.
307
308       usage [options] <path> [<path>...]
309           Show detailed information about internal filesystem usage. This is
310           supposed to replace the btrfs filesystem df command in the long
311           run.
312
313           The level of detail can differ if the command is run under a
314           regular or the root user (due to use of restricted ioctl). For both
315           there’s a summary section with information about space usage:
316
317               $ btrfs fi usage /path
318               WARNING: cannot read detailed chunk info, RAID5/6 numbers will be incorrect, run as root
319               Overall:
320                   Device size:                   1.82TiB
321                   Device allocated:              1.17TiB
322                   Device unallocated:          669.99GiB
323                   Device missing:                  0.00B
324                   Used:                          1.14TiB
325                   Free (estimated):            692.57GiB      (min: 692.57GiB)
326                   Data ratio:                       1.00
327                   Metadata ratio:                   1.00
328                   Global reserve:              512.00MiB      (used: 0.00B)
329
330           The root user will also see stats broken down by block group types:
331
332               Data,single: Size:1.15TiB, Used:1.13TiB
333                  /dev/sdb        1.15TiB
334
335               Metadata,single: Size:12.00GiB, Used:6.45GiB
336                  /dev/sdb       12.00GiB
337
338               System,single: Size:32.00MiB, Used:144.00KiB
339                  /dev/sdb       32.00MiB
340
341               Unallocated:
342                  /dev/sdb      669.99GiB
343
344           Options
345
346           -b|--raw
347               raw numbers in bytes, without the B suffix
348
349           -h|--human-readable
350               print human friendly numbers, base 1024, this is the default
351
352           -H
353               print human friendly numbers, base 1000
354
355           --iec
356               select the 1024 base for the following options, according to
357               the IEC standard
358
359           --si
360               select the 1000 base for the following options, according to
361               the SI standard
362
363           -k|--kbytes
364               show sizes in KiB, or kB with --si
365
366           -m|--mbytes
367               show sizes in MiB, or MB with --si
368
369           -g|--gbytes
370               show sizes in GiB, or GB with --si
371
372           -t|--tbytes
373               show sizes in TiB, or TB with --si
374
375           -T
376               show data in tabular format
377
378               If conflicting options are passed, the last one takes
379               precedence.
380

EXAMPLES

382       $ btrfs filesystem defrag -v -r dir/
383
384       Recursively defragment files under dir/, print files as they are
385       processed. The file names will be printed in batches, similarly the
386       amount of data triggered by defragmentation will be proportional to
387       last N printed files. The system dirty memory throttling will slow down
388       the defragmentation but there can still be a lot of IO load and the
389       system may stall for a moment.
390
391       $ btrfs filesystem defrag -v -r -f dir/
392
393       Recursively defragment files under dir/, be verbose and wait until all
394       blocks are flushed before processing next file. You can note slower
395       progress of the output and lower IO load (proportional to currently
396       defragmented file).
397
398       $ btrfs filesystem defrag -v -r -f -clzo dir/
399
400       Recursively defragment files under dir/, be verbose, wait until all
401       blocks are flushed and force file compression.
402
403       $ btrfs filesystem defrag -v -r -t 64M dir/
404
405       Recursively defragment files under dir/, be verbose and try to merge
406       extents to be about 64MiB. As stated above, the success rate depends on
407       actual free space fragmentation and the final result is not guaranteed
408       to meet the target even if run repeatedly.
409
410       $ btrfs filesystem resize -1G /path
411
412       $ btrfs filesystem resize 1:-1G /path
413
414       Shrink size of the filesystem’s device id 1 by 1GiB. The first syntax
415       expects a device with id 1 to exist, otherwise fails. The second is
416       equivalent and more explicit. For a single-device filesystem it’s
417       typically not necessary to specify the devid though.
418
419       $ btrfs filesystem resize max /path
420
421       $ btrfs filesystem resize 1:max /path
422
423       Let’s assume that devid 1 exists, the filesystem does not occupy the
424       whole block device, eg. it has been enlarged and we wan the grow the
425       filesystem. Simply using max as size we will achieve that.
426
427           Note
428           There are two ways to minimize the filesystem on a given device.
429           The btrfs inspect-internal min-dev-size command, or iteratively
430           shrink in steps.
431

EXIT STATUS

433       btrfs filesystem returns a zero exit status if it succeeds. Non zero is
434       returned in case of failure.
435

AVAILABILITY

437       btrfs is part of btrfs-progs. Please refer to the btrfs wiki
438       http://btrfs.wiki.kernel.org for further details.
439

SEE ALSO

441       mkfs.btrfs(8),
442
443
444
445Btrfs v4.9.1                      08/06/2017               BTRFS-FILESYSTEM(8)
Impressum