Create a Standby Root Mirror: duplicate.sh

This script works for Solaris machines only, but does support multiple Sun architectures.  It duplicates the root disk to another disk using newfs, fsck, and dump.  It then sets the EEPROM settings to automatically boot off that disk the next time the system is rebooted.

Copying the OS

To copy the OS, it performs the following steps:
  • Partition the copy drive to look the same as the drive we are booted from
  • newfs the appropriate filesystems on the other drive
  • fsck the appropriate fileystems on the other drive
  • Use dump/restore to copy the OS over to the other drive
  • Modifies the /etc/vfstab to look right on the other drive
This is typically done via cron once a night.  The duplication can be halted if you are planning on an OS upgrade, patch installation, application installation, or other risky project.  If anything happens to your OS as a result of this project, you can safely boot off the old disk if you halted the duplication for the length of the project.

Setting the alternate boot

duplicate.sh uses the disk aliases (e.g. disk0 disk3) already available.  It looks at the disk we are currently booted from (e.g. disk0), and then sets the boot argument to the other disk (e.g. boot disk3).  That way, the next time the system reboots, it boots from this disk.  This continually tests the process and the other disk.  A neat feature of this is that if the system panics for any reason, it automatically boots from the other disk when it comes back up.

Don't Forget

Remember to disable the duplication process for a few days any time you are planning an upgrade of any kind.  When you install patches or applications that require a reboot, make sure you set the boot alias to boot off the drive that you just modified.  Otherwise, you will boot off the alternate disk that was not modified.  Of course, you could also immediately run duplicate.sh, but I wouldn't advise that.  I would make sure that the change didn't negatively affect your system.