在root上使用 ZFS 时如何用新磁盘替换损坏的磁盘?
我有 4 个使用 zroot 的磁盘 RAIDZ2 池。这意味着 ZFS 在单独的分区上运行,而不是使用整个磁盘。我没有找到任何关于如何在这种情况下更换磁盘的文档,或者信息已被弃用。池是由安装自动生成的。
凸轮控制设备列表:
% doas camcontrol devlist -v
scbus0 on mpt0 bus 0:
<> at scbus0 target -1 lun ffffffff ()
scbus1 on ahcich0 bus 0:
<> at scbus1 target -1 lun ffffffff ()
scbus2 on ahcich1 bus 0:
<> at scbus2 target -1 lun ffffffff ()
scbus3 on ahcich2 bus 0:
<ST2000DM001-1CH164 CC43> at scbus3 target 0 lun 0 (pass0,ada0)
<> at scbus3 target -1 lun ffffffff ()
scbus4 on ahcich3 bus 0:
<ST2000DM001-1CH164 CC43> at scbus4 target 0 lun 0 (pass1,ada1)
<> at scbus4 target -1 lun ffffffff ()
scbus5 on ahcich4 bus 0:
<ST2000DM001-1CH164 CC43> at scbus5 target 0 lun 0 (pass2,ada2)
<> at scbus5 target -1 lun ffffffff ()
scbus6 on ahcich5 bus 0:
<SAMSUNG HD204UI 1AQ10001> at scbus6 target 0 lun 0 (pass3,ada3)
<> at scbus6 target -1 lun ffffffff ()
scbus7 on ahciem0 bus 0:
<AHCI SGPIO Enclosure 1.00 0001> at scbus7 target 0 lun 0 (pass4,ses0)
<> at scbus7 target -1 lun ffffffff ()
scbus-1 on xpt0 bus 0:
<> at scbus-1 target -1 lun ffffffff (xpt0)
现有磁盘的 gpart:
% gpart show ada0
=> 40 3907029088 ada0 GPT (1.8T)
40 1024 1 freebsd-boot (512K)
1064 984 - free - (492K)
2048 4194304 2 freebsd-swap (2.0G)
4196352 3902832640 3 freebsd-zfs (1.8T)
3907028992 136 - free - (68K)
zpool状态:
% zpool status zroot
pool: zroot
state: DEGRADED
status: One or more devices has been removed by the administrator.
Sufficient replicas exist for the pool to continue functioning in a
degraded state.
action: Online the device using 'zpool online' or replace the device with
'zpool replace'.
scan: scrub repaired 28K in 0h41m with 0 errors on Thu Sep 27 17:58:02 2018
config:
NAME STATE READ WRITE CKSUM
zroot DEGRADED 0 0 0
raidz2-0 DEGRADED 0 0 0
ada0p3 ONLINE 0 0 0
ada1p3 ONLINE 0 0 0
ada2p3 ONLINE 0 0 0
15120424524672854601 REMOVED 0 0 0 was /dev/ada3p3
errors: No known data errors
离线:
% doas zpool offline zroot 15120424524672854601
我试图将前几个 GiB 从 ada0 复制到 ada3 ,dd
但两者都zpool attach
给出zpool replace
了错误:/dev/ada3p3 is part of active pool 'zroot'
甚至强制标志也无济于事。我猜磁盘 UUID 正在发生冲突。
如何将ada0-2p1-3
分区复制/复制到新磁盘(ada3)并更换故障驱动器的步骤是什么?自动安装程序首先运行了哪些命令来创建这些分区?
首先:记得让新驱动器离线,并确保它没有安装或以任何方式使用。
将分区表从旧磁盘复制
ada0
到新磁盘ada3
:现在
ada3
有相同的三个分区ada0
:删除旧的 ZFS 元数据(注意分区p3):
更换驱动器(注意分区p3):
运行上述命令以更新新磁盘上的引导信息:
UUID 现在不同了:
驱动器现在正在重新同步:
重新同步后: