Better vmbetter

How to create VM images using vmbetter

The minimega miniclass series

Sandia National Laboratories

Building a VM image with vmbetter

The most critical file needed to run a VM is the VM image file.

This can be a single file, a pair, or an entire filesystem.

But as many options as there are for launching and running a VM, they can be thought of in clear, categorical ways.

This module will discuss the types of VMs minimega can run, the image files needed to run those VMs and, most importantly, how to create those image files using vmbetter, part of the minimega tool suite.

So let's get started with the types of VMs you can build.

KVM vs Container

There are broadly two types of VMs minimega is capable of launching: KVMs and Containers

The details of how each work are beyond the scope of this tutorial.

However, it is worth pointing out some key differences, and some key trade-offs.

The kind of VM you decide to run in your experiment will be largely dictated by the needs of your experiment.

KVM

The Kernel-based Virtual Machine (KVM) can be described as a self-contained virtual machine which includes both the kernel and filesystem needed to run.

KVM technology works by turning Linux into a hypervisor, allowing it to act as a host to guest Virtual Machines.

Every KVM VM is implemented as a regular Linux process, and therefore has all the componenets needed by the hypervisor to run as a VM with dedicated virtual hardware.

Because KVM VMs have all the components needed to run as a self-contained Linux machine, they tend to require more resources to run.

Containers

With containers, instead of virtualizing the entire machine, including the hardware stacks, just the OS is virtualized.

The container sits on top of the physical host and its OS and shares the host OS kernel.

The host OS takes on the responsibility for running the processes within each container, and provisioning hardware resources for each.

A container only requires a filesystem with the various programs and files needed to run, and just enough of a virtualized OS to run it.

Consequently, containers require far fewer resources to run, and you can therefore run many more containers on a host compared to KVMs.

Types of VM image files

There are a number of image files you can use to launch a virtual machine or container.

vmbetter script

vmbetter can be used to produce a simplified Debian environment that is configured to the user's choosing.

The configuration files used by vmbetter allow for many choices. vmbetter itself has many runtime options.

To help simplify the former, we have provided an array of configurations files to get you started.

To help simplify the latter, we have provided a script that will run vmbetter with some sensible default options and settings for the provided configs.

vmbetter script

You can find this script in the minimega directory:

<minimega directory>/misc/vmbetter.bash

The script itself is straight-forward and we leave its useage as an exercise for the reader.

However, there are some important fundamentals to understanding how vmbetter configuration works.

Note: vmbetter produces a simplified Debian environment, however it is possible to create an Ubuntu VM. See the misc/vmbetter.bash script for examples.

vmbetter configuration

A vm image can be defined with a configuration file. minimega has a number of default files located in

misc/vmbetter_configs

These configuration files can (but not always) have an associated overlay directory. More on this later.

The configuration files contain a number of key sections:

vmbetter configuration

vmbetter overlay

The overlay directory is useful for placing files you would like to exist on the built VM

The directory structure is the same as that of a standard directory structure.

A file placed in <targetVM>_overlay/etc/foo/ will be in the VM under /etc/foo/

There can also be an init file in the overlay directory. Here is where you write any bash-type commands that are to be executed whenever the VM is launched.

Build miniccc.kernel and miniccc.initrd

A simple KVM image you can use is already configured in the vmbetter_config directory called miniccc.conf.

This image file comes preloaded with miniccc, the command and control component of minimega.

For more information on command and control, see module 07 - Command and control

To build this using the vmbetter.bash script, try the following command while in the minimega directory:

minimega$ sudo bash misc/vmbetter.bash miniccc

Build minirouterfs

vmbetter also lets you build file systems for containers.

One such container already defined in misc/vmbetter_configs is for minirouterfs

minirouterfs is a filesystem that contains miniccc and minirouter built in.

For more information on miniccc, minimega's command and control tool, see module 07 - Command and control

For more information on minirouter and minimega's router API, see module 06 - Experimental Network

To build this using the vmbetter.bash script, try the following command while in the minimega directory:

minimega$ sudo bash misc/vmbetter.bash minirouterfs

and more...

There are a number of configurations in the vmbetter_config directory.

Feel free to explore everything in there, and try building your own.

Don't forget to include a parent config in your own config if you want to build from an existing image.

Next Up...

Module 03: VM Orchestration

Thank you

The minimega miniclass series

Sandia National Laboratories