Re: /etc/lvmtab file format/structure (1050 Views)
Reply
Occasional Visitor
Elavarasan Sowrinaidu
Posts: 1
Registered: ‎02-01-2011
Message 1 of 9 (1,050 Views)

/etc/lvmtab file format/structure

Hello All,

I want to read the /etc/lvmtab file programmatically to get the vgid, pvid. Can some body tell me how its structured? Or, if anyone has a sample program/script would help me a lot.

thanks for your time,
Prince
Please use plain text.
Honored Contributor
Manix
Posts: 518
Registered: ‎12-03-2010
Message 2 of 9 (1,050 Views)

Re: /etc/lvmtab file format/structure

[ Edited ]

lvmtab dies not have PVID /VGID ,you may read the file using "strings /etc/lvmtab"

Commnand for VGID /PVID

echo "0x2008?4D" | adb /dev/dsk/c-t-d-

It will report 5 columns starting with
2008: <5th column=VGID>

You may load a script "lvminfo" to get VGID/PVID



http://h30499.www3.hp.com/t5/System-Administration/HOW-to-know-the-PVID-and-VGID-of-disk/m-p/4620707...

HP-UX been always lovable - Mani Kalra
Please use plain text.
Honored Contributor
Manix
Posts: 518
Registered: ‎12-03-2010
Message 3 of 9 (1,050 Views)

Re: /etc/lvmtab file format/structure

[ Edited ]

do "strings /etc/lvmtab" -its binary file , i don`t think it has PVID /VGID.

echo "0x2008?4D" | adb /dev/dsk/c-t-d-

It will report 5 columns starting with
2008: <5th column=VGID>

Load the script "lvminfo" to get the best information

http://h30499.www3.hp.com/t5/System-Administration/HOW-to-know-the-PVID-and-VGID-of-disk/m-p/4620707...

HP-UX been always lovable - Mani Kalra
Please use plain text.
Honored Contributor
Matti_Kurkela
Posts: 6,271
Registered: ‎12-02-2001
Message 4 of 9 (1,050 Views)

Re: /etc/lvmtab file format/structure

Manix, take a hex dump of the lvmtab file and compare it to the output of Bill Hassell's "showLVMinfo" script. You'll find the CPUID and VGID values *are* included in the lvmtab file in binary format. With a quick glance, the PVIDs don't seem to be included.

For example: "od -t x1a /etc/lvmtab".

On one of my systems, the showLVMinfo reports this:

# ./showLVMinfo /dev/rdsk/c2t2d0

Local CPU ID = 580706587, hex value=0x229ce11b

/dev/rdsk/c2t2d0:
CPUID=0x229ce11b (580706587), VGID 0x48845169, PVID 0x48845169

The relevant part of the output of the od command:

0002000 0 0 0 0 0 0 0 0 0 0 0 0 22 9c e1 1b
nul nul nul nul nul nul nul nul nul nul nul nul " fs a esc
0002020 48 84 51 69 0 0 0 0 0 0 0 0 0 2 0 0
H eot Q i nul nul nul nul nul nul nul nul nul stx nul nul
0002040 0 0 0 0 0 0 0 0 0 0 2f 64 65 76 2f 64
nul nul nul nul nul nul nul nul nul nul / d e v / d
0002060 73 6b 2f 63 32 74 32 64 30 0 0 0 0 0 0 0
s k / c 2 t 2 d 0 nul nul nul nul nul nul nul
0002100 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
nul nul nul nul nul nul nul nul nul nul nul nul nul nul nul nul

MK
MK
Please use plain text.
Honored Contributor
Manix
Posts: 518
Registered: ‎12-03-2010
Message 5 of 9 (1,050 Views)

Re: /etc/lvmtab file format/structure

Thanks Mk ,
I was not sure about it ,so that is another way to get that info apart from Bill`s script.

Thanks
Manix
HP-UX been always lovable - Mani Kalra
Please use plain text.
Acclaimed Contributor
James R. Ferguson
Posts: 21,184
Registered: ‎07-06-2000
Message 6 of 9 (1,050 Views)

Re: /etc/lvmtab file format/structure

Hi Prince:

The '/etc/lvmtab' is a binary data file. Hence, the 'stings' command only makes a "best attempt" to produce printable characters from groups of 4-characters.

Aside from the device file and volume group names, a 'strings /etc/lvmtab' will not generally expose much meaningful data. As Matti noted, an octal (or hex) dump will be more informative.

The file actually contains the physical device paths for each volume group defined to the system. In addition, the VGID (Volume Group Identification) and some other state information about each volume group is recorded.

One way to decode the file is (knowing its internal layout) to use Perl. I did it some years ago as an exercise but no longer have the script.

The best way, in my opinion, to evaluate PVID and VGID information is to read the physical disk itself as any of the aforementioned links will show. Remember that a 'vgexport' of a volume group will remove it from '/etc/lvmtab'. You still might want to assess something more about its origin, though, and the PVID and VGID signatures are there on the disk for the reading.

Regards!

...JRF...
Please use plain text.
Honored Contributor
Bill Hassell
Posts: 14,178
Registered: ‎05-29-2000
Message 7 of 9 (1,050 Views)

Re: /etc/lvmtab file format/structure

Its always important to save a mapfile for every VG using the -p -s -m options. The man page says shared (cluster) mode but really should say -s = serial number. It makes no difference whether PVs are shared or not -- you need the VGID in order to reconstruct (vgimport) or simply identify loose LUNs and alternate paths. showLVMinfo has the xd command with offset to find the LVMREC headers on any disk. lvmtab has never been openly documented and really represents just a snapshot of the VGs. Every PV that has been (or is) part of a VG will have the LVMREC at offset 2000 and that's how vgscan and vgimport find all the disks.
Please use plain text.
Honored Contributor
Emil Velez
Posts: 1,450
Registered: ‎05-17-2000
Message 8 of 9 (1,050 Views)

Re: /etc/lvmtab file format/structure

I got this from a customer that was writing it. Intersting little script

Reemmber with 11iv2 we have LVMv2 which is totally different and has a different LVM header.

cat display_lvmids
#!/usr/bin/sh
#
# $1 should be /dev/rdsk/c_t_d_ or /dev/rdisk/diskxxxx
#
typeset RDEV=$1

KIND=`xd -An -j 8192 -N8 -tc ${RDEV} 2> /dev/null | xargs`

if [ "$KIND" = "L V M R E C 0 1" ]; then
INFO=`xd -An -j8200 -N16 -tx ${RDEV}`
PVID=`echo ${INFO} | awk '{print $1 $2}'`
VGID=`echo ${INFO} | awk '{print $3 $4}'`
echo "${RDEV} pvid = ${PVID} vgid = ${VGID}"
elif [ "$KIND" = "L V M R E C 0 2" ]; then
VGID=`xd -An -j8208 -N84 -tc ${RDEV} | cut -c5- | cut -c 1,5,9,13,17,21,25,29,33,37,41,45,49,53,57,61|tr -d '\n'`
echo "${RDEV} vgid = ${VGID}"
else
echo did not reconize $RDEV as a LVM disk
fi
Please use plain text.
Advisor
davesec
Posts: 27
Registered: ‎09-10-2009
Message 9 of 9 (1,050 Views)

Re: /etc/lvmtab file format/structure

You can check also the scripts showlvmids and showlvmid at http://hpux.ch/index.php/HPUX::Tools .
Please use plain text.
The opinions expressed above are the personal opinions of the authors, not of HP. By using this site, you accept the Terms of Use and Rules of Participation