Howto clone an Solaris installation

Lets say you have two disks. c0t0d0s0 with the original installation and c0t1d0s0 as the clone. Booting in single user mode is not required as long as you stop most of your services. Letting ssh run and do actually the cloning is ok. First we copy the
partition table:

$ prtvtoc /dev/rdsk/c0t0d0s0 > /tmp/bla
$ fmthard -s /tmp/bla /dev/rdsk/c0t1d0s0
fmthard:  New volume table of contents now in place.

Now we need a filesystem

$ newfs /dev/rdsk/c0t1d0s0
newfs: /dev/rdsk/c0t1d0s0 last mounted as /
newfs: construct a new file system /dev/rdsk/c0t1d0s0: (y/n)? Y

Mount it

$ mount -F ufs -o rw /dev/dsk/c0t1d0s0 /mnt

and copy the contents of the root filesystem

$ ufsdump 0f - / | ( cd /mnt; ufsrestore xvf - )
Add links
Set directory mode, owner, and times.
set owner/mode for ? [yn] y
Directories already exist, set modes anyway? [yn] y
  DUMP: 123456 blocks (567.89MB) on 1 volume at 388 KB/sec
  DUMP: DUMP IS DONE

If there are more filesystems (/var, /usr or /export/home) you have to repeat the steps above exept the cloning of the partition table. Don’t forget to edit the vfstab if you plan to boot from c0t1d0s0:

vi /mnt/etc/vfstab

To make it bootable this will help on an sparc-based system

$ /usr/sbin/installboot /usr/platform/`uname -i`/lib/fs/ufs/bootblk /dev/rdsk/c1t2d1s0

and this on an i386 system:

$ installgrub -m /boot/grub/stage1 /boot/grub/stage2 /dev/rdsk/c0t1d0s0

Done.

Leave a comment

1 Comments.

  1. prtvtoc /dev/rdsk/c0t0d0s0 | fmthard -s - /dev/rdsk/c0t1d0s0