Blog » Herbert Poul's Personal Blog » Recovering a broken KVM guest after upgrade
Just so I can remember a few commands.
If you ever happen to stumble upon kernel panics from a KVM guest after upgrading.. maybe a few commands which might be userful. (I have upgraded from debian 7 wheezy to debian 9 stretch) and encountered nice kernel panics.



Forcefully shutting down KVM



Even though it sounds scary. The correct way to just cut the power to your KVM guest is to use `destroy`.

root@host3 / # virsh start services


Mount file system from guest



I am using a LVM volume which itself has a partition table written from the guest system. So I can't mount it directly. Luckily with a bit of googling I found a helpful website: https://backdrift.org/mounting-a-file-system-on-a-partition-inside-of-an-lvm-volume

root@host3 / # kpartx -a /dev/vg0/services
root@host3 / # file -s /dev/mapper/vg0-services1 
/dev/mapper/vg0-services1: symbolic link to ../dm-13
root@host3 / # mount /dev/mapper/vg0-services1 /mnt


Updating grub config



root@host3 / # cd /mnt
root@host3 /mnt # mount -t proc proc proc/
root@host3 /mnt # mount -t sysfs sys sys/
root@host3 /mnt # mount -o bind /dev dev
root@host3 /mnt # chroot .

# Now change /etc/grub.conf to boot old kernel (or just delay automatic selection)

root@host3:/# update-grub
Generating grub configuration file ...
Found linux image: /boot/vmlinuz-4.9.0-7-amd64
Found initrd image: /boot/initrd.img-4.9.0-7-amd64
Found linux image: /boot/vmlinuz-3.16.0-6-amd64
Found initrd image: /boot/initrd.img-3.16.0-6-amd64
Found linux image: /boot/vmlinuz-3.2.0-4-amd64
Found initrd image: /boot/initrd.img-3.2.0-4-amd64
done
root@host3:/#


🎉️🎉️🎉️🎉️🎉️

root@host3:/# exit
root@host3 /mnt # umount proc
root@host3 /mnt # umount sys
root@host3 /mnt # umount dev
root@host3 /mnt # cd /
root@host3 / # umount /mnt
root@host3 / # kpartx -d /dev/vg0/services
root@host3 / # virsh start services
Hey, we have Signatures !!! Great, isn't it ? ;)

Posted by Herbert Poul

Assigned Tags:

0 Comments

Attachments: Screen_Shot_2018-08-01_at_13.11.20.png (90.6 KB)

Please login to post a reply.

Personal website and blog of Herbert Poul. Also check out my Photo Gallery.




Herby's Photo Gallery

Subscriptions

User

You are not logged in.
Login
Register