How to Replace a Failed Btrfs Device

The Problem

Originally the btrfs file system is build on multiple disks.

# btrfs filesystem show
Label: 'MYBTRFS' uuid: 09138ad8-eb2f-4c7c-aef7-90482a67c45c
Total devices 3 FS bytes used 768.00KiB
devid 1 size 5.00GiB used 1.52GiB path /dev/xvdb
devid 2 size 5.00GiB used 520.00MiB path /dev/xvdc
devid 3 size 5.00GiB used 1.51GiB path /dev/xvdd

For some reason one disk is faulty and needs to be replaced.

# btrfs filesystem show
Label: 'MYBTRFS' uuid: 09138ad8-eb2f-4c7c-aef7-90482a67c45c
Total devices 3 FS bytes used 768.00KiB
devid 1 size 5.00GiB used 1.52GiB path /dev/xvdb
devid 3 size 5.00GiB used 1.51GiB path /dev/xvdd
*** Some devices missing

The Solution

1. Mount the btrfs with “-o degraded” option from existing good volume:

# mount -o degraded /dev/xvdd /mnt/btrfs

2. Replace the absent disk with the missing one:

# btrfs replace start 2 /dev/xvdc /mnt/btrfs

3. Balance the file system:

# btrfs filesystem balance

If any error, please check the output of “dmesg”. You may also need to contact your support team if there are errors in dmesg.

Related Post