Thursday, 6 February 2014

How to make a KVM Virtual machine boot From CDROM


If you have a running KVM VM and you need to boot this VM from a Bootable Linux iso image inorder to fix some issues on the KVM machine. Below are the steps to boot the KVM machine from CD ROM.

KVM machine is using the xml files for the configuration. We need to edit the configuration xml file inorder to make any changes in the VM.

1_First Shutdown the VM using the command.

virsh shutdown vmname

2)Open the configuration file of the VM using the command

virsh edit vmname

3)Search for the word cdrom and add the lines as below

<disk type='file' device='cdrom'>
      <driver name='qemu' type='raw'/>
      <source file='/opt/isos/CentOS-6.3-x86_64-bin-DVD1.iso'/>
      <target dev='hdc' bus='ide'/>
      <address type='drive' controller='0' bus='1' unit='0'/>

Here we specified the iso image as the source file parameter.

4)Now the cdrom has been added on the VM. But now we need to make the cdrom as the first boot device.

For that we need to change the boot order of vm. Below is the lines which specifies the boot loader for the KVM vm

    <type arch='x86_64' machine='rhel6.2.0'>hvm</type>

<boot dev='cdrom'/>
<boot dev='hd'/>
    <bootmenu enable='yes'/>

In above I put the boot device as cdrom in the parameter <boot dev='cdrom'/> and put it above the hd.

Now reboot the machine and then the vm will boot from the Linux iso image we added.


No comments:

Post a Comment