Booting KVM VM from CD image

Posted on Oct 28, 2014

You may list Your all KVM VM with command:

1
2
3
4
[root@kvm3 qemu]# virsh list --all
 Id    Name                           State
----------------------------------------------------
 -     vm1.server.tld               shut off

Edit the config file:

1
[root@kvm3 qemu]# virsh edit vm1.server.tld

Add the following lines to the ‘devices’ part:

1
2
3
4
5
6
7
8
9
<disk type='file' device='cdrom'>
  <driver name='qemu' type='raw'/>
  <source file='/tmp/CentOS-7.0-1406-x86_64-Minimal.iso'/>
  <target dev='hdb' bus='ide'/>
  <readonly/>
  

<address type='drive' controller='0' bus='1' unit='0' />
</disk>

cd

Then find the OS part:

1
2
3
4
<os>
    <type arch='x86_64' machine='pc-i440fx-rhel7.0.0'>hvm</type>
    <boot dev='hd'/>
  </os>

And insert the

1
<boot dev='cdrom'/>

to look like

1
2
3
4
5
<os>
    <type arch='x86_64' machine='pc-i440fx-rhel7.0.0'>hvm</type>
    <boot dev='cdrom'/>
    <boot dev='hd'/>
  </os

That’s it.
Save the config and boot the VM :)