Edit grub on a VM on headless KVM Host


I Recently updated my OP5 machine later after an reboot got the error message.  Important to know is that i run my VM (Virtual Machine) on a headless server so i have no more tools then to VNC to a VM and therefore its hard to get into grub at boot as the timeout was set to 5 seconds.

Kernel panic - not syncing: VFS: Unable to mount root fs on unit block(0,0)

information about diskfile

First we need to know what kind of fileformat is used to store our VM machine

[root@hem-dalesjo-net OP5]# qemu-img info /var/lib/libvirt/images/OP5.dsk
image: /var/lib/libvirt/images/OP5.dsk
file format: qcow2
virtual size: 48G (51539607552 bytes)
disk size: 12G
cluster_size: 65536
Format specific information:
  compat: 1.1
  lazy refcounts: true

You can also do a quick check if the file is corrupt or not

[root@hem-dalesjo-net OP5]# qemu-img check /var/lib/libvirt/images/OP5.dsk
No errors were found on the image.
786432/786432 = 100.00% allocated, 0.00% fragmented, 0.00% compressed clusters
Image end offset: 51547734016

Install guestmount

These tools are needed to mount qcow2 files

yum install libguestfs libguestfs-bash-completion.noarch

Mount qcow2

virsh destroy OP5
mkdir /tmp/OP5/ /tmp/OP5/sda1 /tmp/OP5/lv_root/
guestmount -a /var/lib/libvirt/images/OP5.dsk -m /dev/sda1 /tmp/OP5/sda1/
guestmount -a /var/lib/libvirt/images/OP5.dsk -m /dev/vg_op5/lv_root /tmp/OP5/lv_root/

Edit grub

changed timeout to 35 seconds, AKA timeout=35

nano /tmp/OP5/sda1/grub/grub.conf

unmount qcow2

guestunmount /tmp/OP5/sda1/ && guestunmount /tmp/OP5/lv_root/
virsh start OP5


OP5 was recently updated to Kernel 2.6.32-696.18.7.el6.x86_64 which apparently is not bootable. changed default=1 in grub.conf to boot on the older kernel 2.6.32-696.16.1.el6.x86_64