[HowTo] Convert BTRFS profile of Metadata "Single" to "DUP" (Duplicate of metadata is more safe than single)

The old BTRFS file system is older than version 5.15 and uses its profile of metadata “SINGLE” by default for a single partition or hard drive (that means your data and one metadata in the same partition)

From BTRFS version 5.15+, metadata’s profile always becomes “DUP” by default
(That means your data and two same metadata in the same partition)
See the changelog: Changes (btrfs-progs) — BTRFS documentation

See the profile in Wiki: SINGLE vs DUP

DUP means duplicate. This ensures two copies exists on the same disk. Can be used on one or several drives like SINGLE mode but does not protect against disk failures.
DUP mode protects against data or metadata corruption, but not disk failures.

I heard that someone had some problem with BTRFS, unable to mount partition and unable to recover data in the past (Data had to be lost) when one metadata alone was corrupted and using a single disk (without RAID).


How to check if metadata’s profile is “SINGLE”

Run sudo btrfs fi usage /

The output:

...
Data,single: Size:940.00GiB, Used:875.88GiB (93.18%)
   /dev/nvme0n1p2        940.00GiB
Metadata,single: Size:5.00GiB, Used:3.77GiB (75.33%)
   /dev/nvme0n1p2          5.00GiB
System,single: Size:32.00MiB, Used:144.00KiB (0.44%)
   /dev/nvme0n1p2         32.00MiB
...

That shows SINGLE metadata and SINGLE system


How to convert the metadata’s profile “SINGLE” to “DUP”

  1. Switch to Linux Kernel 5.15+

  2. Please stop all btrfs services, e.g. btrfsmaintenance etc…

  3. Run the command: See :btrfs-balance(8) — BTRFS documentation

btrfs balance start -mconvert=DUP /
  1. Then check the output of sudo btrfs fi usage /
...
Data,single: Size:876.00GiB, Used:875.82GiB (99.98%)
   /dev/nvme0n1p2        876.00GiB

Metadata,DUP: Size:5.00GiB, Used:3.82GiB (76.35%)
   /dev/nvme0n1p2         10.00GiB

System,DUP: Size:32.00MiB, Used:128.00KiB (0.39%)
   /dev/nvme0n1p2         64.00MiB
...

That shows DUP metadata and DUP system in the same device.


You get two same metadata on a single disk/partition. If one of 2 is broken or corrupted but last one survives so you might be able to mount the partition and recover your data back. (Idea: Broken metadata is easily repaired or overwritten, which is the same as healthy metadata.)

4 Likes