The runvmm script

To get people started, I've written a little script that runs the virtual machine monitor for you, and sets up ethernet addresses, etc. Source is available from the Linux-on-Linux page.

runvmm creates a virtual machine at an address; the address is a small number starting at one. It is used for determining which tapaddress interface to use, which root file system to use, and the IPv4 address of the virtual machine.

The script can be set up to use ethernet bridging or iptables; it can either set the root filesystem to use DHCP or a static IP address from a consecutive range of addresses available on the same network that the host's default route is on.

The Virtual Machine needs a root disc. runvmm assumes a root disc in sda1, which is in ${rootpath}/address/sda. Additional disc images can be put into the same directory, called sdb, sdc etc., and will be found by the virtual machine.

runvmm can also be used to create a suitable disk image using a tarball or disk image of a root file system.


runvmm [ -k ] [-n ncpu] [ -a address] [-m memsize] [ -c diskimage] [-D disksize] [ -C configfile] [ -r diskimage] [-p cpushare] [-P] linux-args ...


runvmm invokes vmm(1), setting up networking, root password etc., on the disk image as it goes.


-a address
Specify which instance of /dev/taptapNumber to use, and what IP address to assign to the new virtual machine. Assigned IP addresses start at $netbase.$hostbase. By default, this is the address of the host machine's external network interface, but it can be overridden in a config file.
-n ncpu
Start a virtual machine with ncpu processors. This passes -n ncpu to vmm, and appends maxcpus=ncpu to the linux arguments.
-m memsize
Create the machine with memsize memory. memsize is in bytes, but the suffixes k M and G are recognised. Memory is allocated by mapping a file in /tmp; if there is insufficient real memory, the virtual machine will swap to that file, and be slow.
-C configFile
Read defaults from configFile. See CONFIG below for what can go into a configFile
-c diskImage
Copy diskImage to the simulated root disk. diskImage may be a gzipped or bzipped tarball, or a disk image.
Keep the temporary and log files around after starting the virtual machine.
-D Disksize
When using -c, create a disk of size Disksize. The size must be suffixed with a multiplier k, M or G.
-r diskbase
Use diskbase as the base of the disk name. For example, -r /home/disks/sd means that files of the form /home/disks/sda, /home/disks/sdb, etc., will be made available to the virtual machine as /dev/sda, /dev/sdb, etc. The root device will be diskbasea1 (e.g., if you specify -r /home/disks/sd, then root=/dev/sda1 will be appended to the command line, and the manipulations that runvmm does will be to that file.) If this option is not specified, the default is ${HOME}/disks/$address/sd
-p centipercent
Set the percentage of processor that this virtual machine gets to centipercent times 100. This relies on having an entitlement scheduler installed on the host, for example the PlugSched project
Set the root password on the new disk image before starting the virtual machine.


Start the virtual machine on vmlinux in the current directory. vmm will be invoked as:
vmm -n 1 vmlinux root=/dev/sda1 simscsi=$HOME/disks/1/sd simeth=eth0
runvmm -c $HOME/disks/redhat.tgz -D 512M -a 2 -n 4
Create a new disk image called $HOME/disks/2/sda, populate it from the tarball $HOME/disks/redhat.tgz, modify the resulting image to have an appropriate hostname and IP address, then run as a four processor emulated system.


The configuration file ($HOME/.vmmrc or as specified on the command line) sets up the network base, etc., for the virtual machine. The file is a shell script in which variables can be set.

Variables that if set in the file make a difference are:

Set to 1 if the guest's network is to be attached to ethernet bridge br0; set to 0 to set up NAT.
The full path name to the vmm executable. Default is $HOME/vmm/userspace-afterburner/userspace/vmm
Set to 1 if the network address is defined in this file; otherwise dhcp will be used.
The network IPv4 address on which the virtual machine's interface will live. By default, runvmm chooses the network of the external interface of the host. Only used if STATIC is 1.
The address of the gateway machine. By default this is the same as the host's. Only used if STATIC is 1.
The netmask for the virtual machine's network interface. By default, this is the same as the host's Only used if STATIC is 1.
The broadcast address for the virtual machine's network interface. By default, this is the same as the host's Only used if STATIC is 1.
The last octet of the base address for all virtual machines on this host. This octet is added to the address parameter and combined with netbase to give the IPv4 address of the virtual machine. Only used if STATIC is 1.
All but the last octet of a dotted-quad IPv4 address. The IP v4 address of the virtual machine's ethernet interface is calculated as $netbase.`expr $hostbase + $address` Only used if STATIC is 1.
The address (default 1) is added into the hostbase to give the virtual machine's IPv4 address, and is also used as the number of the tap device to use, and to select which disk image to use as the root device. address? is overridden by the -a option.
Same as the -m parameter. Default: 512M.
Same as the -n parameter. Default: 1
Directory containing disk images. Each virtual machine has a subdirectory in this directory, named by address, and an image named sda within that subdirectory. So for example, the virtual machine started with runvmm -a2 will use as its root disk partition 1 on $rootpath/2/sda.
For other parameters, read the runvmm source.

Example CONFIG file



  • /tmp/vm.[0-9]* — mapped physical memory for the virtual machine.
  • ~/.vmmrc — configuration file.
  • vmlinux — the kernel image
  • $HOME/disks/address/sda — default root filesystem
  • /tmp/x$$ — trace output from VMM.



    Almost no error checking.