Home > Virtualization > Running Virtual Machines on KVM and QEMU from command line on Ubuntu 14.04

Running Virtual Machines on KVM and QEMU from command line on Ubuntu 14.04

The aim of this post is to document how to get a Lubuntu 14.04 instance, a Windows 7 instance and an Android-86 instance running on KVM (running on QEMU in most cases).
[NB: This is not yet complete, so it may serve only as pointers and not a full guide…]

Install the prerequisites:

sudo apt-get install qemu-kvm libvirt-bin ubuntu-vm-builder bridge-utils

Check if Virtualization is supported on your machine (or virtual machine, if you’re trying to nest VMs) using the kvm-ok command

Method 1: Using the libvirt library / package / set of tools:

NB: I used this to get the lubuntu instance running

sudo apt-get install virtinst
sudo virt-install -n testLubuntu -r 512 \
--disk path=/home/USERNAME/Desktop/VMDisks/testLubuntu.img,bus=virtio,size=6 -c \
lubuntu-14.04.iso --network network=default,model=virtio \
--graphics vnc,listen=0.0.0.0 --noautoconsole -v

Check which VMs are running:

virsh -c qemu:///system list

Stop an instance:

virsh -c qemu:///system shutdown  

NB: Replace the with the name of the instance, e.g. in my case “testLubuntu”
Start an instance:

virsh -c qemu:///system start  

Destroy and undefine an instance:

virsh -c qemu:///system destroy  
virsh -c qemu:///system undefine  

Method 2: Using the kvm package directly:

NB: I used this to get the Android-x86 instance running … but without a WiFI network (as of now…)
Create a virtual disk image file

qemu-img create android-4.4.img 8G

Install the Android OS using a virtualized CD-Rom that points to a bootable Android image:

kvm -m 2048 -hda android-4.4.img -cdrom <Bootable-Android-ISO.iso> -boot d

Create a partition that is bootable and writable when the cfdisk prompts you to do so.

I haven’t been able to get the networking part right because it involves some bridging … which is a bit mind-boggling.

Resources:

Advertisements
  1. No comments yet.
  1. No trackbacks yet.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: