====== Замена диска в RAID1 под FreeBSD ====== ===== zpool ===== ==== Смотрим состояние массива zpool: ==== Обратите внимание, здесь действия производятся в rescue mode # zpool status pool: tank state: DEGRADED status: One or more devices could not be opened. Sufficient replicas exist for the pool to continue functioning in a degraded state. action: Attach the missing device and online it using 'zpool online'. see: http://illumos.org/msg/ZFS-8000-2Q scan: resilvered 10.5G in 0h9m with 0 errors on Mon Feb 1 09:49:38 2016 config: NAME STATE READ WRITE CKSUM tank DEGRADED 0 0 0 mirror-0 DEGRADED 0 0 0 ada1p3 ONLINE 0 0 0 9066085129501579450 UNAVAIL 0 0 0 was /dev/ada0p3 errors: No known data errors Копируем разметку с рабочего диска: # gpart backup ada1 | gpart restore -F /dev/ada0 Монтируем: # zpool import -o altroot=/mnt tank Добавляем: # zpool replace tank 9066085129501579450 ada0p3 Make sure to wait until resilver is done before rebooting. If you boot from pool 'tank', you may need to update boot code on newly attached disk 'ada0p3'. Assuming you use GPT partitioning and 'da0' is your new boot disk you may use the following command: gpart bootcode -b /boot/pmbr -p /boot/gptzfsboot -i 1 da0 Ставим загрузчик: gpart bootcode -b /boot/pmbr -p /boot/gptzfsboot -i 1 ada0 bootcode written to ada0 Проверяем: # zpool status pool: tank 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 Tue May 10 22:34:44 2016 1.08G scanned out of 196G at 8.42M/s, 6h35m to go 1.07G resilvered, 0.55% done config: NAME STATE READ WRITE CKSUM tank DEGRADED 0 0 0 mirror-0 DEGRADED 0 0 0 ada1p3 ONLINE 0 0 0 replacing-1 UNAVAIL 0 0 0 9066085129501579450 UNAVAIL 0 0 0 was /dev/ada0p3/old ada0p3 ONLINE 0 0 0 block size: 512B configured, 4096B native (resilvering) errors: No known data errors ===== gmirror ===== Обратите внимание, здесь действия производятся на "живой", работающей системе! # Меняем диск ada0 # Сохраняем его разметку gpart backup ada0 > ada0.bcp # Удаляем неисправный диск из массива gmirror remove boot ada0p1 gmirror remove swap ada0p2 gmirror remove root ada0p3 # В этом месте можно придти и извлечь диск из сервера # Если не зависло, работает, то вставляем новый диск и восстанавливаем массив gpart restore -l -F ada0 < ada0.bcp gmirror insert boot ada0p1 gmirror insert swap ada0p2 gmirror insert root ada0p3 Смотрим на полученный результат - синхронизация началась! [root@k ~]# gmirror status Name Status Components mirror/boot COMPLETE ada1p1 (ACTIVE) ada0p1 (ACTIVE) mirror/swap COMPLETE ada1p2 (ACTIVE) ada0p2 (ACTIVE) mirror/root DEGRADED ada1p3 (ACTIVE) ada0p3 (SYNCHRONIZING, 0%) gpart bootcode -b /boot/pmbr -p /boot/gptboot -i 1 ada0