Skip to contentSkip to conversation

How to restore a PV ??

linux-lvm Jerome 4 participants 11 messages Oct 13, 2006 – Nov 18, 2006

lore
Share & tools
lore

Jerome

author
#0 lore raw

Hi all,
i've made a mistake on deleting the MBR of a disk who was included in a Volume Group of three disks. Now, when i do a pvdisplay command, i have this result:

pvdisplay
2 PV(s) found for VG principal: expected 3
Logical volume (Database) contains an incomplete mapping table. PV segment VG free_count mismatch: 0 != 3576
PV segment VG extent_count mismatch: 7152 != 10728

  Internal error: PV segments corrupted in principal.

And a vgdisplay show me this following:
vgdisplay
2 PV(s) found for VG principal: expected 3
2 PV(s) found for VG principal: expected 3
Volume group "principal" not found

I'm sure that the data on the hard disk are not erased. But i want to restore this third disk, that it is part of the "principal" Volume Group. (I have a fourth disk with the same physical caracteristics). So, how can i do to succeed in this?

Best regards.

Signature · 3 lines
-- J�r�me
Si l'on peut trouver moins que rien, c'est que rien vaut d�j� quelque chose.
	(Raymond Devos)
#1 lore raw

does 'vgcfgrestore principal' work?

brassow

Quoted 32 lines · Jerome

Hi all,
i've made a mistake on deleting the MBR of a disk who was included in a Volume Group of three disks. Now, when i do a pvdisplay command, i have this result:

pvdisplay
2 PV(s) found for VG principal: expected 3
Logical volume (Database) contains an incomplete mapping table. PV segment VG free_count mismatch: 0 != 3576
PV segment VG extent_count mismatch: 7152 != 10728

  Internal error: PV segments corrupted in principal.

And a vgdisplay show me this following:
vgdisplay
2 PV(s) found for VG principal: expected 3
2 PV(s) found for VG principal: expected 3
Volume group "principal" not found

I'm sure that the data on the hard disk are not erased. But i want to restore this third disk, that it is part of the "principal" Volume Group. (I have a fourth disk with the same physical caracteristics). So, how can i do to succeed in this?

Best regards.

Signature · 9 lines
-- J�r�me
Si l'on peut trouver moins que rien, c'est que rien vaut d�j� quelque chose.
	(Raymond Devos)

_______________________________________________
linux-lvm mailing list
[email protected]
https://www.redhat.com/mailman/listinfo/linux-lvm
read the LVM HOW-TO at http://tldp.org/HOWTO/LVM-HOWTO/
author
#2 lore raw
In reply to Jerome
Quoted 4 lines · jbrassow

does 'vgcfgrestore principal' work?

brassow

Hi Jonathan,
i try to use this command, and i've received this error mesage:

/etc/lvm/backup/principal: stat failed: No such file or directory Couldn't read volume group metadata.
Restore failed.

