btrfs failed device

Scan for btrfs devices

btrfs device scan

Show btrfs devices

btrfs filesystem show

# btrfs fi sh
Label: 'btrfs-pool'  uuid: 12345678-1234-1234-1234-123456789012
    Total devices 4 FS bytes used 8.01TiB
    devid    1 size 5.46TiB used 5.46TiB path /dev/mapper/luks1
    devid    2 size 2.73TiB used 2.73TiB path /dev/mapper/luks2
    devid    3 size 2.73TiB used 2.73TiB path /dev/mapper/luks3
    devid    5 size 5.46TiB used 5.46TiB path /dev/sdd

Mount btrfs volume in degraded state

mount -o degraded /dev/sdx /mnt/btrfs-pool

or if you’re using luks:

mount -o degraded /dev/mapper/luksx /mnt/btrfs-pool

Replace failed device

See luks and btrfs for creating new luks encrypted devices.

Change x to match the device, and y to match the device ID.

btrfs replace start y /dev/mapper/luksx /mnt/btrfs-pool

# btrfs filesystem show
Label: 'btrfs-pool'  uuid: 12345678-1234-1234-1234-123456789abc
    Total devices 5 FS bytes used 8.01TiB
    devid    0 size 2.73TiB used 2.73TiB path /dev/mapper/luks2
    devid    1 size 5.46TiB used 5.46TiB path /dev/mapper/luks1
    devid    3 size 2.73TiB used 2.73TiB path /dev/mapper/luks3
    devid    5 size 5.46TiB used 5.46TiB path /dev/sdd
    *** Some devices missing

Check status of replace

btrfs replace status -1 /mnt/btrfs-pool

# btrfs replace status -1 /mnt/btrfs-pool
0.5% done, 0 write errs, 0 uncorr. read errs

Larger disk

Don’t forget to resize if you are replacing with a larger disk, where x is the devid:

btrfs filesystem resize x:max /mnt/btrfs-pool