1

How do I make the operation of btrfs check --repair reversible without a full dd backup?

Is it sufficient to use:

btrfs-image -w <device> <image-file>

possibly using -t <#-threads> and -c9 (highest compression) as well?

Will a restore of this image reverse the effect of all check --repair operations, including

  • --init-csum-tree
  • --init-extent-tree?

What is the use of the

Tom Hale
  • 28,728
  • 32
  • 139
  • 229

2 Answers2

1

I am not familiar with the details of btrfs but I see the risk that the metadata dump of a damaged filesystem might be incomplete.

I suggest that you use dmsetup to set up a snapshot device and run btrfs check --repair on the snapshot which you can just throw away so that you get the original state.

This snapshot will consume only little space after the repair run.

Hauke Laging
  • 88,146
  • 18
  • 125
  • 174
1

dmsetup snapshots (official documentation) can be used to store changes, and if they are acceptable, they can be merged into the original device.

This reddit post has detailed examples.

Note all dmsetup(8) table sectors are 512 bytes:

Devices are created by loading a table that specifies a target for each sector (512 bytes) in the logical device.

Credit to Hauke Laging's suggestion to use dmsetup.

Tom Hale
  • 28,728
  • 32
  • 139
  • 229