GenVM - Generate Ubuntu VMs

From version 2.0 of GenVM, you can generate Ubuntu VMs. To generate a VM Ubuntu you must specify :

  • a Ubuntu mirror
  • a version to install (like trusty, precise, etc)
  • name of kernel (linux-image-generic)
  • name of boot loader (grub-pc)

after, all features provided by GenVM are available.

Simple Ubuntu VM

The first VM is basic with all default values (have look on GenVM - Defaults values):

fhh@aaricia ~ $ su -c "genvm -b grub-pc -k linux-image-generic \
 -S http://archive.ubuntu.com/ubuntu/ \
 -V trusty ubuntu-trusty.vmdk"

We are getting an image named “ubuntu-trusty.vmdk” on Ubuntu Trusty in 64 bits (because Aaricia is in 64b), named “aaricia” (because no name was specify).

During installation, the script ask a root password.

A Ubuntu VM advanced

All step in this part are optional.

Setting a name for your VM

As you can find on parameters, you can set the name of your VM with -n newname.

Configure network on DHCP

By using a script in third party you can configure the network directly.

An example of script to configure network is available on page GenVM - Scripts host - Configure network.

fhh@aaricia ~ $ mkdir src.ubuntu
fhh@aaricia ~ $ cat > src.ubuntu/01.host.network_dhcp
auto lo eth0

iface lo inet loopback

iface eth0 inet dhcp
^d

Add some packages

If you want to add a single package, you can use parameter -A *package* but if you need a list, you can specify packages on file and use -l yourfile to install it.

fhh@aaricia ~ $ cat > src.ubuntu/lst.pkgs
# Client DHCP
isc-dhcp-client

# OpenSSH server
openssh-server

# Editor 
 vim

# Pager
 less

^d

Disk image size

-s Size defined the size on hard drive image.

Partitioning VM

All type of VM partition schema can be imagined. You can defined it on file or from command line or mix command line and file.

### Paritions to VM Ubuntu ###
/:4G:xfs:defaults:::
sw:1G
/home:2G:btrfs
/srv

This file is equivalent to a command line containing :

genvm ...  -P :4G:xfs -P sw:1G -P /home:2G:btrfs -P /srv ...

The size of image must be grater than some of partitions size specified plus 1G (for last partition).

Set root password

root Password can be set from command line with option -p password.

Generate Ubuntu VM

Finally we run GenVM :

fhh@aaricia ~ $ su -c "genvm -b grub-pc -k linux-image-generic \
 -S http://archive.ubuntu.com/ubuntu/ \
 -n trusty \
 -t src.ubuntu \
 -l src.ubuntu/lst.pkgs \
 -s 10G \
 -P partitions.lst \
 -p root_password \
 -v \
 -V trusty ubuntu-trusty.vmdk"

Run the virtual machine

The virtual machine can be run from Qemu (or KVM) :

fhh@aaricia ~ $ qemu-system-x86_64 --enable-kvm --redir tcp:2222::22 -m 1024 ubuntu-trusty.vmdk

Connect to you VM from SSH :

fhh@aaricia ~ $ ssh -p 2222 root@localhost