ZFS Boot Mirror Setup
Recently a primary boot disk went bad on our server and I got blind sided by a non-bootable secondary mirror disk. All the data was intact but I could not boot it. This required a slow re-installation and migration process that took a very long time.
• EFI partitioned drives are not ZFS bootable.
• ZFS attach automatically partitions the drive as EFI.
• ZFS send/recv transfers on gzip compressed data-slices is slow.
Here is the correct way of getting both the disks in the ZFS mirror to boot.
Plug the new drive into the server that you want to add to the ZFS mirror. If your hot swapping or adding a new drive while the server is still on, you need to use cfgadm to configure it.
victori@solaris:~# cfgadm -c configure sata1/1
Now that the drive is configured and seen by the server you need to repartition it with format so it can be used as a bootable device.
victori@solaris:~# format
AVAILABLE DISK SELECTIONS:
0. c4t0d0
/pci@0,0/pci8086,346c@1f,2/disk@0,0
1. c4t1d0
/pci@0,0/pci8086,346c@1f,2/disk@1,0
2. c4t2d0
/pci@0,0/pci8086,346c@1f,2/disk@2,0
* select your new drive *
# fdisk
* use fdisk to remove the EFI partition and add a solaris2 partition. *
Select the partition type to create:
1=SOLARIS2 2=UNIX 3=PCIXOS 4=Other
5=DOS12 6=DOS16 7=DOSEXT 8=DOSBIG
9=DOS16LBA A=x86 Boot B=Diagnostic C=FAT32
D=FAT32LBA E=DOSEXTLBA F=EFI 0=Exit?
This step is very important, if you did not repartition your drive, zfs attach will default the drive back to an EFI partition table that is not bootable.
c4t0d0s2 — primary drive.
c4t1d0s2 — new drive that we are setting up.
victori@solaris:~# prtvtoc /dev/rdsk/c4t0d0s2 | fmthard -s - /dev/rdsk/c4t1d0s2
You should now be able to attach the secondary drive to your mirror using the identical slice.
zpool attach rpool c4t0d0s0 c4t1d0s0
Once the mirror is done synchronizing you need to install the bootloader on the drive.
victori@solaris:~# installgrub -m /boot/grub/stage1 /boot/grub/stage2 /dev/rdsk/c4t1d0s0
Updating master boot sector destroys existing boot managers (if any).
continue (y/n)?y
stage1 written to partition 0 sector 0 (abs 16065)
stage2 written to partition 0, 267 sectors starting at 50 (abs 16115)
stage1 written to master boot sector
Trouble Shooting
victori@solaris:~# installgrub /boot/grub/stage1 /boot/grub/stage2 /dev/rdsk/c4t1d0s0
raw device must be a root slice (not s2)
You did not re-partition the drive to a solaris2 partition. EFI partitions can’t be made bootable. Use the format tool to reconfigure the drive with a solaris2 partition.
zpool attach rpool c4t0d0s0 c4t1d0s0
cannot open/stat device /dev/rdsk/c1t0d0s0
You did not copy your label information from your primary to your secondary disk with prtvtoc and fmthard.
interesting. myself I have just found this cool CD for booting and repairing Windows at windowsbootcd.com, trying it out right now
I wasn’t able to find the installgrub command on my server?
A better approach is to use expert mode when labeling the disk “format -e”, now you can select either EFI or SMI (you want SMI).
Also zpool attach only automatically creates an EFI label is the drive is over 1TB or you specify the whole disk as in “c0t0d0” if you include the slice (“c0t0d0s0”) it will not replace an SMI label with an EFI label.
So:
-format -e
-select new disk
-label with SMI disk label
-exit
-prtvtoc /dev/rdsk/c4t0d0s2 | fmthard -s – /dev/rdsk/c4t1d0s2
-zpool attach rpool c4t0d0s0 c4t1d0s0
Today, I went to the beachfront with my children. I found a sea shell and gave it to my 4 year old daughter
and said “You can hear the ocean if you put this to your ear.” She placed the shell to
her ear and screamed. There was a hermit crab inside and it pinched
her ear. She never wants to go back! LoL I know this is completely off
topic but I had to tell someone!
Excellent post. I will be experiencing some of these
issues as well..