Friday, December 4, 2009

Solaris Disk Cloning with dd and cpio

For the disk cloning, power off the system, connect the target disk, then boot the system into single user mode. After the cloning, power off the system, disconnect the target disk which can be used as usual.

A. To clone a similar disk, assume the source disk is at /dev/rdsk/c0t0d0 and the target disk is at /dev/rdsk/c0t3d0 in the following example.

1. Clone the root partitial:

dd if=/dev/rdsk/c0t0d0s0 0f=/dev/rdsk/c0t3d0s0 bs=2048k count=1
dd if=/dev/rdsk/c0t0d0s0 of=/dev/rdsk/c0t3d0s0 bs=2048k

2. Clone the entire disk:

dd if=/dev/rdsk/c0t0d0s2 of=/dev/rdsk/c0t3d0s2 bs=2048k

B. To clone a disimilar disk, assume the source is at /dev/dsk/c1t3d0s0 and the target is at /dev/dsk/c1t0d0s0.

mount /dev/dsk/c1t3d0s0 /mnt/old
mount /dev/dsk/c1t0d0s0 /mnt/new
cd /mnt/old
find . -print | cpio -oac | (cd /mnt/new; cpio -imduc)

Continue to perform the similar operation for the rest of partitions.

If cloning is for the root disk, you may need to run installboot to fix the boot problem. Follow is the example to install the boot block on /dev/rdsk/cotodoso.

installboot /usr/platform/`uname -i`/lib/fs/ufs/bootblk /dev/rdsk/c0t0d0s0

No comments: