msgbartop
Tips and Tricks site for advanced HP-UX Engineers
msgbarbottom

09 Jun 09 System mirroring script

This was taken off of itrc forums. It may need some adjustment.

#!/bin/ksh

PARTITION_FILE=/var/tmp/partition_file

# define primary and mirror disks

# the format is:
# PRI_DISK=cXtXdX
# PRI_DISK=cXtXdX

PRI_DISK=c2t1d0
MIR_DISK=c3t0d0

echo
echo “PRIMARY DISK = /dev/dsk/$PRI_DISK”
echo “MIRROR  DISK = /dev/dsk/$MIR_DISK”
echo
echo If the above is correct, hit enter to continue echo If not correct, hit control-C to quit echo

echo
echo “Creating partition file /tmp/$PARTITION_FILE”
echo

cat <<EOF > $PARTITION_FILE
3
EFI 500MB
HPUX 100%
HPSP 400MB
EOF

# create system, OS and  service partitions

echo
echo idisk -wf $PARTITION_FILE /dev/rdsk/$MIR_DISK echo

idisk -wf $PARTITION_FILE /dev/rdsk/$MIR_DISK

# Create device files needed for the new partitions

insf -eC disk

# Verify the parition table

echo idisk /dev/rdsk/$MIR_DISK
idisk /dev/rdsk/$MIR_DISK

# Initialize the EFI partition for use

echo efi_fsinit -d /dev/rdsk/${MIR_DISK}s1 efi_fsinit -d /dev/rdsk/${MIR_DISK}s1

# Populate the /efi/hpux directory in the new EFI system partition

echo mkboot -e -l /dev/rdsk/$MIR_DISK
mkboot -e -l /dev/rdsk/$MIR_DISK

# Changing the auto file for the mirror to boot without quorum # Note: Using s1

echo “boot vmunix -lq”
echo “boot vmunix -lq”           > /tmp/AUTO.lq
efi_cp -d /dev/rdsk/${MIR_DISK}s1  /tmp/AUTO.lq   /EFI/HPUX/AUTO

# Verify the contents of the auto file on the primary and the mirror.
# Note: Using s1

echo  Verify the contents of the auto file on the primary and the mirror.
echo
efi_cp -d /dev/rdsk/${PRI_DISK}s1 -u  /EFI/HPUX/AUTO  /tmp/AUTO.pri efi_cp -d /dev/rdsk/${MIR_DISK}s1 -u  /EFI/HPUX/AUTO  /tmp/AUTO.alt

echo cat /tmp/AUTO.pri
echo
cat /tmp/AUTO.pri

echo cat /tmp/AUTO.alt
echo
cat /tmp/AUTO.alt

# add the new paritition to vg00
# Note: Using s2

echo  add the new paritition to vg00
echo  Note: Using s2

echo pvcreate  -B /dev/rdsk/${MIR_DISK}s2

pvcreate  -B /dev/rdsk/${MIR_DISK}s2

#pvcreate  -fB /dev/rdsk/${MIR_DISK}s2

vgextend vg00 /dev/dsk/${MIR_DISK}s2

# Add the new disk to /stand/bootconf
# Note: Using s2

echo  “Add the mirror disk $MIR_DISK to /stand/bootconf”
echo “l  /dev/dsk/${MIR_DISK}s2” >> /stand/bootconf

echo  Mirroring all Logical Volumes in /dev/vg00, lvol1 – lvol8 echo echo

echo “Mirroring /stand”
echo lvextend -m 1 /dev/vg00/lvol1  /dev/dsk/${MIR_DISK}s2
lvextend -m 1 /dev/vg00/lvol1  /dev/dsk/${MIR_DISK}s2 echo

echo “Mirroring swap”
echo lvextend -m 1 /dev/vg00/lvol2  /dev/dsk/${MIR_DISK}s2
lvextend -m 1 /dev/vg00/lvol2  /dev/dsk/${MIR_DISK}s2 echo

echo “Mirroring root”
echo lvextend -m 1 /dev/vg00/lvol3  /dev/dsk/${MIR_DISK}s2
lvextend -m 1 /dev/vg00/lvol3  /dev/dsk/${MIR_DISK}s2 echo

echo “Mirroring /home”
echo lvextend -m 1 /dev/vg00/lvol4  /dev/dsk/${MIR_DISK}s2
lvextend -m 1 /dev/vg00/lvol4  /dev/dsk/${MIR_DISK}s2 echo

echo “Mirroring /opt”
echo lvextend -m 1 /dev/vg00/lvol5  /dev/dsk/${MIR_DISK}s2
lvextend -m 1 /dev/vg00/lvol5  /dev/dsk/${MIR_DISK}s2 echo

echo “Mirroring /tmp”
echo lvextend -m 1 /dev/vg00/lvol6  /dev/dsk/${MIR_DISK}s2
lvextend -m 1 /dev/vg00/lvol6  /dev/dsk/${MIR_DISK}s2 echo

echo “Mirroring /usr”
echo lvextend -m 1 /dev/vg00/lvol7  /dev/dsk/${MIR_DISK}s2
lvextend -m 1 /dev/vg00/lvol7  /dev/dsk/${MIR_DISK}s2 echo

echo “Mirroring /var”
echo lvextend -m 1 /dev/vg00/lvol8  /dev/dsk/${MIR_DISK}s2
lvextend -m 1 /dev/vg00/lvol8  /dev/dsk/${MIR_DISK}s2 echo

Leave a Comment

You must be logged in to post a comment.

sidebarbottom
sidebartop
sidebarbottom
WhatsApp chat