Skip to contentSkip to conversation

LVM metadata checksums

linux-lvm Mark Krenz 3 participants 3 messages Sep 8, 2006

lore
Share & tools
lore

Mark Krenz

author
#0 lore raw

Before you say, DON'T DO IT THAT WAY, let me assure you that I have my
reasons and I'm aware of the risks. This is mostly related to my question about changing UUIDs of physical volumes and volume groups. Anyways, I thought that perhaps I could try to use hexedit to modify the UUID within the image file. However, after I did this I ran into all the lvm commands complaining about checksum errors in the metadata. So my question is, where is the checksum stored and how is it calculated. I noticed that there is an "LVM header near the beginning of the disk followed by a long string:

LABELONE........?... ...LVM2 001M0U7CEZK8M7l2Z4KnOtI1uSVjAu0cCFd

Is that last part the checksum? What kind is it?

Signature · 4 lines
Mark S. Krenz
IT Director
Suso Technology Services, Inc.
http://suso.org/
#1 lore raw
Quoted 10 lines · Mark Krenz

Before you say, DON'T DO IT THAT WAY, let me assure you that I have my
reasons and I'm aware of the risks. This is mostly related to my question about changing UUIDs of physical volumes and volume groups. Anyways, I thought that perhaps I could try to use hexedit to modify the UUID within the image file. However, after I did this I ran into all the lvm commands complaining about checksum errors in the metadata. So my question is, where is the checksum stored and how is it calculated. I noticed that there is an "LVM header near the beginning of the disk followed by a long string:

Quoted 5 lines

LABELONE........?... ...LVM2 001M0U7CEZK8M7l2Z4KnOtI1uSVjAu0cCFd

Is that last part the checksum? What kind is it?

after a fast read of sources, i think checksum is computed here :
lib/misc/crc.c :
/* Calculate an endian-independent CRC of supplied buffer */ uint32_t calc_crc(uint32_t initial, void *buf, uint32_t size)

{
        static const uint32_t crctab[] = {
                0x00000000, 0x1db71064, 0x3b6e20c8, 0x26d930ac,
                0x76dc4190, 0x6b6b51f4, 0x4db26158, 0x5005713c,
                0xedb88320, 0xf00f9344, 0xd6d6a3e8, 0xcb61b38c,
                0x9b64c2b0, 0x86d3d2d4, 0xa00ae278, 0xbdbdf21c
        };
        uint32_t i, crc = initial;
        uint8_t *data = (uint8_t *) buf;

        for (i = 0; i < size; i++) {
                crc ^= *data++;
                crc = (crc >> 4) ^ crctab[crc & 0xf];
                crc = (crc >> 4) ^ crctab[crc & 0xf];
        }
        return crc;
}

Here is the call :
lib/format_text/format-text.c,139 :

        if (mdah->checksum_xl != xlate32(calc_crc(INITIAL_CRC,

mdah->magic,
MDA_HEADER_SIZE -

sizeof(mdah->checksum_xl)))) {
                log_error("Incorrect metadata area header checksum");
                return NULL;
        }
Signature · 1 line
Fabien Jakimowicz <[email protected]>
#2 lore raw
In reply to Mark Krenz
Quoted 2 lines · Mark Krenz

Anyways, I thought that perhaps I could try to use hexedit to modify the UUID within the image file.

Use the tools!
pvchange --uuid
vgchange --uuid

Never edit on-disk metadata by hand!
Use vgcfgbackup to read it into a file, edit the file, then put it back with vgcfgrestore. (With pvcreates before restoring if necessary.)

Alasdair

Signature · 1 line
[email protected]