Friday 27 January 2012

Creating and/or replacing a ZFS mirror

Creating a mirror

Quite often when you install a Solaris system you can't mirror the boot disk up at install time. Its not tricky to do but it can impede you if you don't know where to start.

Firstly, to avoid problems, clone the VTOC - assuming c2t0d0 is your boot disk, and c2t1d0 is your blank disk:-

prtvtoc /dev/rdsk/c2t0d0s2 | fmthard -s - /dev/rdsk/c2t1d0s2

Next, attach the blank disk...

zpool attach pool c2t0d0s0 c2t1d0s0

Depending on your Solaris version you may need to install a boot block.

installboot -F zfs /platform/`uname-m`/lib/fs/zfs/bootblk /dev/rdsk/c2t1d0s2

Set the eeprom, usually your disks are pre-defined in devalias, so the following should suffice.

eeprom boot-device "disk0 disk1"

If you're bored, watch the resilver process take place. ZFS is smart, and with an almost empty disk it only copies where data is written.

zpool status



Replacing a mirror

So what happens if a disk fails? First detach the mirror

zpool detach pool c2t1d0s0

Remove the disk from Solaris, on most hardware (v2x0 and up) this sets an ok to remove light for the engineer.

cfgadm -c unconfigure c2::dsk/c2t1d0

Replace the disk, and add it back in...

cfgadm -c configure c2::dsk/c2t1d0

Replace the disk, and add it back in using the create mirror process above.








No comments: