e1e0.net

sources for e1e0 website
git clone https://git.e1e0.net/e1e0.net.git
Log | Files | Refs

raidz-disk-change.md (2813B)


      1 Title: ZFS RAIDZ disk change
      2 Author: paco
      3 Date: 2018-11-13
      4 Type: article
      5 
      6 Here are some notes in order to change a failing disk on a RAIDZ pool.
      7 This has been tested on FreeBSD 11.2. It may work with other versions,
      8 but check `gpart(8)`, `zpool(8)` and the handbook to be sure.
      9 
     10 My NAS runs FreeBSD 11.2 with zroot, 4x3TB disks in raidz1.
     11 Some days ago 1 of those disks started to report quite a few _smart_
     12 errors. ZFS itself did not report any errors, but I prefer to change the
     13 disk while it still works. It's probably faster (copy over re-build)
     14 and safer, as one does not face the possibility of a failing disk while
     15 rebuilding the RAID.
     16 
     17 In this particular case `ada2` was failing, and ada4 was the new disk.
     18 This will change once the failing disk is removed, but I don't care as I
     19 use gtp labels.
     20 
     21 I don't like GPT GUID labels nor DiskID labels (although I see the point
     22 on this latter ones when you have a bunch of disks ...). So, I have this
     23 on `/boot/loader.conf`
     24 
     25     kern.geom.label.gptid.enable="0"
     26     kern.geom.label.disk_ident.enable="0"
     27 
     28 First thing is to create thg GPT partition table:
     29 
     30     gpart create -s GPT ada4
     31 
     32 And replicate the same partition scheme on the new disk (in my
     33 particular case replacement disk and replaced disk are the same model):
     34 
     35     gpart backup ada2 | gpart restore -F ada4
     36 
     37 This only replicates the partition scheme, but not the labels. So that
     38 has to be done manually:
     39 
     40     gpart modify -i 3 -l zfs4 ada4
     41     gpart modify -i 2 -l swap4 ada4
     42     gpart modify -i 1 -l gptboot4 ada4
     43 
     44 As you can see on my schema I have a boot partition on each disk, a swap
     45 partition an another partition which is part of the zpool.
     46 
     47 At this time, we're ready to replace the disk:
     48 
     49     zpool replace zroot gpt/zfs2 gpt/zfs4
     50 
     51 This can take a lot of time. It all depends on your hardware. In my case
     52 it took over 10h.
     53 
     54 Is a good idea to setup now the bootloader in place on the new disk:
     55 
     56     gpart bootcode -b /boot/pmbr -p /boot/gptzfsboot -i 1 ada4
     57 
     58 Once finished everything is back to normal:
     59 
     60     pool: zroot
     61     state: ONLINE
     62     scan: resilvered 2.15T in 10h23m with 0 errors on Tue Nov 13 04:31:35 2018
     63   config:
     64   
     65           NAME          STATE     READ WRITE CKSUM
     66           zroot         ONLINE       0     0     0
     67             raidz1-0    ONLINE       0     0     0
     68               gpt/zfs0  ONLINE       0     0     0
     69               gpt/zfs1  ONLINE       0     0     0
     70               gpt/zfs4  ONLINE       0     0     0
     71               gpt/zfs3  ONLINE       0     0     0
     72   
     73     errors: No known data errors
     74 
     75 As a bonus, those commends can help a lot getting information about the
     76 disks, partitions and status:
     77 
     78     zpool status
     79     gpart show
     80     gpart backup <provider>
     81     camcontrol devlist
     82 
     83 Take a look at the respective man pages before executing anything on
     84 your machine !