Thursday, April 4, 2013

Create an ISO volume on a remote KVM server

I have a Fedora 17 KVM server that I access remotely with virt-manager.  I usually do network installs of Linux guest VM's, but today I needed to actually boot a VM from an ISO image.  After several fruitless Google searches, here's what worked.

First off, the virt-manager GUI does not enable the Browse Local button when accessing a remote server.  So I needed to get the ISO image into a libvirt storage pool.  Creating the pool is simple, but adding an ISO volume isn't obvious.   In the Storage tab of the Connection Details dialog, you simply select a pool on the right and then select New Volume.  

The problem is that Format doesn't have an ISO option.  Some web pages do show pictures of "iso" appearing there but mine doesn't have it.

Update: raw images work just as well as iso, so you accepting defaults (raw format, suffix "img") should work.

So I used virsh to do it.  Here are the steps.   For this example, let's assume there is a pool called iso and an ISO image at /tmp/my.iso.

  • Log on to the KVM server with ssh.  You'll need sudo privilege or the root password.
  • Transfer the ISO image from wherever it is to any directory on the server.
  • Create an XML template for the new volume.  Use virsh vol-dumpxml to get the XML of an existing volume.
  • Paste the XML into a text editor, and change the name, key, and target path.  I used os-install.iso as the name of the volume.
  • Make sure the capacity is equal to or larger than the ISO image.
  • Change the format type to iso.  This step is confusing.  qemu-img create doesn't accept 'iso' as a format and the vol-create command below fails it you try to use it.  Yet, the type does appear as iso in virt-manager's Storage dialog.
  • Save the file as ~/test-os.xml
  • Create a new volume:

    virsh vol-create --pool iso --file ~/test-os.xml
  • Load the contents of the ISO into the new volume:

    virsh vol-upload --vol os-install.iso --pool iso --file /tmp/my.iso
That's it.  You should be able to connect any guest CD-ROM device to this ISO from a remote virt-manager session.

No comments:

Post a Comment