booting KVM VM from an iso image

let’s say you have a vm, maybe with debian. and that vm stopped booting, maybe because of grub corruption. what do you do?

virsh destroy nameOfVM
virsh edit nameOfVM

add under devices – for pc-i440fx arch:

 <disk type='file' device='cdrom'>
   <driver name='qemu' type='raw'/>
   <source file='/mnt/storage0/iso/debian-10.8.0-amd64-netinst.iso'/>
   <target dev='hdc' bus='ide'/>
   <readonly/>
   <address type='drive' controller='0' bus='1' target='0' unit='0'/>
 </disk>

and for pc-q35-3.1:

 <disk type='file' device='cdrom'>
  <driver name='qemu' type='raw'/>
  <source file='/mnt/storage0/iso/debian-10.11.0-amd64-netinst.iso'/>
  <backingStore/>
  <target dev='sdb' bus='sata'/>
  <readonly/>
  <address type='drive' controller='0' bus='0' target='0' unit='1'/>
 </disk>

then in the os section change boot from dev=’hd’ to dev=’cdrom’:

<os>
  <type arch='x86_64' machine='pc-i440fx-3.1'>hvm</type>
  <boot dev='hd'/>
</os>

then

virsh define /etc/libvirt/qemu/nameOfVM.xml
virsh start nameOfVM

also – this article describes how to go back from gpt to mbr / msdos disk partition definition. i hope this one ends my endless problems with GRUB on KVM VMs occasionally getting stuck and preventing VM boot.

Leave a Reply

Your email address will not be published. Required fields are marked *

(Spamcheck Enabled)