Skip to contentSkip to conversation

LVM2 label and metadata location

DISCUSSION Schneider 2 participants 2 messages Oct 13, 2018 – Oct 17, 2018

lore
Share & tools
lore

Schneider

#0 lore raw

Hello Sir or Madam,

i am writing to you because i do have a question about the LVM2 label and the contained metadata location.
I need to know how the metadata location is encoded because i am currently writing my master thesis about the examination of different system metadata. If you want to verify this you can contact my supervisor and professor Mister Felix Freiling from the Friedrich-Alexander-Universit?t Erlangen-N?rnberg.
I would be very grateful if you could tell me where to find the metadata location in (for example) a hexdump of the LVM label like this one:

Offset 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15

001049088   4C 41 42 45 4C 4F 4E 45  01 00 00 00 00 00 00 00   LABELONE
001049104   7A 46 99 07 20 00 00 00  4C 56 4D 32 20 30 30 31   zF?     

LVM2 001
001049120 74 5A 6D 45 42 50 53 68 56 67 68 69 59 65 55 42
tZmEBPShVghiYeUB
001049136 78 4A 51 6A 44 55 55 69 38 72 41 31 36 48 67 58
xJQjDUUi8rA16HgX

001049152   00 00 90 70 74 00 00 00  00 00 10 00 00 00 00 00      pt
001049168   00 00 00 00 00 00 00 00  00 00 00 00 00 00 00 00
001049184   00 00 00 00 00 00 00 00  00 10 00 00 00 00 00 00
001049200   00 F0 0F 00 00 00 00 00  00 00 00 00 00 00 00 00    ?
001049216   00 00 00 00 00 00 00 00  02 00 00 00 01 00 00 00

I did read the LVM2 documentation and i have tried to find the location parsing in the LVM2 code but unfortunately I was unable to figure out how this has to be done.

Thank you so much for your help.
With best wishes from Bavaria, Germany

Janine Schneider

#1 lore raw
Quoted 3 lines · Janine

I did read the LVM2 documentation and i have tried to find the location parsing in the LVM2 code but unfortunately I was unable to figure out how this has to be done.

This brief summary might get you started; the structure of the lvm code doesn't make it easy to find or follow.

The second sector of the disk (offset 512) contains: struct label_header followed by struct pv_header. The pv_header (disk_areas) point to the location of one (or optionally two) struct mda_header. The first mda_header is at offset 4096. (The optional second one is at the end of the device.)

The sector containing mda_header is followed by many sectors (e.g. 1MB). These sectors act as a circular buffer containing lvm text metadata. One copy of the text metadata is written into this buffer after the last version. The mda_header's raw_locn struct points to the latest copy of the metadata in this buffer.

_find_lvm_header() reads label_header.
_text_read() reads pv_header.
_raw_read_mda_header() reads mda_header
text_read_metadata() reads text metadata