This procedure requires a recent backup of the LVM configuration. This can be generated with the command vgcfgbackup and is stored in the file /etc/lvm/backup/[volume group name]. The /etc/lvm/archive directory also contains recent configurations that are created when modifications to the volume group metadata are made. It is recommended that these files be regularly backed up to a safe location so that they will be available if required for recovery purposes.
Assuming a physical volume has been lost that was a part of a volume group the following procedure may be followed. The procedure will replace the failed physical volume with a new disk rendering any remaining logical volumes accessible for recovery purposes.
The procedure for recovery is as follows:
1. Execute the following command to display information about the volume group in question:
# vgdisplay --partial --verbose
The output will be similar to the following (note that the –partial flag is required to activate or manipulate a volume group having one or more physical volumes missing and that use of this flag with LVM2 activation commands (vgchange -a) will force volumes to be activated in a read-only state):
Partial mode. Incomplete volume groups will be activated read-only. Finding all volume groups Finding volume group "volGroup00" Couldn't find device with uuid ƏeWicl-1HSB-Fkcz-wrMf-DzMd-Dgx2-Kyc11j'. Couldn't find device with uuid ƏeWicl-1HSB-Fkcz-wrMf-DzMd-Dgx2-Kyc11j'. Couldn't find device with uuid ƏeWicl-1HSB-Fkcz-wrMf-DzMd-Dgx2-Kyc11j'. Couldn't find device with uuid ƏeWicl-1HSB-Fkcz-wrMf-DzMd-Dgx2-Kyc11j'. --- Volume group --- VG Name volGroup00 System ID Format lvm2 Metadata Areas 4 Metadata Sequence No 33 VG Access read VG Status resizable MAX LV 0 Cur LV 1 Open LV 0 Max PV 0 Cur PV 5 Act PV 5 VG Size 776.00 MB PE Size 4.00 MB Total PE 194 Alloc PE / Size 194 / 776.00 MB Free PE / Size 0 / 0 VG UUID PjnqwZ-AYXR-BUyo-9VMN-uSRZ-AFlj-WOaA6z --- Logical volume --- LV Name /dev/volGroup00/myLVM VG Name volGroup00 LV UUID az6REi-mkt5-sDpS-4TyH-GBj2-cisD-olf6SW LV Write Access read/write LV Status available # open 0 LV Size 776.00 MB Current LE 194 Segments 5 Allocation inherit Read ahead sectors 0 Block device 253:0 --- Physical volumes --- PV Name /dev/hda8 PV UUID azYDV8-e2DT-oxGi-5S9Q-yVsM-dxoB-DgC4qN PV Status allocatable Total PE / Free PE 48 / 0 PV Name /dev/hda10 PV UUID SWICqb-YIbb-g1MW-CY60-AkNQ-gNBu-GCMWOi PV Status allocatable Total PE / Free PE 48 / 0 PV Name /dev/hda11 PV UUID pts536-Ycd5-kNHR-VMZY-jZRv-nTx1-XZFrYy PV Status allocatable Total PE / Free PE 48 / 0 PV Name /dev/hda14 PV UUID OtIMPe-SZK4-arxr-jGlp-eiHY-2OA6-kyntME PV Status allocatable Total PE / Free PE 25 / 0 PV Name unknown device PV UUID 9eWicl-1HSB-Fkcz-wrMf-DzMd-Dgx2-Kyc11j PV Status allocatable Total PE / Free PE 25 / 0
Note the PV UUID line:
PV UUID 9eWicl-1HSB-Fkcz-wrMf-DzMd-Dgx2-Kyc11j
This line contains the universally unique identifier (UUID) of the physical volume that failed and will be needed in the next step.
2. If the physical volume failed, it must be replaced with a disk or partition that is equal in size or larger than the failed volume. If the disk did not fail but was overwritten or corrupted, the same volume can be re-used. Run the following command to re-initialize the physical volume:
# pvcreate --restorefile /etc/lvm/backup/[volume group name] --uuid [UUID] [device]
In the above command the UUID is the value taken from the output in step 1. In this example the full command would be:
# pvcreate --restorefile /etc/lvm/backup/volGroup00 --uuid 9eWicl-1HSB-Fkcz-wrMf-DzMd-Dgx2-Kyc11j /dev/hda15 Couldn't find device with uuid 9eWicl-1HSB-Fkcz-wrMf-DzMd-Dgx2-Kyc11j. Physical volume "/dev/hda15" successfully created
3. Now the new physical volume has been initialized with the UUID of the old physical volume. The volume group metadata may be restored with the following command:
# vgcfgrestore --file /etc/lvm/backup/[volume group name] [volume group name]
Continuing the earlier example the exact command would be:
# vgcfgrestore --file /etc/lvm/backup/volGroup00 volGroup00 Restored volume group volGroup00
4. To check that the new physical volume is intact and the volume group is functioning correctly execute vgdisplay -v.