5.9 Replacing Devices on a Live File System

Note

The device replacement feature requires that you boot the system using UEK R3.

You can replace devices on a live file system. You do not need to unmount the file system
or stop any tasks that are using it. If the system crashes or loses power while the
replacement is taking place, the operation resumes when the system next mounts the file
system.

Use the following command to replace a device on a mounted btrfs file system:

# btrfs replace startsource_devtarget_dev [-r] mountpoint

source_dev and target_dev specify
the device to be replaced (source device) and the replacement device
(target device). mountpoint specifies the
file system that is using the source device. The target device must be the same size as 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 obtained
from other devices (such as another available mirror). The source device is removed from the
file system when the operation is complete.

You can use the btrfs replace statusmountpoint and btrfs replace cancelmountpoint commands to check the progress of the replacement
operation or to cancel the operation.