Creating a new virtual machine
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
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:
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:
And away you go:
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.