免费注册 查看新帖 |

Chinaunix

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

Poor man's disk mirroring [复制链接]

论坛徽章:
7
荣誉会员
日期:2011-11-23 16:44:17水瓶座
日期:2013-08-28 21:20:16丑牛
日期:2013-10-02 21:01:462015年迎新春徽章
日期:2015-03-04 09:54:45操作系统版块每日发帖之星
日期:2016-06-05 06:20:0015-16赛季CBA联赛之吉林
日期:2016-06-20 08:24:0515-16赛季CBA联赛之四川
日期:2016-08-18 15:02:02
跳转到指定楼层
1 [收藏(0)] [报告]
发表于 2006-04-08 11:45 |只看该作者 |倒序浏览
#!/bin/ksh
#
# Orf Gelbrich - orf@gelbrich.com
# 7/6/2001
# Script mirrors c0t0d0s0 (disk1) to c0t1d0s0 (disk2)
# Script mirrors c0t0d0s1 (disk1) to c0t1d0s1 (disk2)
# Script mirrors c0t0d0s3 (disk1) to c0t1d0s3 (disk2)
# Script mirrors c0t0d0s4 (disk1) to c0t1d0s4 (disk2)
#
export f1="/usr/local/etc/mirrorbox.log"
export line="------------------------------------------------------------------"
#
# set up the log file
#
echo $line  >> $f1
date >> $f1
echo $line  >> $f1
#
# find out which disk we are on
#
export disk1=`df -k |  grep c0t | head -1 | awk '{ FS="/"} { print $4}' | awk '{print $1}'`
echo "We are on this disk : $disk1" >> $f1
if [ $disk1 != "c0t0d0s0" ] ; then
        echo "Error this is not disk 1 = $disk1" >> $f1
        exit 1
fi
#
# copy the two partitons
#
dd if=/dev/dsk/c0t0d0s0 of=/dev/dsk/c0t1d0s0 bs=524288   2>&1 >> $f1 2>&1
dd if=/dev/dsk/c0t0d0s1 of=/dev/dsk/c0t1d0s1 bs=524288   2>&1 >> $f1 2>&1
dd if=/dev/dsk/c0t0d0s3 of=/dev/dsk/c0t1d0s3 bs=524288   2>&1 >> $f1 2>&1
dd if=/dev/dsk/c0t0d0s4 of=/dev/dsk/c0t1d0s4 bs=524288   2>&1 >> $f1 2>&1
#
# copy the boot block to the spare disk
#
cd /usr/platform/`/usr/bin/uname -i`/lib/fs/ufs >> $f1
installboot bootblk /dev/rdsk/c0t1d0s0 >> $f1
#
# unmount the file systems
#
umount /mnt1 >> $f1
umount /mnt2 >> $f1
umount /mnt3 >> $f1
umount /mnt4 >> $f1
#
# run fsck on the spare file systems
#
fsck -y /dev/dsk/c0t1d0s0 >> $f1
fsck -y /dev/dsk/c0t1d0s1 >> $f1
fsck -y /dev/dsk/c0t1d0s3 >> $f1
fsck -y /dev/dsk/c0t1d0s4 >> $f1
#
# mount the spare disk slice 0 and 3
#

if [ ! -d /mnt1 ]; then
        mkdir /mnt1 >> $f1
fi
if [ ! -d /mnt2 ]; then
        mkdir /mnt2 >> $f1
fi
if [ ! -d /mnt3 ]; then
        mkdir /mnt3 >> $f1
fi
if [ ! -d /mnt4 ]; then
        mkdir /mnt4 >> $f1
fi
mount -f ufs /dev/dsk/c0t1d0s0 /mnt1 >> $f1
mount -f ufs /dev/dsk/c0t1d0s1 /mnt2 >> $f1
mount -f ufs /dev/dsk/c0t1d0s3 /mnt3 >> $f1
mount -f ufs /dev/dsk/c0t1d0s4 /mnt4 >> $f1
#
# fix the vfstab file on disk2  (t0 -> t2)
#
cd /mnt1/etc >> $f1
cp vfstab vfstab.old >> $f1
sed 's/t0/t1/g' vfstab > vfstab.new
cp vfstab.new vfstab >> $f1
cd /
#
# close out the log file
#
echo $line  >> $f1
date >> $f1
echo $line  >> $f1

exit 0



本文来自ChinaUnix博客,如果查看原文请点:http://blog.chinaunix.net/u/43/showart_96846.html
您需要登录后才可以回帖 登录 | 注册

本版积分规则 发表回复

  

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

清除 Cookies - ChinaUnix - Archiver - WAP - TOP