I mean that i've lost the /etc/lv/ directory lost. I've read some information about how to construct the Metadata file with hexdump command (cf : https://www.redhat.com/archives/linux-lvm/2006-June/msg00049.html).
But i not sure how to do this yet.

Thank's a lot.

Signature · 3 lines
-- J�r�me
Il n'y a point de g�nie sans un grain de folie.
	(Aristote)
#3 lore raw

On each disk in the volume group is a record of the changes that have been made to the volume group. The last item in the record is the current lvm meta-data. If you can retrieve that, it is the same as having the backup file which would normally be found in /etc/lvm/backup.

You could use hexdump, but I find it much simpler to use 'less -f <device>'. You should see something like:

<crap>
principal {
...
}
<comments>
<crap>
principal {
...
}
<comments>
<crap>

You should be able to search for 'principal' (the name of your volume group) to locate the first record. As I said, this "meta data area" of the disk keeps a history of your volume group changes. That is, rather than overwriting the record, it writes the new metadata format after the last one (in a circular buffer fashion). You can use the 'seqno' field to determine the newest one. Also, the metadata is written in text to the disk, so it should be simple enough to read it and determine if everything looks fine.

Once you've found the latest copy of the metadata, copy it - including comments - to a file and use 'vgcfgrestore -t -f <file> <vgname>' to test it. Once satisfied, perform the 'vgcfgrestore -f <file> <vgname>'.

If all else fails, you can use dd to grab me the first chunk of the disk, and I'll recreate the backup file for you. ('dd if=<one of the good devs> of=<output file> bs=1M count=1; bzip2 <output file>; send me <output file>.bz2')

brassow

Quoted 31 lines · Jerome
Quoted 4 lines · jbrassow

does 'vgcfgrestore principal' work?

brassow

Hi Jonathan,
i try to use this command, and i've received this error mesage:

/etc/lvm/backup/principal: stat failed: No such file or directory Couldn't read volume group metadata.
Restore failed.

I mean that i've lost the /etc/lv/ directory lost. I've read some information about how to construct the Metadata file with hexdump command (cf : https://www.redhat.com/archives/linux-lvm/2006-June/msg00049.html).
But i not sure how to do this yet.

Thank's a lot.

Signature · 9 lines
-- J�r�me
Il n'y a point de g�nie sans un grain de folie.
	(Aristote)

_______________________________________________
linux-lvm mailing list
[email protected]
https://www.redhat.com/mailman/listinfo/linux-lvm
read the LVM HOW-TO at http://tldp.org/HOWTO/LVM-HOWTO/
#4 lore raw

I am having a similar problem with a drive that was created under LVM version 1. More questions below.

Quoted 9 lines · Jonathan E Brassow

On each disk in the volume group is a record of the changes that have been made to the volume group. The last item in the record is the current lvm meta-data. If you can retrieve that, it is the same as having the backup file which would normally be found in /etc/lvm/backup.

You could use hexdump, but I find it much simpler to use 'less -f <device>'. You should see something like:

Quoted 11 lines

<crap>
principal {
...
}
<comments>
<crap>
principal {
...
}
<comments>
<crap>

Is this also true for LVM1? I have examined the disk ( there are 5 LVs on this disk, one elsewhere ( nowhere! ) ) and it doesn't seem to follow this format.

If this is not true, is there any way to recover such a Volume Group?

Here is what vgscan and pvscan show:

[root@clachan media]# pvscan
5 PV(s) found for VG vg_system: expected 6
Logical volume (lvol4) contains an incomplete mapping table. PV segment VG free_count mismatch: 1381 != 2572
PV segment VG extent_count mismatch: 1417 != 2608

  Internal error: PV segments corrupted in vg_system.

[root@clachan media]# vgscan
Reading all physical volumes. This may take a while... 5 PV(s) found for VG vg_system: expected 6
5 PV(s) found for VG vg_system: expected 6
Volume group "vg_system" not found
[root@clachan media]# vgchange -a y --partial vg_system
Partial mode. Incomplete volume groups will be activated read-only. 5 PV(s) found for VG vg_system: expected 6
Logical volume (lvol4) contains an incomplete mapping table. PV segment VG free_count mismatch: 1381 != 2572
PV segment VG extent_count mismatch: 1417 != 2608

  Internal error: PV segments corrupted in vg_system.
  Unable to find volume group "vg_system"

I do have several copies of the config file, also on this drive ( in a real ext2 partition! ). Could I just edit the file to remove lvol4 ( with 250 segments! ) and do a vgcfgrestore from an LVM2 system?

Thank you,
Brian

#5 lore raw
Quoted 1 line · Brian McCullough
  Internal error: PV segments corrupted in vg_system.

First update your lvm2 software to avoid that bug: you shouldn't see internal errors!

Alasdair

Signature · 1 line
[email protected]
#6 lore raw
Quoted 5 lines · Alasdair G Kergon
Quoted 1 line · Brian McCullough
  Internal error: PV segments corrupted in vg_system.

First update your lvm2 software to avoid that bug: you shouldn't see internal errors!

After installing the latest version available ( packaged ), I get:

[root@clachan ~]# lvm version

LVM version:     2.02.06 (2006-05-12)
Library version: 1.02.07 (2006-05-11)
Driver version:  4.6.0

Should these be new enough?

Thank you,
Brian

#7 lore raw
Quoted 6 lines · Brian McCullough
Quoted 5 lines · Alasdair G Kergon
Quoted 1 line · Brian McCullough
  Internal error: PV segments corrupted in vg_system.

First update your lvm2 software to avoid that bug: you shouldn't see internal errors!

OK, I went to the source and compiled the latest version of both the library and LVM2.

Versions:

[root@clachan ~]# lvm version
LVM version: 2.02.06 (2006-05-12)
Library version: 1.02.12 (2006-10-13)
Driver version: 4.6.0

pvscan:

[root@clachan ~]# pvscan
5 PV(s) found for VG vg_system: expected 6
Logical volume (lvol4) contains an incomplete mapping table. PV segment VG free_count mismatch: 1381 != 2572
PV segment VG extent_count mismatch: 1417 != 2608

  Internal error: PV segments corrupted in vg_system.

Do I need to rebuild my kernel, too?

B-)

#8 lore raw
In reply to Alasdair G Kergon
Quoted 5 lines · Alasdair G Kergon
Quoted 1 line · Brian McCullough
  Internal error: PV segments corrupted in vg_system.

First update your lvm2 software to avoid that bug: you shouldn't see internal errors!

OK, as mentioned in previous messages, I have updated to the most recent versions found on the FTP site ( lvm2 and dm ), but I am still getting the same internal error being reported. Do I need to do something with the kernel? I am running 2.6.17 on an AMD X86_64.

Is there somewhere in the LVM code that I could look for where this internal error is being generated, so that I could perhaps dump the data structures?

Thank you,
Brian

#9 lore raw
Quoted 2 lines · Brian McCullough

OK, as mentioned in previous messages, I have updated to the most recent versions found on the FTP site ( lvm2 and dm )

If you see that with the latest (2.02.14) then we've still got a bug to fix there.

If you lost a partition table, look for something like 'gpart' to try to recreate it. Then you'll need to recreate the PV and get the VG/LV back in place - the procedure depends on whether it's lvm1 or lvm2 metadata and how much info you still have (or can remember) about the layout.

Alasdair

Signature · 1 line
[email protected]
#10 lore raw
Quoted 4 lines · Alasdair G Kergon
Quoted 2 lines · Brian McCullough

OK, as mentioned in previous messages, I have updated to the most recent versions found on the FTP site ( lvm2 and dm )

Quoted 8 lines

If you see that with the latest (2.02.14) then we've still got a bug to fix there.

If you lost a partition table, look for something like 'gpart' to try to recreate it. Then you'll need to recreate the PV and get the VG/LV back in place - the procedure depends on whether it's lvm1 or lvm2 metadata and how much info you still have (or can remember) about the layout.

The partition table is fine. There are 5 ext2/3 partitions, one swap partition and 5 LVM ( 8e ) partitions. The LVM partitions appear to be LVM version 1.

Thanks,
Brian

Quoted 10 lines

Alasdair

Signature · 7 lines
[email protected]

_______________________________________________
linux-lvm mailing list
[email protected]
https://www.redhat.com/mailman/listinfo/linux-lvm
read the LVM HOW-TO at http://tldp.org/HOWTO/LVM-HOWTO/