using dd

From: Pappas, Bill (Bill.Pappas@stjude.org)
Date: Mon Mar 24 2003 - 14:29:09 EST


I found a great script for cloning a disk, but I was wondering...is there a
way to automate the cloning via crontab?
Here is what I would like to see happen automatically....
1. From multiuser mode with networking (init 3) goto single user mode.
2. Mount the disks you need
3. Perform the clonedisk script shown at MY SCRIPT.
4. When dome with #3 go back to init 3

The problem I am having is with step 1. As I dive into single user mode, my
script is killed as are other processes.
Therefoe, I never reach step 2

Any suggestions on how I could automate this?

MY SCRIPT:

#cat clonedisk.sh
#!/bin/sh -x
#
#The may work only with disks using the same
#geometry e.g the same models.
#
#1. initial steps
#
#- plug in the destination disk in the drive cage
#- power on the machine
#- with "show dev" you should see the master disk and the destination disk
#- boot from the master disk
#
#2. the cloning
#
#- login and do the following
#
# hwmgr -view devices
#(you should see both disks and the special-device files too)
#
# Here we begin:
#
#
# Put the machine into single user mode and mount all disks
init s
echo "Wait for 60 seconds so that this machine can stop all related
processes"
sleep 60
mount -a
sleep 4
#
#
# After booting in single-user (b -fl s)
# make sure that the devicefiles for your destination disk
# exists (ls -l /dev/rdisk)
#
echo "1 - modify root_domain usr_domain var_domain and home_domain"
#
cd /etc/fdmns/root_domain
rm dsk6a
ln -s /dev/disk/dsk5a .
ls -l
#
cd /etc/fdmns/usr_domain
rm dsk6b
ln -s /dev/disk/dsk5b .
ls -l
#
cd /etc/fdmns/var_domain/
rm dsk6g
ln -s /dev/disk/dsk5g .
ls -l
#
cd /etc/fdmns/home_domain/
rm dsk6h
ln -s /dev/disk/dsk5h .
ls -l
#
#
#
echo "modification correct? 5 seconds to go on! CTRL+C will break"
sleep 5

echo "2 - clear the disklabel on the destination disk"

disklabel -z /dev/rdisk/dsk5c
sleep 2

echo "3 - clone the source disk to the destination disk"
echo "this takes time ... please wait ..."
sync ;sync
dd if=/dev/rdisk/dsk6c of=/dev/rdisk/dsk5c bs=1024k

echo "4 - resemble root_domain and usr_domain var_domain home_domain"

# restore the old links!
cd /etc/fdmns/root_domain
rm dsk5a
ln -s /dev/disk/dsk6a .
#
cd /etc/fdmns/usr_domain
rm dsk5b
ln -s /dev/disk/dsk6b .
#
cd /etc/fdmns/var_domain
rm dsk5g
ln -s /dev/disk/dsk6g .
#
cd /etc/fdmns/home_domain
rm dsk5h
ln -s /dev/disk/dsk6h .
#
sleep 2

echo "5 - Halt the system and boot from your cloned disk"

echo "6 - run the script finishclonedd"

init 3



This archive was generated by hypermail 2.1.7 : Sat Apr 12 2008 - 10:49:13 EDT