Operating System - HP-UX
1752273 Members
4870 Online
108786 Solutions
New Discussion юеВ

script to collect info from ll /dev/*/group

 
SOLVED
Go to solution
jose da silva
Frequent Advisor

script to collect info from ll /dev/*/group

Hello , I need assistance for creating a script to extract info from the ll /dev/*/group to create the directories of the specific vgs under /dev and also extract the character device information to put it in their respective indicated vg directory.
7 REPLIES 7
James R. Ferguson
Acclaimed Contributor

Re: script to collect info from ll /dev/*/group

Hi Jose:

Your objective isn't clear. For volume group creation (prior to recent version of 11,31 where the vg_name directory and its 'group' file are created automatically) you would do (for version-1 LVM) :

# mkdir /dev/vgXX
# mknod /dev/vgXX/group c 64 0xNN0000

After this step a 'vgcreate' would be done. It's the subsequent creation of logical volumes with 'lvcreate' that generate the block and raw (character) device files beneath '/dev/vgXX'.

Hence, you don't need a script in the fashion of your question. Again, your objective isn't clear.

Regards!

...JRF...
James R. Ferguson
Acclaimed Contributor
Solution

Re: script to collect info from ll /dev/*/group

Hi (again) Jose:

Upon reflection, I think this thread relates directly to this one:

http://forums.itrc.hp.com/service/forums/questionanswer.do?threadId=1447193

...and that we are dealing with pre-11.31 systems using LVM version 1.0 where it is necessary to manually make the 'group' directory prior to a 'vgimport'. In this context, I assume that you want to 'vgexport' volume groups from one server; and 'vgimport' then on another. Two scripts (below) should help. Run the first script; copy the '/tmp/*.map' files and the '/tmp/VGINFO' file to the target server; and execute the second script there.

# cat ./pass1
#!/usr/bin/sh
set -u
VGINFO=/tmp/VGINFO
rm -f ${VGINFO}
VGS=$(vgdisplay|awk '/VG Name/ {print $3}')
for VG in ${VGS}
do
MYMAP="/tmp/$(basename ${VG}).map"
echo vgexport -v -p -s -m ${MYMAP} ${VG}
MINOR=$(ls -l ${VG}/group | awk '{print $6}')
echo "${VG} ${MINOR} ${MYMAP}" >> ${VGINFO}
done
exit 0

# cat ./pass2
#!/usr/bin/sh
set -u
VGINFO=/tmp/VGINFO
while read VG MINOR MYMAP X
do
echo mkdir ${VG}
echo mknod ${VG}/group c 64 ${MINOR}
echo vgimport -v -s -m ${MYMAP} ${VG}
done < ${VGINFO}
exit 0

...REMOVE the 'echo' when you are satisfied with the behavior. Running the scripts with it shows this (on a test server of mine):

# ./pass1
vgexport -v -p -s -m /tmp/vg00.map /dev/vg00
vgexport -v -p -s -m /tmp/vg01.map /dev/vg01

# cat /tmp/VGINFO
/dev/vg00 0x000000 /tmp/vg00.map
/dev/vg01 0x010000 /tmp/vg01.map

# ./pass2
mkdir /dev/vg00
mknod /dev/vg00/group c 64 0x000000
vgimport -v -s -m /tmp/vg00.map /dev/vg00
mkdir /dev/vg01
mknod /dev/vg01/group c 64 0x010000
vgimport -v -s -m /tmp/vg01.map /dev/vg01

Regards!

...JRF...
jose da silva
Frequent Advisor

Re: script to collect info from ll /dev/*/group

Hello James

Thanks for the reply. Yes you are correct to say that you do not need it for HP-UX 11.31, and it would only apply for HP-UX 11i and below. This script would be used on HP-UX 11.00 to create the directories before the vgimport.

Thanks
jose da silva
Frequent Advisor

Re: script to collect info from ll /dev/*/group

Hello James

Yes it is exactly what I wanted.This will make things easier. Thanks will be assigning points.

Thanks once again.

Warm Regards
Jose da Silva
James R. Ferguson
Acclaimed Contributor

Re: script to collect info from ll /dev/*/group

Hi (again) Jose:

You probably want to skip exporting vg00 after all, so the first script could look like:

# cat ./pass1
#!/usr/bin/sh
set -u
VGINFO=/tmp/VGINFO
rm -f ${VGINFO}
VGS=$(vgdisplay|awk '/VG Name/ {print $3}')
for VG in ${VGS}
do
[ "${VG}" = "/dev/vg00" ] && continue
MYMAP="/tmp/$(basename ${VG}).map"
echo vgexport -v -p -s -m ${MYMAP} ${VG}
MINOR=$(ls -l ${VG}/group | awk '{print $6}')
echo "${VG} ${MINOR} ${MYMAP}" >> ${VGINFO}
done
exit 0

...Remember that you can always skip the 'vgimport' for a volume group by removing its information from the '/tmp/VGINFO' created by './pass1' before running './pass2'.

You might also want to activate your volume groups after their import with 'vgchange'.

Regards!

...JRF...
jose da silva
Frequent Advisor

Re: script to collect info from ll /dev/*/group

Hello James

Thanks for the last update, yes I do not want to export vg00. Will use your last recomendation.

Warm Regards,
Jose
Raj D.
Honored Contributor

Re: script to collect info from ll /dev/*/group

Jose,
From the first question I understand you are looking for some script ,that will help recreating /dev/vg and group files from the existing data captured with ll /dev/*/group :

Check this out:


#example : suppose you want to generate the commands for vg01 and vg02 for recreation.
# This is useful for storage migration etc:
# You mkdir and mknod commands will be ready for one shot execution:

ls -lrt /dev/*/group | grep -e vg01 -e vg02 | awk '{print "mkdir " $10 }' | sed 's/\/group//'

ls -lrt /dev/*/group | grep -e vg01 -e vg02 | awk '{print "mknod " $10 "\t" " c 64 " $6 }'


Enjoy, Have fun!,
Raj.
" If u think u can , If u think u cannot , - You are always Right . "