免费注册 查看新帖 |

Chinaunix

  平台 论坛 博客 文库
最近访问板块 发新帖
查看: 4639 | 回复: 9
打印 上一主题 下一主题

[SCO UNIX] a useful script [复制链接]

论坛徽章:
0
跳转到指定楼层
1 [收藏(0)] [报告]
发表于 2002-11-18 20:14 |只看该作者 |倒序浏览
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" = "" ]&#59; then
hostname IRIS
fi

( versions eoe\*|grep xfs ) >; /dev/null 2>;&1
if [ $? -ne 0 ]&#59;
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) &#59;&#59;
        *) echo "\007\n\nAbort"&#59; exit 1&#59;&#59;
        }


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 &quot;dksc($TGT_CON,$TGT_NUM,0)&quot; << EOF
label/create/all
label/sync
..
exit
EOF

echo &quot;\nStart disk clone...&quot;
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&quot;$TGT_CON&quot;d&quot;$TGT_NUM&quot;s0 -l internal,size=2048b -b size=1k
labelit /dev/rdsk/dks&quot;$TGT_CON&quot;d&quot;$TGT_NUM&quot;s0 / sgi
mount /dev/dsk/dks&quot;$TGT_CON&quot;d&quot;$TGT_NUM&quot;s0 /d
df -k
echo &quot;\ncopy root partition...&quot;
if [ &quot;$fstype&quot; = efs ]&#59; then
cd /&#59; dump 0f - / | (cd /d&#59; restore rf - )
else
cd /&#59; xfsdump -L dump -M dump -l 0 -J - / | (cd /d&#59; xfsrestore - .)
fi

fsstat /dev/usr 1>; /dev/null 2>;&amp;1
stat=$?
if [ $stat = 2 ]
then
mkdir /d/usr
df -k
echo &quot;\ncopy usr partition...&quot;
if [ &quot;$fstype&quot; = efs ]&#59; then
cd /usr&#59; dump 0f - /usr | (cd /d/usr&#59; restore rf - )
else
cd /usr&#59; xfsdump -L dump -M dump -l 0 -J - /usr | (cd /d/usr&#59; xfsrestore - .)
fi
fi

echo &quot;\ninstalling sash, ide &amp; fx in volume header.....&quot;

#create sash fx ide tmp files
if [ -d /stand ]&#59;
then
     echo &quot; keep going.......&quot;
else
     mkdir /stand
fi
# get the current header files:
/etc/dvhtool -v get sash /stand/sash /dev/rdsk/dks&quot;$SRC_CON&quot;d&quot;$SRC_NUM&quot;vh
/etc/dvhtool -v get fx   /stand/fx   /dev/rdsk/dks&quot;$SRC_CON&quot;d&quot;$SRC_NUM&quot;vh
/etc/dvhtool -v get ide  /stand/ide  /dev/rdsk/dks&quot;$SRC_CON&quot;d&quot;$SRC_NUM&quot;vh

# put them on the target
if [ -r /stand/sash ]&#59; then /etc/dvhtool -v c /stand/sash sash /dev/rdsk/dks&quot;$TGT_CON&quot;d&quot;$TGT_NUM&quot;vh&#59; fi
if [ -r /stand/fx   ]&#59; then /etc/dvhtool -v c /stand/fx     fx /dev/rdsk/dks&quot;$TGT_CON&quot;d&quot;$TGT_NUM&quot;vh&#59; fi
if [ -r /stand/ide  ]&#59; then /etc/dvhtool -v c /stand/ide   ide /dev/rdsk/dks&quot;$TGT_CON&quot;d&quot;$TGT_NUM&quot;vh&#59; fi
echo &quot;\nNew disk number &quot;$TGT_NUM&quot; ready to use.&quot;

echo &quot;\nDONE.....&quot;
exit 0



论坛徽章:
0
2 [报告]
发表于 2002-11-19 09:31 |只看该作者

a useful script

我看不明白是什么意思?

论坛徽章:
0
3 [报告]
发表于 2002-11-19 09:55 |只看该作者

a useful script

也是克隆启动盘
sgi,忙什么去了啊  常回来看看啊

论坛徽章:
0
4 [报告]
发表于 2002-11-21 17:14 |只看该作者

a useful script

谢谢race 把它加入精华区,我经常回来看看的,毕竟对irix还是毕竟怀念的。

论坛徽章:
0
5 [报告]
发表于 2002-11-22 08:11 |只看该作者

a useful script

sgi你已经不再用irix了吗?

论坛徽章:
0
6 [报告]
发表于 2002-11-22 08:19 |只看该作者

a useful script

刚恳了一点点,有一小惑,请说明一下:
echo &quot;\007OK? (n)\c&quot;
       read answer
       case &quot;$answer&quot; {
       y|Y|yes|Yes|YES) &#59;&#59;
       *) echo &quot;\007\n\nAbort&quot;&#59; exit 1&#59;&#59;
       }
有何作用?

论坛徽章:
0
7 [报告]
发表于 2002-11-22 20:43 |只看该作者

a useful script

是一个判断提示,yes就会继续,否则就退出。

论坛徽章:
0
8 [报告]
发表于 2002-11-28 11:48 |只看该作者

a useful script

能够把这个详细的解释一遍吗?
我是CAICAI的 啊,,,,

论坛徽章:
0
9 [报告]
发表于 2002-11-29 00:33 |只看该作者

a useful script

讲了你也不懂.

论坛徽章:
0
10 [报告]
发表于 2002-11-29 23:02 |只看该作者

a useful script

但是我会去用心学习的啊。。
呵呵
虽然偶很CAICAI 。。。
您需要登录后才可以回帖 登录 | 注册

本版积分规则 发表回复

  

北京盛拓优讯信息技术有限公司. 版权所有 京ICP备16024965号-6 北京市公安局海淀分局网监中心备案编号:11010802020122 niuxiaotong@pcpop.com 17352615567
未成年举报专区
中国互联网协会会员  联系我们:huangweiwei@itpub.net
感谢所有关心和支持过ChinaUnix的朋友们 转载本站内容请注明原作者名及出处

清除 Cookies - ChinaUnix - Archiver - WAP - TOP