{"id":3260,"date":"2021-09-25T09:49:14","date_gmt":"2021-09-25T08:49:14","guid":{"rendered":"https:\/\/kudzia.eu\/b\/?p=3260"},"modified":"2021-12-25T19:14:42","modified_gmt":"2021-12-25T18:14:42","slug":"booting-kvm-vm-from-an-iso-image","status":"publish","type":"post","link":"https:\/\/kudzia.eu\/b\/2021\/09\/booting-kvm-vm-from-an-iso-image\/","title":{"rendered":"booting KVM VM from an iso image"},"content":{"rendered":"<p>let&#8217;s say you have a vm, maybe with debian. and that vm stopped booting, maybe because of grub corruption. what do you do?<\/p>\n<pre class=\"brush: plain; title: ; notranslate\" title=\"\">\r\nvirsh destroy nameOfVM\r\nvirsh edit nameOfVM\r\n<\/pre>\n<p>add under devices &#8211; for pc-i440fx arch:<\/p>\n<pre class=\"brush: plain; title: ; notranslate\" title=\"\">\r\n &lt;disk type='file' device='cdrom'&gt;\r\n   &lt;driver name='qemu' type='raw'\/&gt;\r\n   &lt;source file='\/mnt\/storage0\/iso\/debian-10.8.0-amd64-netinst.iso'\/&gt;\r\n   &lt;target dev='hdc' bus='ide'\/&gt;\r\n   &lt;readonly\/&gt;\r\n   &lt;address type='drive' controller='0' bus='1' target='0' unit='0'\/&gt;\r\n &lt;\/disk&gt;\r\n<\/pre>\n<p>and for pc-q35-3.1:<\/p>\n<pre class=\"brush: plain; title: ; notranslate\" title=\"\">\r\n &lt;disk type='file' device='cdrom'&gt;\r\n  &lt;driver name='qemu' type='raw'\/&gt;\r\n  &lt;source file='\/mnt\/storage0\/iso\/debian-10.11.0-amd64-netinst.iso'\/&gt;\r\n  &lt;backingStore\/&gt;\r\n  &lt;target dev='sdb' bus='sata'\/&gt;\r\n  &lt;readonly\/&gt;\r\n  &lt;address type='drive' controller='0' bus='0' target='0' unit='1'\/&gt;\r\n &lt;\/disk&gt;\r\n<\/pre>\n<p>then in the os section change boot from dev=&#8217;hd&#8217; to dev=&#8217;cdrom&#8217;:<\/p>\n<pre class=\"brush: plain; title: ; notranslate\" title=\"\">\r\n&lt;os&gt;\r\n  &lt;type arch='x86_64' machine='pc-i440fx-3.1'&gt;hvm&lt;\/type&gt;\r\n  &lt;boot dev='hd'\/&gt;\r\n&lt;\/os&gt;\r\n<\/pre>\n<p>then <\/p>\n<pre class=\"brush: plain; title: ; notranslate\" title=\"\">\r\nvirsh define \/etc\/libvirt\/qemu\/nameOfVM.xml\r\nvirsh start nameOfVM\r\n<\/pre>\n<p>also &#8211; <a href=\"https:\/\/www.explorelinux.com\/convert-a-disk-gpt-to-mbr-linux\/\">this article<\/a> 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.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>let&#8217;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 &#8211; for pc-i440fx arch: &lt;disk type=&#8217;file&#8217; device=&#8217;cdrom&#8217;&gt; &lt;driver name=&#8217;qemu&#8217; type=&#8217;raw&#8217;\/&gt; &lt;source file=&#8217;\/mnt\/storage0\/iso\/debian-10.8.0-amd64-netinst.iso&#8217;\/&gt; &lt;target dev=&#8217;hdc&#8217; bus=&#8217;ide&#8217;\/&gt; &lt;readonly\/&gt; &lt;address type=&#8217;drive&#8217; controller=&#8217;0&#8242; bus=&#8217;1&#8242; target=&#8217;0&#8242; unit=&#8217;0&#8217;\/&gt; &lt;\/disk&gt; [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[17,51],"tags":[49],"class_list":["post-3260","post","type-post","status-publish","format-standard","hentry","category-tech","category-unimportant","tag-kvm"],"_links":{"self":[{"href":"https:\/\/kudzia.eu\/b\/wp-json\/wp\/v2\/posts\/3260","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/kudzia.eu\/b\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/kudzia.eu\/b\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/kudzia.eu\/b\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/kudzia.eu\/b\/wp-json\/wp\/v2\/comments?post=3260"}],"version-history":[{"count":4,"href":"https:\/\/kudzia.eu\/b\/wp-json\/wp\/v2\/posts\/3260\/revisions"}],"predecessor-version":[{"id":3287,"href":"https:\/\/kudzia.eu\/b\/wp-json\/wp\/v2\/posts\/3260\/revisions\/3287"}],"wp:attachment":[{"href":"https:\/\/kudzia.eu\/b\/wp-json\/wp\/v2\/media?parent=3260"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/kudzia.eu\/b\/wp-json\/wp\/v2\/categories?post=3260"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/kudzia.eu\/b\/wp-json\/wp\/v2\/tags?post=3260"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}