- 论坛徽章:
- 0
|
We did as good as the others
http://www.samag.com/documents/s=1148/sam0107j/0107j.htm
#!/bin/sh
# Original Script written by Constantin Ionescu
# Modified by Carlo Cosolo
# Modified by Peter Baer Galvin
# Modified by John West
# Use and distribute freely
# Define variables for use in the script
# ! Important, these must be set correctly !
# The root disk to duplicate (leave off slice numbers and path)
SRC=c0t0d0
# The empty disk to duplicate it to (leave off slice numbers and path)
DEST=c0t1d0
# The directory to mount destination partitions on while duplicating
MOUNTDIR=/dup_0
# The file name of this script, to rename it on the destination to avoid execution
SCRIPT=/opt/local/etc/rootcopy
# The slices that should be copied
SLICES="s0 s3 s4 s6 s7"
echo ====================================
echo Disk Copy script started `date`
echo
# Make sure the mount point for duplicate partitions exists
if [ ! -d $MOUNTDIR ]; then
mkdir $MOUNTDIR
chmod 700 $MOUNTDIR
fi
# Partition the duplicate disk, make filesystems, make it bootable
prtvtoc /dev/rdsk/${SRC}s2 > /tmp/vtoc
fmthard -s /tmp/vtoc /dev/rdsk/${DEST}s2
installboot /usr/platform/`uname -i`/lib/fs/ufs/bootblk /dev/rdsk/${DEST}s0
# Modify the following loop to handle any special cases
for fs in $SLICES
do
newfs /dev/dsk/${DEST}${fs} < /dev/null; mount /dev/dsk/${DEST}${fs} ${MOUNTDIR};
ufsdump 0f - /dev/dsk/${SRC}${fs}|(cd ${MOUNTDIR}; ufsrestore rf -);
if [ $fs = "s0" ]; then
sed 's/${SRC}/${DEST}/g' /etc/vfstab > ${MOUNTDIR}/etc/vfstab;
mv ${MOUNTDIR}/${SCRIPT} ${MOUNTDIR}/${SCRIPT}.DONTRUN;
fi
umount ${MOUNTDIR}
done
echo
echo Disk Copy script ended `date`
echo ====================================
echo |
|