Cover V08, I11
Article
Listing 1

nov99.tar


Listing 1: Sample script for physical disk copy

#!/sbin/sh
#
#
# Physical disk copy script.  This script copies
# the original boot disk to another disk and then
# checks the disk for file system consistency.
# A log is also created to keep track of disk copy
# activity.  Modify this script for your configuration.
# This script can be run from cron.

# Set the “DD_DIR” variable to the
# location of the “dd_script” shell script

DD_DIR=”/var/sadm/dd_log”

# Define the originating disk and the
# destination disk.  (be careful here!)

PRI_DISK=”/dev/rdsk/c#t#d#s#”
CPY_DISK=”/dev/rdsk/c#t#d#s#”

# Set the block size to be used with the “dd”.
# Block size formula:  block size = (# of heads) x (# of cylinders)

BLK_SZ=”126b”   # Your block size may vary

PATH=/usr/bin:/usr/sbin
export PATH

# Update the disk copy log (dd_log)

echo “” >> “$DD_DIR”/dd_log
echo “******************************************************” >>
“$DD_DIR”/dd_log
echo “`date` - Beginning boot disk copy using dd.” >> “$DD_DIR”/dd_log

# Actual copy of disk is performed here.

dd if=/dev/dsk/”$PRI_DISK” of=/dev/rdsk/”$CPY_DISK” bs=”$BLK_SZ” >>
“$DD_DIR”/dd_log

# This fsck makes sure the copied boot disk
# comes up cleanly - all slices are fsck'ed
# to make sure no partition is missed.  Any slice
# that is unused can be commented

echo “`date` - Now performing fsck of disk” >> “$DD_DIR”/dd_log

# Uncomment which disk partition that you want fsck'ed.  Also,
# indicate the proper controller (c#), target (t#), disk (d# - usually 0),
# and slice (s#).

#fsck -y /dev/rdsk/c#t#d#s# >> “$DD_DIR”/dd_log
#fsck -y /dev/rdsk/c#t#d#s# >> “$DD_DIR”/dd_log
#fsck -y /dev/rdsk/c#t#d#s# >> “$DD_DIR”/dd_log
#fsck -y /dev/rdsk/c#t#d#s# >> “$DD_DIR”/dd_log
#fsck -y /dev/rdsk/c#t#d#s# >> “$DD_DIR”/dd_log
#fsck -y /dev/rdsk/c#t#d#s# >> “$DD_DIR”/dd_log
#fsck -y /dev/rdsk/c#t#d#s# >> “$DD_DIR”/dd_log

# Update the disk copy log

echo “`date` - Boot disk copy has completed” >> “$DD_DIR”/dd_log
echo “******************************************************” >>
“$DD_DIR”/dd_log