1834220 Members
2504 Online
110066 Solutions
New Discussion

Mirror rootvg

 
SOLVED
Go to solution
Carlos Munoz Lopez
Frequent Advisor

Mirror rootvg

Hi guys! I have a HP 5470 server runnign HP-UX 11i. In this server I have two internal disks, one is used by the operating system, the other one is not used by any VG. I want to use this empty disk to mirror the operating system. What are the specific steps I have to follow to achieve this?? I have MirrorDiskUX already installed in the system. I would like some help on this. Thanks in advanced!!
8 REPLIES 8
Rick Garland
Honored Contributor
Solution

Re: Mirror rootvg

Here is a procedure for setting mirroring that also covers setting the boot disk.


pvcreate -B /dev/rdsk/c1t0d0 #use real disk

mkboot -l /dev/rdsk/c1t0d0
mkboot -a "hpux -lq (;0)/stand/vmunix" /dev/rdsk/c1t0d0 # use real disk


# mkboot -b /usr/sbin/diag/lif/updatediaglif -p ISL -p AUTO -p HPUX -p PAD -p LABEL /dev/rdsk/c?t?d?

If you are running 64-bit OS:

# mkboot -b /usr/sbin/diag/lif/updatediaglif2 -p ISL -p AUTO -p HPUX -p PAD -p LABEL /dev/rdsk/c?t?d?


vgextend /dev/vg00 /dev/dsk/c1t0d0 # same thing
lvextend -m 1 /dev/vg00/lvol1 /dev/dsk/c1t0d0

# real disk. repeat for other lvols

lvlnboot -r /dev/vg00/lvol3 # root fs /
lvlnboot -s /dev/vg00/lvol2 #swap
lvlnboot -d /dev/vg00/lvol2 #swap/dump
lvlnboot -b /dev/vg00/lvol1
lvlnboot -R
lvlnboot -v
setboot
setboot -a 52.1.0 # second disk
Carlos Munoz Lopez
Frequent Advisor

Re: Mirror rootvg

Can I do this procedure online or maintenance mode???
Pete Randall
Outstanding Contributor

Re: Mirror rootvg

Online.


Pete

Pete
Rick Garland
Honored Contributor

Re: Mirror rootvg

Do be aware, I have some actual system values in my post. Do not use these values, such as the disk address.

Carlos Munoz Lopez
Frequent Advisor

Re: Mirror rootvg

I was just checking that, when you use setboot -a [alternate_path] where do I get this value for my current system??
Rick Garland
Honored Contributor

Re: Mirror rootvg

ioscan
Carlos Munoz Lopez
Frequent Advisor

Re: Mirror rootvg

Thank you guys! I appreciate your help.
Robert Bennett_3
Respected Contributor

Re: Mirror rootvg

Carlos - here's a nice little script to do it all. Name the script what you like (OSmirror) then do an ioscan to get the address of the disk you want to mirror vg00 to, then run script OSmirror cXtYdZ.

This is tried and true.

Hope it helps

B

#!/usr/bin/ksh

VG=$( bdf |grep /stand|awk -F\/ '{print $3}')
FINDPRIMDSK=$(vgdisplay -v /dev/$VG|grep "PV Name"| awk -F\/ '{print $NF}')
OSCHECK=$(uname -r | awk -F\. '{print $2}')

# Checking to see if the command was executed with the unused disk device file name

if [ -z "$1" ];then
echo "/nUsage: OSMirror Example: OSMirror c#t#d# "
exit 1
else
# Checking to see if the disk is a block device file & is not in lvmtab.
if [ -b "/dev/dsk/$1" ];then
strings /etc/lvmtab |grep -q /dev/dsk/$1 > /dev/null 2>&1
if [ $? -ne 0 ];then
NEWDISK=$1
else
echo "/nError: The disk device $1 is already in use"
exit 1
fi
else
echo "/nError: The disk device $1 is not a valid block device"
exit 1
fi
fi

# Testing to see if the Alternate disk is equal to or larger than the root disk.

PRIMDSK=$(diskinfo /dev/rdsk/$FINDPRIMDSK|grep size: | awk '{print $2}')
ALTDSK=$(diskinfo /dev/rdsk/$1|grep size:|awk '{print $2}')

