What about setting up a little datacenter at home ?
That was my decision several months ago, when I started to think about building my “own cloud” at home.
For that, you need one ĥysical server, and a good Linux distribution running a virtualization environment. I chose KVM over Ubuntu.
Installation
As I installed that some time ago, I selected Ubuntu server 10.04 distribution.
Not really a “slim” distribution, but I’m used to Ubuntu features and issues. Moreover, the .deb package mechanism is simple, and this is what I was looking for… My own cloud, but with limited efforts… 🙂
Once Ubuntu server installed, with a fixed IP address (“good practice” in such cases, I think), you need to install additional packages to get KVM up and running.
Software to install
From a terminal prompt enter:
sudo apt-get install qemu-kvm libvirt-bin ubuntu-vm-builder
After installing libvirt-bin, the user used to manage virtual machines will need to be added to the libvirtd group. Doing so will grant the user access to the advanced networking options.
sudo adduser $USER libvirtd
You will also need utilities to manage the Network interface, especially the bridge notion:
sudo apt-get install bridge-utils
Setup bridge configuration for network interface
For that, you need to modify your host network interface parameters (file /etc/network/interfaces):
# This file describes the network interfaces available on your system # and how to activate them. For more information, see interfaces(5). # The loopback network interface auto lo iface lo inet loopback # The primary network interface # # Commented to remove DHCP #iface eth0 inet dhcp # # Added BR0 for bridging auto eth0 iface eth0 inet manual auto br0 iface br0 inet static address 192.168.0.3 netmask 255.255.255.0 network 192.168.0.0 broadcast 192.168.0.255 gateway 192.168.0.250 bridge_ports eth0 bridge_stp 0 bridge_fd 0 bridge_maxwait 0
(of course, adjust to your own parameters, such as subnet, gateway, “normal” interface – eth0 in my case – and bridge interface to create – br0 in my case)
Verify Installation
You can test if your install has been successful with the following command:
$ virsh -c qemu:///system list Id Name State ----------------------------------
Additional optional software
If you want additional scripts (recommended) to support your VM management, install virt-install which is part of the python-virtinst package. To install it, from a terminal prompt enter:
sudo apt-get install python-virtinst
Note that this will install additional packages: python-libvirt virtinst
In order to get a GUI, you should install Virtual Machine Manager
The virt-manager package contains a graphical utility to manage local and remote virtual machines. To install virt-manager enter:
sudo apt-get install virt-manager
Create virtual machines
There are plenty of ways of creating virtual machines:
- via the GUI (virt-manager)
- via the virtual shell (virsh)
- using special commands (virt-clone,…)
- directly modifying XML files (hard times !!!)
- …
At first, I must admit I used the GUI.
It is a simple interface (that you can run on your laptop, as it allows remote connection to the hosting server via SSH)
When you start it, you get a usual look & feel (especially if you are already using other Virtualization environments, such as VMWare or VirtualBox).
The only issue I faced using this GUI was the network setup.
I wanted to create VM used to deliver services within my personal network. As such, I wanted them to use a fix IP Address.
I could have setup static IPs in my DHCP server, but I wanted to do it “old fashioned-way”: setting up fix IP addresses within the guest OS.
By default, this is not possible through the GUI.
Here is the workaround:
Once a Virtual Machine is created with the GUI, and before starting it up, you will need to modify its settings to get the bridge up and running.
Edit its xml configuration file (directory /etc/libvirt/qemu) and replace the network section (starting with
<interface type='bridge'> <mac address='52:54:00:60:94:1f'/> <source bridge='br0'/> </interface>
(of course, adjust to your VM mac address, and your bridge interface created in previous step)
Then, you can start your VM that will be granted a network interface bridged on your real physical server network interface…
A part from that, just… enjoy !