在安装Promox VE(以下简称PVE)操作系统的时候,我选择了mirror(raid1镜像)安装在两块大小一样的磁盘上,
id号:V800_PRO-128_987033160272和V800_PRO-128_987033160260
id号可以在/dev/disk/by-id/目录里面找到。
模拟一下硬盘损坏,我把ata-V800_PRO-128_987033160260这款磁盘拔出来了。
终端下看下状态:
pve:~# zpool status pool: rpool state: DEGRADED status: One or more devices could not be used because the label is missing or invalid. Sufficient replicas exist for the pool to continue functioning in a degraded state. action: Replace the device using 'zpool replace'. see: https://openzfs.github.io/openzfs-docs/msg/ZFS-8000-4Jscan: scrub repaired 0B in 00:00:41 with 0 errors on Sun Mar 13 00:24:42 2022config: NAME STATE READ WRITE CKSUM rpool DEGRADED 0 0 0mirror-0 DEGRADED 0 0 0ata-V800_PRO-128_987033160272-part3 ONLINE 0 0 07676474192047127744 UNAVAIL 0 0 0 was /dev/disk/by-id/ata-V800_PRO-128_987033160260-part3 errors: No known data errors
提示使用“zpool replace”进行磁盘替换。
插入新盘:V800_PRO-128_987033160257
插入新盘,镜像恢复的功能并不会自动启动,因为它不知道新插入的盘是否要进行替换。
新的磁盘名称会出现在:/dev/disk/by-id/目录下,
使用zpool replace -f rpool ata-V800_PRO-128_987033160260-part3 ata-V800_PRO-128_987033160257
命令格式可以不追加参数,让系统提示。
pve:~# zpool replace missing pool name argument usage: replace [-fsw] [-o property=value] <pool> <device> [new-device]
but,还有点小问题,我发现,系统启动分区并没有镜像过来,就是说,这个磁盘的part-1和part2没有镜像过来。
so,把磁盘退出来:zpool detach rpool ata-V800_PRO-128_987033160257
那,要怎么搞呢?
暂时想到了dd,听说可以把uuid也复制过去(不然启动失败)。
dd if=/dev/sdb of=/dev/sda
ls -l /dev/disk/by-id 可以看到设备名称对应的设备id。sdb对应是*272,sda对应是*257。
然后,把part-3加入rpool,让它的数据跟随更新。
pve:~# zpool replace -f rpool ata-V800_PRO-128_987033160260-part3 ata-V800_PRO-128_987033160257-part3 pve:~# zpool status pool: rpool state: DEGRADED status: One or more devices is currently being resilvered. The pool will continue to function, possibly in a degraded state. action: Wait for the resilver to complete. scan: resilver in progress since Wed Mar 16 17:09:09 20223.75G scanned at 75.3M/s, 3.58G issued at 71.8M/s, 3.75G total3.67G resilvered, 95.30% done, 00:00:02 to go remove: Removal of vdev 1 copied 39.6M in 0h0m, completed on Wed Mar 16 16:15:55 20221.90K memory used for removed device mappings config: NAME STATE READ WRITE CKSUM rpool DEGRADED 0 0 0mirror-0 DEGRADED 0 0 0ata-V800_PRO-128_987033160272-part3 ONLINE 0 0 0replacing-1 DEGRADED 0 0 07676474192047127744 UNAVAIL 0 0 0 was /dev/disk/by-id/ata-V800_PRO-128_987033160260-part3 ata-V800_PRO-128_987033160257-part3 ONLINE 0 0 0 (resilvering) errors: No known data errors
重复执行 zpool status,可以看到恢复的速度以及已经过去的时间。
稍等片刻:
pve:~# zpool status pool: rpool state: ONLINE scan: resilvered 3.86G in 00:00:52 with 0 errors on Wed Mar 16 17:10:01 2022remove: Removal of vdev 1 copied 39.6M in 0h0m, completed on Wed Mar 16 16:15:55 2022 1.90K memory used for removed device mappings config: NAME STATE READ WRITE CKSUM rpool ONLINE 0 0 0 mirror-0 ONLINE 0 0 0 ata-V800_PRO-128_987033160272-part3 ONLINE 0 0 0 ata-V800_PRO-128_987033160257-part3 ONLINE 0 0 0errors: No known data errors
嗯,恢复了。
为啥dd的时候拷贝了整个磁盘?因为我不是很熟dd命令,猜测dd if=/dev/sdb of=/dev/sdc conv=notrunc bs=1MB count=600,可以复制前面600M的数据。part-1加上part-2也就540MB。
当然,这样拷贝分区,前面两个分区如果数据更新,新磁盘一样更新不到,只是EFI分区一般比较少更新,等我想到了完善的办法再来更新。
发表评论: