This post will show you how I managed to restore my laptop after the grub configuration got corrupted and could not find the LVM root partition.
The grub menu booted into grub-rescue which I could not use to boot the LVM partitions as it was an unrecognised file system. Therefore the only thing to do was boot into a LIVE system. I tried several but ended up using an Arch system as I could potentially chroot into the installed system.
Within the live cd I could see the /dev/sd* devices and their partitions which were described as lvm by using the parted application.
Type
parted
and then
to show the partitions.
Before you try to reinstall grub, the root partition needs to be mounted. Without LVM then it would be simple:
mkdir -p /mnt/root mount /dev/sdaX /mnt/root
However with lvm the system does not recognise it and says it can't mount it (mount: unknown filesystem type 'LVM2_member'). So all the posts I found suggested doing a pvscan to scan for the physical lvm volumes followed by a vgscan.
root@Raspberry /home/user # pvscan PV /dev/sda2 VG volgr lvm2 [42.00 GiB / 2.00 GiB free] PV /dev/sda5 VG volgr lvm2 [16.50 GiB / 16.50 GiB free] Total: 2 [58.49 GiB] / in use: 2 [58.49 GiB] / in no VG: 0 [0 ]
This is from my working system. When I was booted from a live cd then "in use" was 0. The vgscan said no volumes found. Trying a "vgchange -ay" had no affect as it could not find the volumes. I eventually found the command "vgcfgrestore" which restored the volume group and then I was able to run the "vgchange -ay" to activate it.
vgcfgrestore 'volume group name' vgchange -ay
Now you can show the logical volumes.
root@Raspberry /home/user # lvdisplay :( --- Logical volume --- LV Path /dev/volgr/lvroot LV Name lvroot VG Name volgr LV UUID 5syuZy-XN2h-fUK5-8DDF-tK9G-50HB-zO4LV7 LV Write Access read/write LV Creation host, time archiso, 2014-05-07 21:19:31 +0100 LV Status available # open 1 LV Size 40.00 GiB Current LE 10240 Segments 1 Allocation inherit Read ahead sectors auto - currently set to 256 Block device 254:0
Now you can mount the lvm logical volume.
mount /dev/mapper/lvroot /mnt/root
Now you can arch-chroot. This takes you into the mounted root volume so you can run commands as if you were booted into that root partition.
arch-chroot /mnt/root
Now it's time to fix grub. To reinstall grub and then generate a configuration file you need to run the following commands.
grub-install --target=i386-pc /dev/sdx grub-mkconfig -o /boot/grub/grub.cfg
To clean up. Exit the chroot, umount the lvm volume and reboot.
exit umount /mnt/root reboot
Comments powered by Disqus.