Linux Virtualization with Xen
Pages: 1, 2
Building a Different Virtual Host
This is Fedora on Fedora, but I promised to give you a Debian on a Fedora. This is where you need
debootstrap. It comes in an RPM, but if you want a correct installation you need to find an up-to-date config script for Sarge, which you can easily find on any Debian box you have around. From there, again it's a matter of creating a new LVM entry, mounting it, and using
debootstrap to populate the Debian instance:
$ debootstrap --arch i386 sarge root.hope/ http://ftp.be.debian.org/debian
The Debian box has a similar config file:
kernel = "/boot/vmlinuz-2.6.11-1.1366_FC4xenU" memory = 128 name = "newhope.x=tend.be" nics = 1 vif = ['ip = "10.0.11.14", bridge=xen-br0'] disk = ['phy:vm_volumes/root.hope,sda1,w' ,'phy:vm_volumes/var.hope,sda3,w' ,'phy:vm_volumes/cvsroot.hope,sda4,w' ,'phy:vm_volumes/swap.hope,sda2,w' ,'phy:vm_volumes/home.hope,sda5,w' ,'phy:vm_volumes/svnroot.hope,sda6,w' ] root = "/dev/sda1 ro"
xm create newhope, you should get a listing like:
[root@xen xen]# xm list Name Id Mem(MB) CPU State Time(s) Console Domain-0 0 891 0 r---- 62.3 dokeos.x-tend.be 1 127 1 -b--- 24.6 9601 newhope.x-tend.be 2 127 1 -b--- 177.2 9602
Basic Xen virtual machine management is simple. Use
xm shutdown and
xm destroy, respectively, to do a clean shutdown or an immediate domain kill. For console access:
$ xm console $id # and $ xencons localhost $port
are similar and give you a better console than just a telnet localhost
$port. (The port is 9600 + the
$id of the particular virtual machine.)
Networking Virtual Hosts
Of course, you probably want to connect your virtual machines to the network. You first need to understand the bridging tool
brctl. Xen provides one or more virtual network interfaces to your guest hosts, but in your Domain0 you will also see some changes to your default network config.
For each interface you define in a virtual machine, Xen will create a
vifx.y interface, where x is the domain ID and y is the number of the interface in your virtual machine. For example,
vif1.1 refers to
eth1 in the domain with ID 1.
There are different ways of getting networking active, but I will show only one. Suppose that your network is 192.168.11.0 and your physical machine usually is at 192.168.11.2. You want to add your first virtual machine on 192.168.11.3. Log in to your virtual machine and configure the
eth0 in the virtual machine to have the appropriate IP address, just as you would do if it were a physical machine.
Now you want to have physical network interface and the interface of your virtual machine (
vifx.y) in a bridge. If you haven't already created
brctl addbr xen-br0 to do so, and then add both interfaces to it. Where
vif1.0 is the first Ethernet device in your first domain, the commands are:
$ brctl addif xenbr0 eth0 $ brctl addif vif1.0 HOSTA:~ # brctl show bridge name bridge id STP enabled interfaces xen-br0 8000.000bdb90c517 no eth0 vif1.0
vif1.0 don't need an IP address; you can put your 192.168.11.2 on the
xen-br0 interface and route all the traffic for the 192.168.11.0 network to that
xen-br0 interface. With this done and IP forwarding enabled, you should be able to reach the network. You should now be able to go from your virtual machine to other machines on the network and vice versa.
With Intel's announcement that it will ship its VT CPUs soon, operating systems without freely available source will soon run in a Xen environment. The 3.0 release happened in early December 2005, and every major Linux distribution is planning on using Xen somehow. Red Hat wants it in the kernel, and Suse already has added options in Yast for it.
The virtualization and consolidation market is fast changing, and Xen is playing an important role there!
Kris Buytaert is a Linux and open source consultant operating in the Benelux. He currently maintains the openMosix HOWTO.
Return to the Linux DevCenter.
2007-11-04 16:56:41 adulttoothbrush [View]
2006-02-18 14:48:29 JohanBV [View]
2006-02-05 00:21:25 TracyReed [View]
2006-01-30 01:13:24 NickyPeeters [View]
Config to define SLA between Virtual Domains ?
2006-01-27 02:18:07 NickyPeeters [View]