Creating a base 14.04 Ubuntu using LVM and KVM

Creating a new virtual machine

Introduction

I wanted to create a base install of Ubuntu so that I could keep all the security patches up to date, and then create copies of the base image for other tests, and playing around.

The guide was made when installing a basic Ubuntu 14.04 server image on a KVM hypervisor. All the commands were run as root (or via sudo).

Creating the file system

Firstly, I create the file system the machine would use, on the existing LVM partitions:

$ sudo lvcreate -L 5G -n base-1404 vhosts
Logical volume "base-1404" created

Just using a small volume for the base install (5G). To see the current volumes that exist use lvdisplay to list them all.:

Creating the virtual host

Next to create the virtual host, this is relatively simple to get started:

$ sudo virt-install -n base-1404 -r 512 --disk path=/dev/vhosts/base-1404 -c /home/software/os/linuxisos/ubuntu-14.04.2-server-amd64.iso --os-type linux --os-variant ubuntutrusty --accelerate --network=bridge:br0 --hvm --vnc --noautoconsole

Starting install…
Creating domain… | 0 B 00:04
Domain installation still in progress. You can reconnect to the console to complete the installation process.

The options give 512MB ram, the location to the hard drive to use, a location to a cdrom drive to use (or image) for install. Type of OS, and the variant. Whether to use acceleration, what network to use, and to start with a vnc console, to install it with.

Note: To get a list of os variants available, use:

$ sudo virt-install --os-variant list

Connection to the vhost over VNC

To connect the VNC console to actually carry out the installation, have a look at what is being listened to on the network:

Listing all VNC terminals for the KVM virtual hosts
Listing all VNC terminals for the KVM virtual hosts

The last one should be the one to connect to, so lets tunnel from desktop machine to there, and try and connect:

$ ssh sb1 -L5905:localhost:5905

And then connect using your VNC software:

Conecting to the new virtual machine using remmina and VNC
Conecting to the new virtual machine using remmina and VNC

And away you go:

Ubuntu install page over KVM
Ubuntu install page over KVM

If you need the network address, look in the folder: /etc/libvirt/qemu for the xml configuration file (in this case base-1404.xml), and look for the tag. Or xmldump from the virsh.

Facebooktwittergoogle_plusredditpinterestlinkedinmail

Leave a Reply

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