btrfs-replace(8)

SYNOPSIS 概要 

btrfs replace <subcommand> <args>
btrfs 替换 <子命令> <参数>

DESCRIPTION 描述 

btrfs replace is used to replace btrfs managed devices with other device.
btrfs 替换用于将 btrfs 管理的设备替换为其他设备。

SUBCOMMAND 子命令 

cancel <mount_point> 取消 <挂载点>

Cancel a running device replace operation.
取消正在运行的设备替换操作。

start [options] <srcdev>|<devid> <targetdev> <path>
启动 [选项] <源设备>|<设备 ID> <目标设备> <路径>

Replace device of a btrfs filesystem.
替换 btrfs 文件系统的设备。

On a live filesystem, duplicate the data to the target device which is currently stored on the source device. If the source device is not available anymore, or if the -r option is set, the data is built only using the RAID redundancy mechanisms. After completion of the operation, the source device is removed from the filesystem. If the srcdev is a numerical value, it is assumed to be the device id of the filesystem which is mounted at path, otherwise it is the path to the source device. If the source device is disconnected, from the system, you have to use the devid parameter format. The targetdev needs to be same size or larger than the srcdev.
在活动文件系统上,将存储在源设备上的数据复制到目标设备。如果源设备不再可用,或者设置了 -r 选项,则仅使用 RAID 冗余机制构建数据。操作完成后,源设备将从文件系统中移除。如果 srcdev 是一个数字值,则假定它是挂载在路径上的文件系统的设备 ID,否则它是源设备的路径。如果源设备从系统中断开连接,您必须使用 devid 参数格式。目标设备的大小需要与 srcdev 相同或更大。

Note 注意

The filesystem has to be resized to fully take advantage of a larger target device; this can be achieved with btrfs filesystem resize <devid>:max /path
文件系统必须调整大小以充分利用更大的目标设备;这可以通过 btrfs filesystem resize <devid>:max /path 实现。

Options

-r

only read from srcdev if no other zero-defect mirror exists. (enable this if your drive has lots of read errors, the access would be very slow)
只有在没有其他零缺陷镜像存在时才从 srcdev 读取。(如果您的驱动器有很多读取错误,访问速度会非常慢时,请启用此选项)

-f

force using and overwriting targetdev even if it looks like it contains a valid btrfs filesystem.
即使看起来包含有效的 btrfs 文件系统,也强制使用和覆盖 targetdev。

A valid filesystem is assumed if a btrfs superblock is found which contains a correct checksum. Devices that are currently mounted are never allowed to be used as the targetdev.
如果找到包含正确校验和的 btrfs 超级块,则假定存在有效的文件系统。当前已挂载的设备永远不允许用作目标设备。

-B

no background replace. 不替换背景。

--enqueue

wait if there’s another exclusive operation running, otherwise continue
如果有另一个独占操作正在运行,则等待,否则继续

-K|--nodiscard

Do not perform whole device TRIM operation on devices that are capable of that. This does not affect discard/trim operation when the filesystem is mounted. Please see the mount option discard for that in btrfs(5).
不要在能够执行整个设备 TRIM 操作的设备上执行该操作。这不会影响文件系统挂载时的丢弃/修剪操作。请参阅 btrfs(5) 中的挂载选项 discard。

status [-1] <mount_point>
状态 [-1] <挂载点>

Print status and progress information of a running device replace operation.
打印正在运行的设备替换操作的状态和进度信息。

Options

-1

print once instead of print continuously until the replace operation finishes (or is cancelled)
仅打印一次,而不是持续打印,直到替换操作完成(或被取消)。

EXAMPLES 示例

Replacing an online drive with a bigger one
用更大的在线驱动器替换在线驱动器。

Given the following filesystem mounted at /mnt/my-vault
给定以下挂载在 /mnt/my-vault 的文件系统

Label: 'MyVault'  uuid: ae20903e-b72d-49ba-b944-901fc6d888a1
        Total devices 2 FS bytes used 1TiB
        devid    1 size 1TiB used 500.00GiB path /dev/sda
        devid    2 size 1TiB used 500.00GiB path /dev/sdb

In order to replace /dev/sda (devid 1) with a bigger drive located at /dev/sdc you would run the following:
为了用位于 /dev/sdc 的更大驱动器替换 /dev/sda (devid 1),您需要运行以下命令:

btrfs replace start 1 /dev/sdc /mnt/my-vault/

You can monitor progress via:
您可以通过以下方式监视进度:

btrfs replace status /mnt/my-vault/

After the replacement is complete, as per the docs at btrfs-filesystem(8) in order to use the entire storage space of the new drive you need to run:
替换完成后,根据 btrfs-filesystem(8)文档,为了使用新驱动器的整个存储空间,您需要运行:

btrfs filesystem resize 1:max /mnt/my-vault/

EXIT STATUS 退出状态 

btrfs replace returns a zero exit status if it succeeds. Non zero is returned in case of failure.
如果成功,btrfs replace 返回零退出状态。如果失败,则返回非零值。

AVAILABILITY 可用性 

btrfs is part of btrfs-progs. Please refer to the documentation at https://btrfs.readthedocs.io.
btrfs 是 btrfs-progs 的一部分。请参考 https://btrfs.readthedocs.io 上的文档。

SEE ALSO 参见 

btrfs-device(8), btrfs-filesystem(8), mkfs.btrfs(8)