Kernel, Linux

When you have no bootable kernels on a VM…



Shutdown your VM. If you are using virsh, try

virsh shutdown <vm-name>

which is equivalent to sending the shutdown command to your VM. Check if the VM actually shutdown with:

virsh list

If your VM is being stubborn, try:

virsh destroy <vm-name>

which is equivalent to pulling the power from your VM.


Ideally you would have saved a backup of your VM image when it was working… If you had the foresight to do this, then simply copy this into where your VM image is stored and reboot!

Otherwise, make a copy of your existing VM image and store it somewhere safe (in case we end up destroying the actual image…).


Mount the VM image as a filesystem!

There are multiple different ways to mount the various types of disk images out there. Here is how I mounted my qcow2 image:

Mount the nbd kernel module:

sudo modprobe nbd max_part=63

Check that it mounted correctly:

lsmod | grep nbd

Run parted to investigate the partition tables of your disk (so we know how to mount it):

sudo parted /dev/nbd0

In parted, run:

check p

you should see some output describing your partition table. For example:

Model: Unknown (unknown)
Disk /dev/nbd0: 26.8GB
Sector size (logical/physical): 512B/512B
Partition Table: gpt
Disk Flags:

Number   Start          End             Size   File system Name   Flags
1              1049kB      8389kB     7340kB                                      prep
2              8389kB     264MB     256MB             ext2
3              264MB      21.5GB       21.2GB                                       lvm

Partition 2 is the one that we want. Exit parted by typing ‘quit’.

Now we know which partition to boot:

sudo mount /dev/nbd0p2 /mnt/

cd /mnt

You should see your boot folder!


Now copy across or edit any files you need!


Unmount your disk:

sudo umount /mnt

Kill the process using qumu-nbd

ps -aux | grep qemu-nbd

sudo killall qemu-nbd

Remove kernel module:

sudo rmmod nbd

Now rerun your VM as per usual!