In this guide we will work on some recovery steps, that could help you to recover the Volume Group, after reboot.
When you reboot Server after extending / shrinking your Server Logical Volume, and something goes wrong, after the reboot, Server shows you this message, and you start in initramfs shell (Rescue shell) in this shell you have very limited commands to use.
Our main commands that we are going to use, all related to /sbin/lvm, if you tried (pvs, vgs, vgdisplay, etc…) all will give you one result (Command not Found). Therefore, we need to use /sbin/lvm to execute the following commands.
So, first we need to get UUID for our drive, to get UUID use blkid command:
# blkid /dev/sda1: UUID="8a9e79ec-3936-4e74-bb40-e120cf395dae" TYPE="xfs" PARTUUID="27795bc1-01" /dev/sda2: PARTUUID="27795bc1-02"
So /dev/sda2 is showing Partial UUID (PARTUUID), and the Physical Volume (PV), Volume Group (VG), and Logical Volume (LV) are located / stored in /dev/sda2
After getting the UUID, we need to look in /etc/lvm/archive directory, and look for VolumeGroupName_xxx.vg file that has the last known valid archived LVM metadata for that volume group.
Then, we start by creating Physical Volume (pvcreate):
# /sbin/lvm pvcreate --uuid "27795bc1-02" --restore /etc/lvm/archive/VolumeGroupName_xxx.vg /dev/sda2
That will give you an error, that UUID not found in VolumeGroupName_xxx.vg, and it will show you the actual UUID, so we need to confirm the UUID of the Physical Volume from VolumeGroupName_xxx.vg
# cat /etc/lvm/archive/VolumeGroupName_xxx.vg | grep -i "xxxxxx" id = "xxxxxxx-xxxxxx-xxxxx-xxxxx-xxxxx-xxxxxx-xxxxxx"
Then we perform pvcreate command again with the correct UUID:
# /sbin/lvm pvcreate --uuid "xxxxxxx-xxxxxx-xxxxx-xxxxx-xxxxx-xxxxxx-xxxxxx" --restore /etc/lvm/archive/VolumeGroupName_xxx.vg /dev/sda2 Writing physical volume data to disk "/dev/sda2" Physical volume "/dev/sda2" successfully created
After that, we restore the Volume Group (VG):
# vgcfgrestore vg00 Restored volume group vg00
Then activate the Volume Group:
# vgchange -ay
After that you reboot the Server, and your Server should boot into Local mode again normally.
Please note that, sometimes after the reboot, the Operating System asking you to check and repair a Linux filesystem using fsck command on one of the Logical Volume, you run fsck command on the Logical Volume, and fix the broken blocks, then reboot Server again, and that should fix everything.
Note: Always remember to Back up your Data, either locally to your PC, or using any Back up solutions.