Changing Btrfs File System Devices

You can use the btrfs device command to add, remove, or replace devices, and the btrfs rebalance command to rebalance the layout of the file system data and metadata across devices. The following table describes each of the commands that can use to perform these tasks.

Command Description

btrfs device add device mountpoint

Add a device to the file system that's mounted on the specified mount point, for example:

sudo btrfs device add /dev/sdd /mnt

btrfs device delete device mountpoint

Remove a device from a mounted file system, for example:

sudo btrfs device delete /dev/sde /mnt

btrfs device delete missing mountpoint

Remove a failed device from the file system that's mounted in degraded mode, for example:

sudo btrfs device remove missing /mnt

To mount a file system in degraded mode, specify the -o degraded option to the mount command.

For a RAID configuration, if the number of devices would become less than the minimum number that are required, you must add the replacement device before removing the failed device.

btrfs device replace start source_dev target_dev mountpoint

Replace devices on a live file system without unmounting the file system or stopping any tasks that are using the file system, for example:

sudo btrfs device replace start /dev/sdb /dev/sdk /mnt

If the system crashes or loses power while the replacement is taking place, the operation resumes when the system next mounts the file system.

The target device must be the same size or larger than the source device. If the source device is no longer available, or you specify the -r option, the data is reconstructed by using redundant data that's obtained from other devices, such as another available mirror.

The source device is removed from the file system when the operation is complete.

Use the btrfs replace status mountpoint command to check the progress of the replacement operation and the btrfs replace cancel mountpoint command to cancel the operation.

btrfs filesystem balance mountpoint

After adding or removing devices, redistribute the file system data and metadata across the available devices.