Operating System - HP-UX
1754016 Members
7578 Online
108811 Solutions
New Discussion юеВ

Associate VGID with Volume Group Name

 
SOLVED
Go to solution
Richard Ross
Regular Advisor

Associate VGID with Volume Group Name

For curiosity's sake,If I retrieve the vgid directly from a disk, is there any way to find out the Volume Group name that's assocated with the vgid? Yes .. I know about vgexport -s to create a map that includes the vgid, but was wandering if there was another way.

For example,

vgid=283173133ec80dbe = vg00

Thanks
11 REPLIES 11
Jean-Louis Phelix
Honored Contributor

Re: Associate VGID with Volume Group Name

No way ... You can even change the vgid using vgchgid command without changing lvmtab or special files. During activation, the only check done on disks is that all PV in a vg have the same vgid, that all ...

Regards.
It works for me (┬й Bill McNAMARA ...)
Bruno Vidal
Respected Contributor

Re: Associate VGID with Volume Group Name

Hi,
Yes it is possible, this information vgid <-> VG is kept in /etc/lvmtab. But it is not really easy to retrieve it:
For example:
#echo "0x40C?2X" | adb /tmp/lvmtab
40C: 2096147D 3AB1ED17
You have the vgid just before the first disk of the vg. You have to write a small c programm to do that. The last solution is to directly retrieve the vgid on the device itself, it is always at the same place:
#echo "0x0002010?2X" | adb /dev/dsk/c8t2d0
2010: 2096147D 3AB1ED17

Good luck
James R. Ferguson
Acclaimed Contributor

Re: Associate VGID with Volume Group Name

Hi Richard:

To add to the information already provided, remember that the very way to rename a volume group is to first 'vgexport' it [which removes the '/dev/vgXX' structures from the server and purges '/etc/lvmtab' of the VG information]. Having done this, you create a new directory representing the new VG name (e.g. /dev/myvg) and a group file with a unique minor number of your choice, and 'vgimport' the appropriate physical disk [either by matching the VGID or by specifying the actual physical disks].

Thus, the *name* of a volume group is "known" only through the device directory structure, and is not recorded on the physical disk(s) comprising the volume group.

Regards!

...JRF...
Jean-Louis Phelix
Honored Contributor
Solution

Re: Associate VGID with Volume Group Name

Hi,

I'm very sorry but Bruno (who is 2 meters away from me ...) is perfectly rigth. vgchgid must be done BEFORE importing a vg. One of my colleagues wrote a long time ago a tool to read the lvmtab file. I give you a simplified version which is more beautiful than 'strings /etc/lvmtab and also give you the required vgid.

Regards.
It works for me (┬й Bill McNAMARA ...)
Dietmar Konermann
Honored Contributor

Re: Associate VGID with Volume Group Name

... and in the case you need something "handy":

strings -t d /etc/lvmtab |
grep /dev |
grep -v /dev/dsk |
while read offset path; do
xd -An -j$(($offset+1024)) -N8 -tuL /etc/lvmtab |
read vgid1 vgid2
echo $path $vgid1-$vgid2
done

Best regards...
Dietmar.
"Logic is the beginning of wisdom; not the end." -- Spock (Star Trek VI: The Undiscovered Country)
malay boy
Trusted Contributor

Re: Associate VGID with Volume Group Name

sorry for being sooo naive.what's the use of knowing the vgid?.Any specific used for vgid.

regards
mB
There are three person in my team-Me ,myself and I.
Dietmar Konermann
Honored Contributor

Re: Associate VGID with Volume Group Name

Imagine, you have a disk and need to know, if it's part of an configured volume group.

You look at the disk to get the VGID, e.g.:

# echo "0d8208?UU" | adb /dev/dsk/c11t0d0
2010: 3216063718 1046873340


Then you look at the VGID of the lvmtab, e.g. using the script above:


/dev/vg00 3216063718-1052129048
/dev/vgtobi 3216063718-1008239346
/dev/vgignite 3216063718-1006159972
/dev/vgoracle 3216063718-1012832752
/dev/vg03 3216063718-1052471874
/dev/vgmichael 3216063718-1053943064
/dev/vgheiko 3216063718-1046873340

And now you know that the disk is part of /dev/vgheiko. This is especially useful in a SAN, where lots of systems potentially use the disk.

BTW, here is another way to look at the VGID:

# echo "0d8208?UY" | adb /dev/dsk/c11t0d0
2010: 3216063718 2003 Mar 5 15:09:00

# uname -i
3216063718

You see that the vgcreate was issued on Mar 5 from this system.

Same applies for the PVID, which corresponds to the pvcreate timestamp.

# echo "0d8200?UY" | adb /dev/dsk/c11t0d0
2008: 3216063718 2002 Mar 11 14:36:31


Best regards...
Dietmar.
"Logic is the beginning of wisdom; not the end." -- Spock (Star Trek VI: The Undiscovered Country)
Richard Ross
Regular Advisor

Re: Associate VGID with Volume Group Name

Guys,

Thanks for all the responses. Dietmar's conclusion on why this is useful was right on mark and the script that Jean-Louis supplied makes this an easy task. Good info to have, just incase HP/UX renames the instances of the disk and you need to know which (if any) volume group that disk belonged to.

Thanks again
Richard Ross
Regular Advisor

Re: Associate VGID with Volume Group Name

Jean-Louis

I'm receiving the following when trying to compile the c program you supplied:

cc: "lvmtab.c", line 103: warning 527: Integral value implicitly converted to pointer in assignment.

cc: "lvmtab.c", line 103: warning 563: Argument #1 is not the correct type.

Can you help?

Thanks