Unfortunately OpenSolaris doesn’t (or didn’t at the time of installing) provide a way of creating a root mirror when installing. So after completing your initial installation you have to manually create this.
Being a newcomer to Solaris/OpenSolaris I did a little searching and have put together a quick howto tutorial for creating a ZFS root mirror.
Creating your ZFS Root Mirror
- Install OpenSolaris to your first disk (will be referred to as Disk A from here on in). I’m not going to cover how to install OpenSolaris its fairly fool proof and if not there a plenty of guides out there.
- After installation remove your installation media and reboot.
- Login to your new installation.
- Open a terminal and get a list of your disks, use the format command and it will list all of your disks.
- In my case c4t0d0 is the disk i installed to (Disk A) and c4t1d0 is the disk I want to mirror to (Disk B).
- Select your mirror destination disk (Disk B – c4t1d0).
- Select fdisk.
- Create a standard Solaris partition over the full disk and then exit out of format.
- Now we must copy the partition table from Disk A to Disk B. prtvtoc is used to report information about a disk geometry and partitioning – the following combination of commands is used to copy a partition table from one disk to another. Again from the terminal run the command “prtvtoc /dev/rdsk/c4t0d0s2 | fmthard -s – /dev/rdsk/c4t1d0s2″. You should get a confirmation message stating “fmthard: New volume table of contents now in place.”
- Now we must attach Disk B to the ZFS Root Pool. To do this run the command “zpool attach -f rpool c4t0d0s0 c4t1d0s0″. You will get a confirmation reminding you to install grub and to wait for the sync (resilver) process to complete before rebooting.
- Lastly we must install Grub (bootloader) on to Disk B. Run the command “installgrub -m /boot/grub/stage1 /boot/grub/stage2 /dev/rdsk/c4t1d0s0″.
- That is our ZFS Root Mirror created. Before rebooting, you should wait for the mirror to sync. You can check its status by running the command “zpool status rpool”. It will give its sync status and progress.
- Once sync is complete reboot and your are now running your rpool from a zfs mirror.
Testing / Recovering your ZFS Root Mirror
- You will probably want to test your mirror is good at this point. Pull Disk A and make sure everything still works and that you can boot and operate without Disk A being in place. Really do this now! You don’t want to find out down the line that things aren’t working…..
- Should the worst happen and a disk fails in the future, simply pull out the faulty disk, replace with a new disk, reboot and repeat the steps above. This using Disk B as the source and Disk C as the destination.