1824218 Members
3818 Online
109669 Solutions
New Discussion юеВ

reading LVM headers

 
SOLVED
Go to solution
Michal Toth
Regular Advisor

reading LVM headers

hi all,

i just wonder, if there is a way how to read LVM headers off existing physical volumes (VGRA, PVRA). Or if someone could direct me to a document that describes the format so I could write a tool myself...

thanks and regards

Michal
8 REPLIES 8
IT_2007
Honored Contributor
Solution

Re: reading LVM headers

HP has a script names lvm11 and you can get it from HP. I can attach if I have that script.
Bill Hassell
Honored Contributor

Re: reading LVM headers

You can do something like this:

dd if=/dev/rdsk/c0t5d0 | xd -xc | more

Not pretty but it shows the raw data at the beginning of the disk. Use offsets in dd to move around. Naturally, you'll need a lot of details about the VGRA, BDRA, and other LVM structures to make sense of the data.


Bill Hassell, sysadmin
Hein van den Heuvel
Honored Contributor

Re: reading LVM headers

Ok, Bill's reply triggered me to write up this somewhate related recent war story...

I actually was checking out LVM headers myself last week.
You see, I have a modest rx2620 which I boot for HPUX or OpenVMS based on my needs.
It has 3 x 73 GB drives which I want to use all for OpenVMS performance experiments.
So I want to reserve an HPUX LVM Logical Volume as play area for VMS.
Now as long as I knew where the LV starts on the drive, I could use the OpenVMS psuedo disk LD-driver to 'map' a disk in a range of blocks with neglectable performance impact.

VGdisplay -v gives the PE number for the LV start, but this does NOT map directly to a block number on the disk due to those LVM headers (and the EFI partitioning 512MB).
So here is the brute force method I succesfully deployed:
- using " dd -count=1 -bs=1k " wrote a 1KB file with the words 'first first first...' in it to the raw volume for a selected LV.
- using " dd -oseek=(LV_SIZE*PE_SIZE -1) -bs=1k -count=1 " wrote a 1KB file with 'last last last ..." to the last KB in the LV raw device.
- Boot OpenVMS
- Write program to scan raw disk for text starting from a selected block (SMOP :-)
- Scanned for 'first first ' -- Found start!
- Scanned for 'last last ' -- Found end!
- Verified distance was size of LV
- mapped OpenVMS LDdrive onto block range.
- repeat for second drive... Presto!

Now I can use my hpux data and os disk drives as data drives for my OpenVMS tests!

Fun fun fun... for crazy folks like myself.

Grins,
Hein van den Heuvel
HdvH Performance Consulting.
Michal Toth
Regular Advisor

Re: reading LVM headers

pure madness I say, but you deserve 1 point for the story :-)

anyways, if someone could post the lvm11 script here I'd be very grateful, as I currently do not have my pets under contract from HP
Robert-Jan Goossens_1
Honored Contributor

Re: reading LVM headers

melvyn burnard
Honored Contributor

Re: reading LVM headers

You could use the folowing:

Read the LVM record identification:
#echo 0x2000?4s | adb /dev/dsk/c0t6d0

Read the PVID:
#echo 0x2000?4X | adb /dev/dsk/c0t6d0
2000: 4C564d52 45433031 78261D3A 391C79BF
The 3rd and 4th fields make up the PVID
78261D3A391C79BF

Read the VGID:
#echo 0x12000?8X | adb /dev/dsk/c0t6d0
12000: 4C564d52 45433031 78261D3A 91C79BF 78261D3A 391C79C0 1FC74B 0

The VGID is the 5th and 6th fields:
78261D3A391C79C0

Read the cluster ID (if in use on a cluster):
#echo 0x12080?8X | adb /dev/dsk/c0t6d0
12080: 0 1 1FC740 392C0AE1 100 0 0 0

The cluster ID is the 4th field:
392C0AE1


Hope that helps
My house is the bank's, my money the wife's, But my opinions belong to me, not HP!
Michal Toth
Regular Advisor

Re: reading LVM headers

thank you all
Michal Toth
Regular Advisor

Re: reading LVM headers

got nice answers