How to replace HDD in ZFS raidz2

mikeo_43015

New Member
Jan 5, 2022
5
0
1
51
Have 2 HDD that are degraded and need help on how to replace the drives without losing data.


zpool status

config:

NAME STATE READ WRITE CKSUM
NAS-Local DEGRADED 0 0 0
raidz2-0 DEGRADED 0 0 0
ata-WDC_WD30EZRX-00SPEB0_WD-WCC4E0807601 ONLINE 0 0 0
ata-WDC_WD30EZRX-00SPEB0_WD-WCC4E0711318 ONLINE 0 0 0
ata-WDC_WD30EZRX-00MMMB0_WD-WCAWZ1948935 FAULTED 37 1 0 too many errors
ata-WDC_WD30EZRX-00MMMB0_WD-WCAWZ2697916 DEGRADED 0 0 0 too many errors
ata-WDC_WD30EZRX-00MMMB0_WD-WCAWZ2568784 ONLINE 0 0 0
ata-WDC_WD30EZRX-00MMMB0_WD-WCAWZ2856607 ONLINE 0 0 0


root@Vader:~# ls -al /dev/disk/by-id | grep WDC_WD30EZRX-00MMMB0_WD-WCAWZ1948935
lrwxrwxrwx 1 root root 9 Oct 26 17:36 ata-WDC_WD30EZRX-00MMMB0_WD-WCAWZ1948935 -> ../../sdc
lrwxrwxrwx 1 root root 10 Oct 26 17:36 ata-WDC_WD30EZRX-00MMMB0_WD-WCAWZ1948935-part1 -> ../../sdc1
lrwxrwxrwx 1 root root 10 Oct 26 17:36 ata-WDC_WD30EZRX-00MMMB0_WD-WCAWZ1948935-part9 -> ../../sdc9



Thanks,
 
Based on the article I found here...


I created a script as below...which worked for me. I am a novice though, so cannot offer any guarantees
#!/bin/bash poolName="NAS-Local"; replacementDevID="/dev/disk/by-id/ata-WDC_WD30EZRX-00MMMB0_WD-WCAWZ1948935"; zpool status "${poolName}" | grep -i "UNAVAIL\|OFFLINE\|DEGRADED" | grep -v "replacing"; #this SHOULD show the drive/device that is not happy zpool status "${poolName}" | grep -i "OFFLINE" | awk '{print $1 " was " $7}'; #this SHOULD show the drive/device that is not happy badDev=$(zpool status "${poolName}" | grep -i "UNAVAIL\|OFFLINE\|DEGRADED" | grep -v "replacing\|state\|raidz\|${poolName}"); printf "%s\n" "${badDev}"; badID=$(awk '{print $1}' <<< "${badDev}"); printf "%s\n" "${badID}"; zpool offline "${poolName}" "${badID}"; zpool replace "${poolName}" "${badID}" "${replacementDevID}"
 
  • Like
Reactions: mikeo_43015
zpool status

покажет нерабочий диск, копируем весь вывод

NAME STATE READ WRITE CKSUM
raid6_02 DEGRADED 0 0 0
raidz2-0 DEGRADED 0 0 0
scsi-35000c50056db990b ONLINE 0 0 0
scsi-35000c50056dfa16f ONLINE 0 0 0
scsi-35000c5005662661b FAULTED 229 22 0 too many errors
scsi-35000c500565d5983 ONLINE 0 0 0
scsi-35000c50056db533b ONLINE 0 0 0
scsi-35000c50056617467 ONLINE 0 0 0


физически меняем диск на новый
и даём команду

ls -al /dev/disk/by-id

в выводе будут все диски, новый можно опознать, если сравнить с выводом предыдущей команды, т к там его не было, также совсем новый диск не будет содержать разделов
если же на новом диске есть разделы (напр диск б/у), то вводим команду

fdisk /dev/sde

, где sde это новый диск, со случайно оказавшимися там разделами

внутри программы фдиск нажимаем кнопку

d

удаляем таким образом все разделы
поле чего выходим, введя

w

проверяем

ls -al /dev/disk/by-id

у нового диска разделов уже быть не должно
далее вводим команду

zpool replace -f <pool> <old-device> <new-device>

например

zpool replace -f raid6_02 scsi-35000c5005662661b ata-VBOX_HARDDISK_VB4906d5e3-880410aa


ну и в конце проверяем

zpool status
 
Have you tried to look at dmesg / smartctl ?

Try zpool clear <pool_name>
This will make zfs pool to do resilvering and it may be enough for fix. Later investigate the status of the disk.
 

About

The Proxmox community has been around for many years and offers help and support for Proxmox VE, Proxmox Backup Server, and Proxmox Mail Gateway.
We think our community is one of the best thanks to people like you!

Get your subscription!

The Proxmox team works very hard to make sure you are running the best software and getting stable updates and security enhancements, as well as quick enterprise support. Tens of thousands of happy customers have a Proxmox subscription. Get yours easily in our online shop.

Buy now!