While I upgrade to Karmic, here’s a quick setup to get a virtual ubuntu server running on a real ubuntu server:
ubuntu-vm-builder kvm jaunty --hostname dev2 --addpkg openssh-server vim -d /usr/local/vms/dev2 --mem 256 --libvirt qemu:///system
This will create a jaunty jackalope ubuntu virtual server using the KVM hypervisor. The hostname will be dev2. It will add the openssh-server package as well as vim. It will put it in the /usr/local/vms/dev2 directory. It’ll allocate 256 Megs of memory for the machine. The libvirt options automatically adds your new machine to the qemu:///system domain.
Once you’re done you can run:
In the virsh shell type:
You should see your new machine listed.
To set up networking type ‘edit dev2′.
Change (or add) the following:
Leave out anything about a MAC address because virsh will automatically add that for you.
Now the hard part. You want to create a linux bridge.
If you have only one network interface on the box you’re going to need physical access. I’m going to assume that’s the case. [If you have a second, just leave it up and make sure you're ssh'ing in via that port]
ifconfig eth0 down
ifconfig eth0 0.0.0.0
brctl addbr br0
brctl addif br0 eth0
ifconfig br0 up
At this point your bridge is up and your virtual machine can use it, but the guest OS doesn’t have an IP of it’s own. So:
ifconfig br0 192.168.123.123 netmask 255.255.255.0
Now add a default gateway to your host:
route add default gw 192.168.123.1
Now comes another tricky part. If you’re running all this on a machine with a GUI, life is easy. I’m going to assume you, like me, run ubuntu server. You need to launch your new virtual machine and you need to connect to it using VNC. Lets say you have a MacBook and want to run the VNC client on that. Here’s what you do:
On the macbook launch a terminal. Go to root with: sudo su –
ssh -f -N -L 5900:127.0.0.1:88 root@your_host_machines_ip
On the host machine run:
ssh -f -N -L 88:localhost:5900 root@your_host_machines_ip
Now go and download Chicken of the VNC for your Mac.
Now on the host operating system run:
virsh start dev2
Then launch Chicken of the VNC and just connect to localhost. Bang you should have a console!
Now edit your network settings:
Just configure your network as per normal as if the machine was on your physical network. Something like:
iface eth0 inet static
And … unless I’ve forgotten a step which is quite likely … you should be up and running. Make sure the ssh server is running on your new server and try and ssh to your virtual server’s IP from the host machine.
If you can’t ping the default gateway make sure your firewall software (if you have any) isn’t interfering. If you run shorewall you want to change the following:
Edit the /etc/shorewall/interfaces file and change ‘eth0′ to ‘br0′
Also add routeback,bridge to br0 so it looks something like this:
net br0 detect routeback,bridge,tcpflags,norfc1918,routefilter,nosmurfs,logmartians
Restart shorewall and give it a try.
Now if you want to upgrade your new virtual Jaunty machine to karmic, simply do a:
apt-get install update-manager-core
I’ll try to include the settings in the host /etc/network/interfaces for br0 soon.
If you’re still stuck, here are some great links:
Introduction to Linux bridging.
Info on libvirt.
Setting up a bridge.
ubuntu-vm-builder short guide.