a useful script
发表于:2007-05-26来源:作者:点击数:
标签:
Hi,everybody. It'slongtimesiceIcamehereatlasttime,Ihopefollowingscriptwillbeusefultoeveryone. -------------------------------------------------------------------------- #!/bin/sh #programtocopyrootusrpartitionsandcreateanewbootabledisk #No
Hi ,everybody.
It's long time sice I came here at last time, I hope following script will be useful to everyone.
--------------------------------------------------------------------------
#!/bin/sh
# program to copy root & usr partitions and create a new bootable disk
# Note that this script is limited to SCSI drives, and only those
# on controller 0.
# It makes the root & usr filesystem on partition 0 for target drive
# and install sash, ide & fx in the volume header of the target drive.
# usage ./clone_disk 0 1 0 2
echo '---------------------------------------------------------------------'
echo 'Note: This utility will create a bootable clone of the system disk '
echo 'on target disk and will build the target disk with an XFS filesystem.'
echo '---------------------------------------------------------------------'
# needed
hn=`hostname`
if [ "$hn" = "" ]; then
hostname IRIS
fi
( versions eoe\*|grep xfs 
> /dev/null 2>&1
if [ $? -ne 0 ];
then
echo The source disk does not have support for XFS
echo and thus cannot be cloned by this script.
exit 1
fi
if [ $# -ne 4 ]
then
echo "Usage: $0 source_controler source_id target_controler target_id"
exit 1
fi
SRC_CON=$1
SRC_NUM=$2
TGT_CON=$3
TGT_NUM=$4
echo "\nJust checking:"
echo "The source (system) disk is controler "$SRC_CON" SCSI id "$SRC_NUM" "
echo "The target ( new  
disk is controler "$TGT_CON" SCSI id "$TGT_NUM" "
echo "\007OK? (n)\c"
read answer
case "$answer" {
y|Y|yes|Yes|YES) ;;
*) echo "\007\n\nAbort"; exit 1;;
}
echo "\nChecking SCSI disk"$TGT_NUM".."
hinv -c disk | grep -s "unit $TGT_NUM on SCSI controller $TGT_CON" > /dev/null 2>&1
if [ $? -ne 0 ]
then echo Sorry, SCSI disk $TGT_NUM not found on controller $TGT_CON
exit 1
fi
fstype=`stat /dev/root |grep fstype|awk '{print $2}'`
fx -x "dksc($TGT_CON,$TGT_NUM,0)" << EOF
label/create/all
label/sync
..
exit
EOF
echo "\nStart disk clone..."
umount /d
mkdir /d
echo making a target filesystem with an internal log 2048 blocks long and 1 KB block size
mkfs -d name=/dev/rdsk/dks"$TGT_CON"d"$TGT_NUM"s0 -l internal,size=2048b -b size=1k
labelit /dev/rdsk/dks"$TGT_CON"d"$TGT_NUM"s0 / sgi
mount /dev/dsk/dks"$TGT_CON"d"$TGT_NUM"s0 /d
df -k
echo "\ncopy root partition..."
if [ "$fstype" = efs ]; then
cd /; dump 0f - / | (cd /d; restore rf - 
else
cd /; xfsdump -L dump -M dump -l 0 -J - / | (cd /d; xfsrestore - .)
fi
fsstat /dev/usr 1> /dev/null 2>&1
stat=$?
if [ $stat = 2 ]
then
mkdir /d/usr
df -k
echo "\ncopy usr partition..."
if [ "$fstype" = efs ]; then
cd /usr; dump 0f - /usr | (cd /d/usr; restore rf - 
else
cd /usr; xfsdump -L dump -M dump -l 0 -J - /usr | (cd /d/usr; xfsrestore - .)
fi
fi
echo "\ninstalling sash, ide & fx in volume header....."
#create sash fx ide tmp files
if [ -d /stand ];
then
echo " keep going......."
else
mkdir /stand
fi
# get the current header files:
/etc/dvhtool -v get sash /stand/sash /dev/rdsk/dks"$SRC_CON"d"$SRC_NUM"vh
/etc/dvhtool -v get fx /stand/fx /dev/rdsk/dks"$SRC_CON"d"$SRC_NUM"vh
/etc/dvhtool -v get ide /stand/ide /dev/rdsk/dks"$SRC_CON"d"$SRC_NUM"vh
# put them on the target
if [ -r /stand/sash ]; then /etc/dvhtool -v c /stand/sash sash /dev/rdsk/dks"$TGT_CON"d"$TGT_NUM"vh; fi
if [ -r /stand/fx ]; then /etc/dvhtool -v c /stand/fx fx /dev/rdsk/dks"$TGT_CON"d"$TGT_NUM"vh; fi
if [ -r /stand/ide ]; then /etc/dvhtool -v c /stand/ide ide /dev/rdsk/dks"$TGT_CON"d"$TGT_NUM"vh; fi
echo "\nNew disk number "$TGT_NUM" ready to use."
echo "\nDONE....."
exit 0
szh 回复于:2002-11-19 09:31:31
|
我看不明白是什么意思?
|
race 回复于:2002-11-19 09:55:06
|
也是克隆启动盘 sgi,忙什么去了啊 常回来看看啊
|
sgi 回复于:2002-11-21 17:14:25
|
谢谢race 把它加入精华区,我经常回来看看的,毕竟对irix还是毕竟怀念的。
|
microroad 回复于:2002-11-22 08:11:18
|
sgi你已经不再用irix了吗?
|
microroad 回复于:2002-11-22 08:19:21
|
刚恳了一点点,有一小惑,请说明一下: echo "\007OK? (n)\c" read answer case "$answer" { y|Y|yes|Yes|YES) ;; *) echo "\007\n\nAbort"; exit 1;; } 有何作用?
|
sgi 回复于:2002-11-22 20:43:00
|
是一个判断提示,yes就会继续,否则就退出。
|
YT 回复于:2002-11-28 11:48:10
|
能够把这个详细的解释一遍吗? 我是CAICAI的 啊,,,,
|
phoenixli 回复于:2002-11-29 00:33:16
|
讲了你也不懂.
|
YT 回复于:2002-11-29 23:02:23
|
但是我会去用心学习的啊。。 呵呵 虽然偶很CAICAI 。。。
|
原文转自:http://www.ltesting.net
|