box.matto.nl
[tux]

This page: Home » » Run virtual machines on a laptop howto

Virtualisation on a laptop

The use of virtual machines is an awsome way of doing things.

Multiple solutions to run virtual machines on your laptop

Linux offers more then one way to run virtual machines on your laptop. Here are the ones I prefer:

Running virtual machines on a laptop is not allways easy. This is because the wireless network interface often fails to become a bridge.

Here is how I do it.

KVM with VDE

kvm banner

The following examples are based on these presumptions:

Use the virtual switch VDE. I run the following script before starting kvm virtual machines:

#!/bin/sh

modprobe kvm_intel
modprobe tun

vde_switch -tap tap0 -d

ifconfig tap0 192.168.254.254

echo "1" > /proc/sys/net/ipv4/ip_forward
/sbin/iptables -t nat -A POSTROUTING -o wlan0 -j MASQUERADE

This script is run as root on the laptop (the host). In the last line of the script wlan0 is used. This is the network-interface of my laptop.

After this, as a user I start the kvm virtual machine with the following command:

sudo vdeq kvm -net nic -net vde,vlan=0 <name-of-image> -m 512

Inside the virtual machine, choose an ip-address in the range 192.168.254.xxx and set the gateway to 192.168.254.254:

Example 1: setting the virtual machine to 192.168.254.12

In the kvm virtual machine do as root:

ifconfig eth0 192.168.254.12 up
route add default gw 192.168.254.254

The address of the nameserver in /etc/resolv.conf can be your "normal" nameserver.

This way the kvm virtual machines have a link to the outside world. This means you can do a netinstall this way or do something like an apt-get update && apt-get upgrade.

From the laptop (the host) there is a network-connection to the virtual machines (so pointing your webbrowser to 192.168.254.12 on your laptop will show the website on the webserver of the virtual machine off example 1 above).

Other machines on the network can't connect to the virtual machine without adding a routing. This can be added in the following way:

route add -net 192.168.254.0 netmask 255.255.255.0 gw <ip-number of the laptop (host)>

Do this on other machines in your network in order to reach your kvm virtual machines in the 192.168.254.xxx ip-range on your laptop.

Multiple kvm virtual machines

In order to run multiple virtual machines ,the machines do have to have different mac addresses. It is easy to change the mac address of a virtual machine.

In the kvm virtual machine do the following:

ifconfig eth0 down
ifconfig eth0 hw ether <mac-address>
ifconfig eth0 up

When everything works, put the mac address in the network startup script to make the change permanent (in Debian, this is in /etc/network/interfaces).

When starting multiple kvm virtual machines this way, they have a network-connection to each other. So this way you can test some kind of client-server model with two kvm virtual machines.

Running openvz on a laptop

openvz banner

It is fascinating that networking with openvz works right out the box. When you give your openvz virtual machine an ip address in your "normal" network range, then both from your laptop (the host) as well as from other machines in the network (and within the same range) the openvz virtual machine can be accessed.

Running LXC Linux Containers on a laptop

LXC Linux Containers are also great on a laptop. See the Running LXC Linux Containers on a laptop page.

Last updated: $Date: 2010-12-17 18:35:01 $

Walk through this site
← previous page next page →