As I have to play around with some
OSD devices for my diploma thesis, I felt the urge to bring up some virtual machines for this...
Xen has no Dom0 support in mainline kernels, so it was out of scope for installation on my laptop, where I like to run current and unpatched vanilla kernels.
The next though was using KVM. The CPU of my ThinkPad has VMX-support, so let's go.
I could not have been much simpler:
Build kernel modules for KVM and your CPU flavour and load them
Set up disk image or logical volume (I chose using a LV for performance reasons)
Set up a bridge for network connectivity
On Debian(based) systems this can be easily done by installing the bridge-utils package and putting the following stanza into /etc/network/interfaces:
# Bridge for virtual machines
auto br0
iface br0 inet static
address 10.0.0.1
netmask 255.255.255.0
If you want your virtual machine(s) to be able to connect to the internet, you have to activate routing on your box, which could be done by editing /etc/sysctl.conf for example:
(Don't forget a sysctl -p after edit for activating the changes be activated without reboot.)
# Uncomment the next line to enable packet forwarding for IPv4
net.ipv4.ip_forward=1
Furthermore you most likely will need to activate NAT for the VM ip range, for example by adding the following command to your /etc/rc.local file:
(Don't forget to also type this into a root-shell, to let it work without reboot.)
iptables -t nat -A POSTROUTING -s 10.0.0.0/24 -j MASQUERADE
As the default network connection script on Debian tries some magic - which is not strong enough for this case - to figure out which bridge to connect the VM NICs to, you may have to use a different script without magic (/etc/kvm/kvm-ifup_private):
#!/bin/sh
/sbin/ifconfig $1 0.0.0.0 up
/usr/sbin/brctl addif br0 $1
exit 0
Set up a KVM virtual machine
Command for installation:
kvm -drive file=/dev/mapper/vg_pandora_crypt2-lv_osd1,cache=none,if=virtio,boot=on -cdrom /local/machines/debian-503-i386-netinst.iso -boot d -m 512 -net nic,model=virtio -net tap,name=tap0,script=/etc/kvm/kvm-ifup_private
Command for regular use (maybe you want to add the -nographic option):
kvm -drive file=/dev/mapper/vg_pandora_crypt2-lv_osd1,cache=none,if=virtio,boot=on -m 512 -net nic -net,model=virtio tap,name=tap0,script=/etc/kvm/kvm-ifup_private
While installing Debian into the VM, blog about it.
Search half an hour for the boot=on flag of the drive, to get it booting...
Update:
I added the model=virtio option to the -net nic parameter, as I did not get anything like network bandwith without it.