Clone a Solaris boot disk

      8 Comments on Clone a Solaris boot disk

Having a disk failure the other day reminded me I need to create a clone of the boot drive in our V880 machine…so recovery from the inevitable disk failure won’t require a full reinstall of Solaris (had to do that a year or so ago and it took way longer than I wanted it to). Since I’m not a fan of tape backups, I want to have a boot-drive cloning system in place (like I use for Linux & Mac OSX Server machines). Haven’t found a Carbon Copy Cloner for Solaris yet, so here’s the next best thing.

Here are my notes thus far:

1) Install a duplicate of the boot drive … same geometry, and so on. This part isn’t too hard in the standardized Solaris hardware realm. This isn’t critical but it makes things a lot easier. If you don’t have an identical drive, you can’t use the prtvtoc command shown below.

2) Partition the new drive exactly like the existing one. You can do this via the format command…counting cylinders and so on…but here’s a much faster (and less error-prone) way to do that:

Say the original drive is c1t0d0
and the new drive is c1t4d0

prtvtoc /dev/rdsk/c1t0d0s2 | fmthard -s – /dev/rdsk/c1t4d0s2

Voila…new drive is partitoned exactly like the orginal.

Now, this script will build new file systems on the partitions of the new disk…matching those on the original. Then it will run ufsdump, copying data from the original to the new drive…then unmount the new “clone” drive. Finally it makes the new clone bootable. Note that this jazzy blog format wraps lines on the installboot line of the script…a “man installboot” will give you a clean copy of the syntax.

#! /bin/ksh
# script assumes:
# c1t0d0 is original
# c1t4d0 is drive we’ll turn into a clone

partlist=$(prtvtoc /dev/rdsk/c1t4d0s2 | awk ‘!/\*/ {print $1}’)

for p in $partlist
do
if [ “$p” != “1” -a “$p” != “2” ]
then
newfs /dev/rdsk/c1t4d0s$p < /dev/null mount /dev/dsk/c1t4d0s$p /mnt cd /mnt ufsdump 0uf - /dev/dsk/c1t0d0s$p | ufsrestore rf - cd / umount /mnt fi done mount /dev/dsk/c1t4d0s0 /mnt installboot /usr/platform/`uname -i`/lib/fs/ufs/bootblk \ /dev/rdsk/c1t4d0s0 umount /mnt exit 0

Update (9/23/2005): The other day our power went off (again) so I decided to test whether the clone drive I created using this process actually worked as I had hoped. Pulled the disk out & put it in the boot drive’s slot (0) on the V880…when power came back on I hit the switch…yes…it booted fine and loaded Oracle, Voyager and everything else without a hitch.

Shut things back down & swapped the drive back out of the boot position–but now I can sleep a bit more peacefully.