File: Reflink.rst

package info (click to toggle)
btrfs-progs 6.17.1-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 20,612 kB
  • sloc: ansic: 127,282; sh: 7,915; python: 1,384; makefile: 900; asm: 296
file content (33 lines) | stat: -rw-r--r-- 1,502 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
Reflink
=======

Reflink is a type of shallow copy of file data that shares the blocks but
otherwise the files are independent and any change to the file will not affect
the other. This builds on the underlying COW mechanism. A reflink will
effectively create only a separate metadata pointing to the shared blocks which
is typically much faster than a deep copy of all blocks.

The reflink is typically meant for whole files but a partial file range can be
also copied, though there are no ready-made tools for that.

.. code-block:: shell

   cp --reflink=always source target

There are some constraints:

- cross-filesystem reflink is not possible, there's nothing in common between
  so the block sharing can't work
- reflink crossing two mount points of the same filesystem support depends on
  kernel version:

  - until 5.17 it's not supported and fails with "Cross device link", can be
    worked around by performing the operation on the toplevel subvolume
  - works since 5.18
- reflink requires source and target file that have the same status regarding
  NOCOW and checksums, for example if the source file is NOCOW (once created
  with the :command:`chattr +C` attribute) then the above command won't work unless the
  target file is pre-created with the +C attribute as well, or the NOCOW
  attribute is inherited from the parent directory (:command:`chattr +C` on the directory)
  or if the whole filesystem is mounted with *-o nodatacow* that would create
  the NOCOW files by default