HPUX 11.31操作系统环境下用Shell脚本自动做vg00根盘镜像
##############################################################
# create vg00 mirror shell
##############################################################
# /usr/bin/sh
disk=/dev/disk/$1
rdisk=/dev/rdisk/$1
LOG=/tmp/vg00_mirror.log
echo "\n=====================Start `date \"+%Y-%m-%d %H:%M:%S\"`====================="
#1. Create a temporary file /tmp/partitionfile
echo "3" > /tmp/partitionfile
echo "EFI 500MB" >>/tmp/partitionfile
echo "HPUX 100%" >>/tmp/partitionfile
echo "HPSP 400MB" >>/tmp/partitionfile
#2.Use the file created in Step 1 to partition the mirror disk with idisk:
echo yes|idisk -wf /tmp/partitionfile $rdisk >>$LOG 2>&1
#3.insf newly-created partitions
LUN=`ioscan -m lun $rdisk|grep esdisk|awk '{print $3}'` >>$LOG 2>&1
insf -eH $LUN >>$LOG 2>&1
idisk -p $rdisk >>$LOG 2>&1
#4.Run the pvcreate command on the character device file for the HP-UX (second) partition
#pvcreate -B $rdisk'_p2'
pvcreate -f -B $rdisk'_p2'
#5.Extend vg to _p2 of the mirror disk, using the block device file of _p2
vgextend vg00 $disk'_p2'
#6.Run mkboot to complete the setup of the disk as a boot disk
mkboot -e -l $disk
#7.Create a temporary AUTO file and use the efi_cp command to copy it to the mirror
echo "boot vmunix -lq">/tmp/AUTO
efi_cp -d $rdisk'_p1' /tmp/AUTO /EFI/HPUX/AUTO >>$LOG 2>&1
#8.Run lvextend to mirror each logical volume:
vgdisplay -v vg00
vgdisplay -v vg00|grep "LV Name"|awk '{print $3}'|while read lvname
do
lvextend -m 1 $lvname >>$LOG 2>&1
done
#9.Run the lvlnboot commands to reestablish LVM
lvlnboot -b /dev/vg00/lvol1 /dev/vg00 >>$LOG 2>&1
lvlnboot -r /dev/vg00/lvol3 /dev/vg00 >>$LOG 2>&1
lvlnboot -s /dev/vg00/lvol2 /dev/vg00 >>$LOG 2>&1
lvlnboot -d /dev/vg00/lvol2 /dev/vg00 >>$LOG 2>&1
lvlnboot -Rv >>$LOG 2>&1
#10.Add the block device file of _p2 of the mirror to the file /stand/bootconf
echo "l $disk"_p2"">> /stand/bootconf
#11.Set the alternate boot path to the mirror_disk
setboot -a $rdisk
banner " end"
echo "\n=====================End `date \"+%Y-%m-%d %H:%M:%S\"`====================="
vg00原有根盘是/dev/disk/disk1,现在需要镜像到/dev/disk/disk2上,使用以下命令:
#./vg00_mirror.sh disk2