如果HPUX 11.31操作系统环境下vg00根盘不止一块,而且需要做成了PVG然后再做Mirror Disk镜像.可以使用以下Shell脚本实现自动化实施.
# /usr/bin/sh
##############################################################
#create vg00 PVG mirror shell
##############################################################
disk=/dev/disk/$1
rdisk=/dev/rdisk/$1
disk2=/dev/disk/$2
rdisk2=/dev/rdisk/$2
LOG=/tmp/vg00_mirror.log
echo "\n=====================Start `date \"+%Y-%m-%d %H:%M:%S\"`====================="
#0.create pvg file lvmpvg
lvmbak=/tmp/lvm_bak.`date +%Y%m%d%X`
cp -r /etc/lvm* $lvmbak
echo "VG /dev/vg00" > /etc/lvmpvg
echo "PVG PVG0">> /etc/lvmpvg
vgdisplay -v vg00 |grep "PV Name"|awk '{print $3}'>> /etc/lvmpvg
#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 -f -B $rdisk'_p2' >>$LOG 2>&1
pvcreate $rdisk2 >>$LOG 2>&1
#5.Extend vg to _p2 of the mirror disk, using the block device file of _p2
vgextend vg00 $disk'_p2' >>$LOG 2>&1
vgextend vg00 $disk2 >>$LOG 2>&1
#6.Run mkboot to complete the setup of the disk as a boot disk
mkboot -e -l $disk >>$LOG 2>&1
#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. Add PVG1 to control file lvmpvg as following:
echo "PVG PVG1" >> /etc/lvmpvg
echo "$disk"_p2"" >> /etc/lvmpvg
echo "$disk2" >> /etc/lvmpvg
#8.Run lvextend to mirror each logical volume:
vgdisplay -v vg00|grep "LV Name"|awk '{print $3}'|while read lvname
do
lvchange -s g $lvname >>$LOG 2>&1
lvextend -m 1 $lvname PVG1 >>$LOG 2>&1
done
vgdisplay -v vg00
#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 -h $rdisk
setboot -a $rdisk
echo "\n=====================End `date \"+%Y-%m-%d %H:%M:%S\"`====================="
vg00原有根盘是/dev/disk/disk1和/dev/disk/disk2, 目标是镜像到/dev/disk/disk3和/dev/disk/disk4两块盘上,使用以下命令:
#./vg00_pvg_mirror.sh disk3 disk4