if [ $PRIMDSK -gt $ALTDSK ];then
echo "\n Error: Selected disk is smaller than the root disk"
exit 1
else
NEWDISK=$1
fi


# Creating the raw disk as a bootable device
pvcreate -B -f /dev/rdsk/$NEWDISK
if [ $? -ne 0 ];then
echo "\nError: pvcreate failed"
exit 1
fi
mkboot /dev/rdsk/$NEWDISK
if [ $? -ne 0 ];then
echo "\nError: mkboot failed"
exit 1
fi
mkboot -a "hpux -lq" /dev/rdsk/$NEWDISK
if [ $? -ne 0 ];then
echo "\nError: mkboot -a failed"
exit 1
fi

#adding the disk to the existing OS volume group
vgextend $VG /dev/dsk/$NEWDISK
if [ $? -ne 0 ];then
echo "\nError: vgextend failed"
exit 1
fi

#Collecting the list of root logical volumes in order to be used for mirroring.

LVOLLIST=$( bdf |grep $VG|awk '{print $1}'|awk -F\/ '{print $NF}')
SWAP=$(swapinfo |grep $VG |head -1|awk '{print $NF}'|sort|awk -F\/ '{print $NF}'
)
LVOLLIST="$LVOLLIST $SWAP"
for i in $LVOLLIST;do
echo $i | sed 's/lvol//' >> /tmp/rootmirror_$$
done
sort -n -k1 /tmp/rootmirror_$$ > /tmp/rootmirror1_$$
mv /tmp/rootmirror1_$$ /tmp/rootmirror_$$

LVOLLIST=$(cat /tmp/rootmirror_$$)

# Creating the Mirror of the logical volumes on the new disk
for i in $LVOLLIST;do
lvextend -m 1 /dev/$VG/lvol$i /dev/dsk/$NEWDISK
done

#Finding the logical volume group that / is mounted on.
# Double checking with bdf and fstab.

RLVOL1=$(bdf|grep /$ |awk '{print $1}')
RLVOL2=$(grep " / " /etc/fstab | awk '{print $1}')
RLVOL3=$(grep " /stand " /etc/fstab | awk '{print $1}')
if [ "$RLVOL1" = "$RLVOL2" ];then
lvlnboot -r $RLVOL1
lvlnboot -b $RLVOL3
lvlnboot -s /dev/$VG/$SWAP
else
echo "Error: Could not determine the correct logical volume for / "
exit 1
fi

#cleanup
rm /tmp/rootmirror*

#Setting the Mirror as the alternate bootable device
HWPATH=$( ioscan /dev/dsk/$NEWDISK | tail -1 |awk '{print $1}')
setboot -a $HWPATH

# LIFFILE variable set for 32 or 64 bit systems. updatediaglif2 is used with
# 64 bit systems.
#
RDISK=/dev/rdsk/$NEWDISK
if [ $OSCHECK = "11" ]
then
BITLEVEL=`getconf KERNEL_BITS`
if [ $BITLEVEL = "32" ]
then
LIFFILE=/usr/sbin/diag/lif/updatediaglif
elif [ $BITLEVEL = "64" ]
then
LIFFILE=/usr/sbin/diag/lif/updatediaglif2
else
echo "ERROR: could not determine the whether the OS is 32 or 64 bit"
echo "Run getconf KERNEL_BITS to determine if the command is working"
echo "properly. A 32 or 64 bit level should be displayed"
echo "ODE not copied to $ALTROOT lif files"
fi
else
LIFFILE=/usr/sbin/diag/lif/updatediaglif
fi

# Verify that the updatediaglif file exists
# ISL, AUTO, HPUX, PAD, and LABEL are not overwriten during the copy.
# To add protection to any other lif files add -p "lif file" to the
# mkboot command below
if [ $? = 0 ]
then
if [ -f $LIFFILE ]
then
mkboot -b $LIFFILE -p ISL -p AUTO -p HPUX -p PAD -p LABEL $RDISK
if [ $? -ne 0 ]
then
echo "The mkboot command was not successful"
else
echo "mkboot copy to $RDISK successful"
fi
else
echo "The $LIFFILE does not exist. ODE not copied to $ALTROOT"
exit 1
fi
else
exit 1
fi
"All there is to thinking is seeing something noticeable which makes you see something you weren't noticing which makes you see something that isn't even visible." - Norman Maclean