
Recover missing LVM partition data’s in Linux.
This blog will show, how to recover missing LVM partition data’s in Linux box.
Scenario:-
One of our client server LVM meta data got corrupted and the disks are not shown while we execute, PVdisplay, LVdisplay and VGdisplay. Further, we have done below steps to recover these disks in LVM,
1. LVM will always take the backup of meta data details in /etc/lvm/backup/<vg_name> when we done any modifications. Please verify this file that it’s have all the partitions and size. Ex:-
“logical_volumes {
root {
id = “j2rlvk-cGYE-fxbN-F8bO-p90r-x0FL-suSNUA”
status = [“READ”, “WRITE”, “VISIBLE”]
flags = []
creation_host = “unassigned-hostname”
creation_time = 1475126039 # 2016-09-29 10:43:59 +0530
segment_count = 2
segment1 {
start_extent = 0
extent_count = 6425 # 25.0977 Gigabytes
type = “striped”
stripe_count = 1 # linear
stripes = [
“pv0”, 0
]
}
segment2 {
start_extent = 6425
extent_count = 15360 # 60 Gigabytes
type = “striped”
stripe_count = 1 # linear
stripes = [
“pv1”, 0
]
}
}
2. Once verified all the settings, take the backup of this file and reboot the server into rescue mode.
3. After server booted into rescue mode, unmount the root partitions disk, Ex:-
#umount /dev/sda1
4. Verify, all the partitions are not mounted on the server, Ex:-
#lsblk
5. Upload the backup file of LVM meta data’s in rescue server and get the uuid of /dev/sda1, Ex:-:-
physical_volumes {
pv0 {
id = “ck9MZu-UeBT-4boe-IkJU-Q8n7-yfpX-yLK3WY” –> copy this uuid from LVM backup file.
device = “/dev/sda1” # Hint only
6. Once done, execute below command to create Physical Volumes:-
#pvcreate –restorefile <lvm-backup-file> –uuid <uuid> <disk>
#Ex: pvcreate –restorefile <lvm-backup-file> –uuid ck9MZu-UeBT-4boe-IkJU-Q8n7-yfpX-yLK3WY /dev/sda1
7. Check if PV is created,
#pvs
8. Next, restore the VG by executing below command,
“#vgcfgrestore –force <vg-name>
9. Sync VG data’s,
“#vgscan
10. Check, if VG is restored properly,
“#vgs
11. Next, restore the LVM’s by below command,
“#vgchange -ay <vg-name>
If you get error related to lvm-thin, then you will need the package ‘thin-provisioning-tools’. Install it by using the following command.
“#apt install thin-provisioning-tools
12. Boot the server into normal mode and it should work.!
Thanks for reading. Let us know if you have any questions or suggestions. Keep Clouding!

Admin