KVM virtualization using command line on Ubuntu 15.10

KVM virtualization using command line on Ubuntu 15.10

Recently, I have tested the KVM hypervisor on a server running Ubuntu 15.10. The challenge, for me, was to install, configure and use the KVM host and guest only with the command line.

First check, your server have to support hardware virtualization extensions:
$ egrep '(vmx|svm)' --color /proc/cpuinfo


Next step, install KVM:
$ sudo apt-get install qemu-kvm libvirt-bin uuid python-guestfs libguestfs-tools

I have removed the default virtual network and create my own following these steps:

generate an uuid for the new network


create the xml file mybr.xml


delete the default network and create the mybr network


I have found a useful python script to generate virtual machine easily: ubuntu-vm-builder
You can launch it as follow to create your first guest vm:


For me, I don’t know why yet, the script fails with the following error :


I have found a solution: add this line at the end of the function map_partitions of the script file /usr/lib/python2.7/dist-packages/VMBuilder/disk.py


When the script ends, your virtual machine is almost ready. Check the vm is shut off:


To get access to the vm console, some other steps are required. We have to edit the vm disk file using guestfish:


I have updated the line 135 as follow:
kernel          /boot/vmlinuz-3.13.0-79-generic root=UUID=ef1fb3c8-1765-46ee-ad03-643789032648 ro quiet splash console=ttyS0,115200


Now you can edit the vm configuration:


After editing, the xml file will look like this:


You can now start your vm and check you can login:


Update your iptables rules to allow ssh from the host to the guest:


Do not hesitate to contact me or leave a comment if you have a problem or a step is missing on this procedure.


My Powershell script categories

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.

Social Media Auto Publish Powered By : XYZScripts.com
%d bloggers like this: