ZFS ZFS replace a mirrored disk

When a disk fails and want to replace it with a new disk are these commands correct?

Code:
gpart backup nvd1 | gpart restore -F nvd0
gmirror forget swap
gmirror insert swap /dev/nvd0p2
gpart bootcode -b /boot/pmbr -p /boot/gptzfsboot -i 1 nvd0
zpool replace zroot nvd0

I tried the above commands with the same disk without success. I believe the "issue" is because the "new" disk is the same as before. I just try to learn ZFS so I can't ask datacenter to replace the disk with a new one if the disk works fine.
First I boot with mfsBSD and did gpart destroy -F nvd0. Then I boot the server in the main OS.

If the "new" disk is the same as before do I have to change the commands to these?

Code:
gpart backup nvd1 | gpart restore -F nvd0
gmirror forget swap
gmirror insert swap /dev/nvd0p2
gpart bootcode -b /boot/pmbr -p /boot/gptzfsboot -i 1 nvd0
zpool offline zroot nvd0
zpool online zroot nvd0

So instead of replace to use offline & online ?
 
Last edited by a moderator:
Also something else that I notice:

Code:
gmirror status
       Name    Status  Components
mirror/swap  DEGRADED  nvd1p2 (ACTIVE)

gpart backup nvd1 | gpart restore -F nvd0

Code:
gmirror status
       Name    Status  Components
mirror/swap  COMPLETE  nvd1p2 (ACTIVE)
                                           nvd0p2 (ACTIVE)

How is possible the swap to rebuild the RAID-1 without these commands?

Code:
gmirror forget swap
gmirror insert swap /dev/nvd0p2
 
Last edited by a moderator:
Back
Top