Login to participate
Storage Management DownloadsRSS

Script to Change the Group ID on a Veritas Disk Group

Kimberley's picture

The following download is provided with permision from author Peter Bousfield.

How to change the group id on a veritas Disk Group

The script below (also attached as .txt file) from creator Peter Bousfield s used to change the diskids and dgid of a given diskgroup.  You will want to do this after taking a BCV copy to ensure that there are not id conflicts. Note diskgroup must be already imported (to get disk group info), and must be able to be deported (ie. volumes not in use, no file systems mounted).

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

#!/bin/ksh

# Authors:    Peter Bousfield, Carl Marino
# Date:        Fri Sep  6 15:13:45 BST 2002
# Version:    1.1
# Description:    This program is used to change the diskids and dgid of a given diskgroup.  You will
#        want to do this after taking a BCV copy to ensure that there are not id conflicts.
#        Note diskgroup must be already imported (to get disk group info), and must be able
#        to be deported (ie. volumes not in use, no file systems mounted).

Me=${0##*/}
FILE="/var/tmp/${Me}-$$"
PATH=/usr/sbin:/bin
DG=$1

if [[ -z ${DG} ]] ; then
    print -u2 "Usage: ${Me} diskgroup"
    exit 1
fi
print "Changing disk/group ID of ${DG} ..."

vxprint -g ${DG} -hmvps > ${FILE}
if [[ ! -s ${FILE} ]] ; then
    print -u2 "\nERROR - no configuration in ${FILE} - aborting!"
    exit 1
fi

print "\nRecreating ${DG} disks with existing regions"
set -A CTD  $(vxprint -g ${DG} -dF '%assoc')
set -A NAME $(vxprint -g ${DG} -dF '%name')
vxdg deport ${DG}
(( i = 0 ))
while (( $i < ${#CTD[*]} )); do
    print "\t- initializing ${CTD[$i]}"
    vxdisk -f init ${CTD[$i]} $(vxdisk list ${CTD[$i]} | nawk '/^public:/ {printf("pub%s pub%s ", $3, $4)} /^private:/ {printf("priv%s priv%s", $3, $4)}')
    (( i = $i + 1 ))
done

print "\nRecreating ${DG} with ${CTD[0]} as ${NAME[0]}"
vxdg init ${DG} ${NAME[0]}=${CTD[0]}
(( i = 1 ))
while (( $i < ${#CTD[*]} )); do
    print "\t- adding disk ${CTD[$i]} as ${NAME[$i]}"
    vxdg -g ${DG} adddisk ${NAME[$i]}=${CTD[$i]}
    (( i = $i + 1 ))
done

print "\nRecreating ${DG} configuration"
vxmake -g ${DG} -d ${FILE}
for vol in $(vxprint -g ${DG} -vF %name) ; do
    print "\t- initializing volume ${vol}"
    vxvol -g ${DG} init active ${vol}
done

print "\n${Me} complete.  Please check and then remove ${FILE}."
exit 0