Ubuntu 14.04 - Getting Started with KVM using PHP Helper Script

This post carries on from my previous article on how to install KVM on Ubuntu 14.04.

To make life easier, I have created a PHP script to dynamically generate the KVM commands you need in order to create guests. Run these commands to install the PHP CLI package and download the script.

sudo apt-get install php5-cli -y
cd ~
wget https://raw.githubusercontent.com/programster/KVM-Command-Generator/master/main.php
wget https://raw.githubusercontent.com/programster/KVM-Command-Generator/master/distro.class.php

Run the script and answer all the questions.

php main.php  

Copy the command it outputs and execute it.

Watch the guest get set up in text mode in front of your eyes.

Voila! You know have a guest instance. The username and password are both ubuntu for Ubuntu VMs, and root for Debian. You may want to change this.

The script executes a kickstart file to automatically install the operating system. It is an extremely good idea to make your own and host it on the web, such as with pastebin.

Extra Info

  • If you use the kvm script to deploy an ubuntu guest, the default username and password are both "ubuntu". Please change this after installation.
  • The kvm script will deploy guests as minimally as possible. You will need to install the acpi package in the guests for the virsh commands on the host to be able to shutdown/reboot guests.

Debugging

If you see the following message:

Error in network device parameters: Virtual network 'default' has not been started.  

Then run the following command:

sudo virsh net-start default  

Virtualbox

KVM and Virtualbox appear to not work simultaneously on the same host. If you are running Virtualbox whilst you try to create an instance, you may see the following:

ioctl(KVMCREATEVM) failed: 16 Device or resource busy
failed to initialize KVM: Device or resource busy

Author

Programster

Stuart is a software developer with a passion for Linux and open source projects.

comments powered by Disqus