Replacing a disk in zfs mirror
May 6, 2013 Leave a comment
Well, it paid off. Last week, I noticed that one of the disks in my NAS had failed. And of all the disks, it was the one with the family photos. So setting up the ZFS mirror saved my bacon. Below is what I saw.
admin@nas:~# zpool status pool: files state: DEGRADED status: One or more devices are unavailable in response to persistent errors. Sufficient replicas exist for the pool to continue functioning in a degraded state. action: Determine if the device needs to be replaced, and clear the errors using 'zpool clear' or 'fmadm repaired', or replace the device with 'zpool replace'. Run 'zpool status -v' to see device specific details. scan: scrub repaired 0 in 14h27m with 0 errors on Tue Apr 16 15:27:09 2013 config: NAME STATE READ WRITE CKSUM files DEGRADED 0 0 0 mirror-0 DEGRADED 0 0 0 c12d1 ONLINE 0 0 0 c13d1 UNAVAIL 0 0 0 errors: No known data errors
As you can see, c13d1 had failed. If I really was fancy, I would have had a spare disk in the system and configured as the mirror spare and ZFS would have swapped out the bad drive for the spare automatically. But I didn`t go that route. So off to the store I went and got replacement.
Once I got the new drive, I shut down the system, replace the drive and booted back up. When I booted back up, the error message was still present as expected since the new disk had not ZFS content on it. All I had to do was issue the following command.
zpool replace files c13d1
From there, ZFS would resilver the new drive into the mirror. Depending on how big the drives were, it can take a while.
admin@nas:~# zpool status files pool: files state: DEGRADED status: One or more devices is currently being resilvered. The pool will continue to function in a degraded state. action: Wait for the resilver to complete. Run 'zpool status -v' to see device specific details. scan: resilver in progress since Sat May 4 22:25:34 2013 4.92G scanned out of 1.50T at 18.2M/s, 23h54m to go 2.41G resilvered, 0.32% done config: NAME STATE READ WRITE CKSUM files DEGRADED 0 0 0 mirror-0 DEGRADED 0 0 0 c12d1 ONLINE 0 0 0 replacing-1 UNAVAIL 0 0 0 c13d1/old UNAVAIL 0 0 0 c13d1 OFFLINE 0 0 0 (resilvering)
And once it was done, the mirrot was back to normal.
admin@nas:~# zpool status files pool: files state: ONLINE status: The pool is formatted using an older on-disk format. The pool can still be used, but some features are unavailable. action: Upgrade the pool using 'zpool upgrade'. Once this is done, the pool will no longer be accessible on older software versions. scan: resilvered 1.49T in 9h56m with 0 errors on Mon May 6 09:49:31 2013 config: NAME STATE READ WRITE CKSUM files ONLINE 0 0 0 mirror-0 ONLINE 0 0 0 c12d1 ONLINE 0 0 0 c13d1 ONLINE 0 0 0