• 软件测试技术
  • 软件测试博客
  • 软件测试视频
  • 开源软件测试技术
  • 软件测试论坛
  • 软件测试沙龙
  • 软件测试资料下载
  • 软件测试杂志
  • 软件测试人才招聘
    暂时没有公告

字号: | 推荐给好友 上一篇 | 下一篇

a useful script

发布: 2007-6-08 22:43 | 作者: seanhe | 来源: | 查看: 19次 | 进入软件测试论坛讨论

领测软件测试网
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 。。。

延伸阅读

文章来源于领测软件测试网 https://www.ltesting.net/


关于领测软件测试网 | 领测软件测试网合作伙伴 | 广告服务 | 投稿指南 | 联系我们 | 网站地图 | 友情链接
版权所有(C) 2003-2010 TestAge(领测软件测试网)|领测国际科技(北京)有限公司|软件测试工程师培训网 All Rights Reserved
北京市海淀区中关村南大街9号北京理工科技大厦1402室 京ICP备10010545号-5
技术支持和业务联系:info@testage.com.cn 电话:010-51297073

软件测试 | 领测国际ISTQBISTQB官网TMMiTMMi认证国际软件测试工程师认证领测软件测试网