LinuxDevCenter.com

oreilly.comSafari Books Online.Conferences.

We've expanded our Linux news coverage and improved our search! Search for all things Linux across O'Reilly!

Search
Search Tips

advertisement

Listen Print Discuss Subscribe to Linux Subscribe to Newsletters

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"

After running 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 xen-br0, use 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

Your eth0 and 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.

Looking Ahead

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.


Have a question or a comment for Kris? Here's the place.
You must be logged in to the O'Reilly Network to post a talkback.
Post Comment
Full Threads Oldest First

Showing messages 1 through 5 of 5.

  • Toothbrush Manufacturer
    2007-11-04 16:56:41  adulttoothbrush [Reply | View]

    Http://www.chinabboss.com
  • Xen VPS
    2006-02-18 14:48:29  JohanBV [Reply | View]

    Nice article! I've been playing with the Xen Demo CD, which was quite nice and booted up mulitple OS'es at once (VERY EASILY)! Xen is really the future I suppose... especially with VT and Pacifica.

    If you want a server based on Xen, a hosted solution:
    There are some XEN VPS providers (http://www.budgetdedicated.com/) (BudgetDedicated, and Bytemark also very soon) that offer Xen as a hosted solution. They have an excellent datacenter location in Europe and good performing hardware. I think I will never go back to a dedicated host again, because it's more expensive and actually has less performance (because VPS providers can buy better hardware because they collect the dedicated hosting revenue multiple times).

    Really worth it! 7 Day Trial accouns are even for free at BudgetDedicated (http://www.budgetdedicated.com/) .

    --
    Johan
  • Memory overcommit
    2006-02-05 00:21:25  TracyReed [Reply | View]

    The biggest thing Xen is lacking right now is memory overcommit. I'm afraid this will add significant complication to the Xen kernel but I feel it is necessary. Say for example my physical hardware has 1G of RAM in it and I want to run 2 domains. My domains usually only need 256M of RAM each to operate but on rare occasions need up to 768M. I am forced to make them swap or buy 2G of RAM for my machine. It would be nice if Xen could manage the physical RAM in a smart way and provide the memory to the domain that currently needs it.

    A more obvious example might be in the case of virtual hosts. Maybe I want to sell Xen instances or give them to my friends so they can learn Linux. When a domain is not active all of its pages of memory should be swapped out so other domains can use it. I should be able to provision a few dozen lightly used xen domains on a box with 2G of RAM. But as things stand now I can only provision 4 512M domains on such a box.

    My friend may only log in once a week to play with his Linux instance. Or maybe a low volume web server rarely gets hits but does need to be online to service the hits when they come. It seems silly to have so much memory sitting idle, especially when memory is still not terribly cheap and PC's still usually can't handle more than a few gig. Idle memory is wasted memory.
  • Small typo
    2006-01-30 01:13:24  NickyPeeters [Reply | View]

    When setting up /dev/zero the FC4 chrooted installation :

    MAKEDEV -d /path/dev -x zer should be :
    MAKEDEV -d /path/dev -x zero

  • Config to define SLA between Virtual Domains ?
    2006-01-27 02:18:07  NickyPeeters [Reply | View]

    Would be nice for a follow-up article to deal with the configuration issues of defining SLA-like relations between virtual domains and their CPU usages etc...


Tagged Articles

Be the first to post this article to del.icio.us

Sponsored Resources

  • Inside Lightroom
Advertisement

Sponsored by:

O'Reilly Media

©2009, O'Reilly Media, Inc.
(707) 827-7000 / (800) 998-9938
All trademarks and registered trademarks appearing on oreilly.com are the property of their respective owners.
About O'Reilly
Academic Solutions
Authors
Contacts
Customer Service
Jobs
Newsletters
O'Reilly Labs
Press Room
Privacy Policy
RSS Feeds
Terms of Service
User Groups
Writing for O'Reilly
Content Archive
Business Technology
Computer Technology
Google
Microsoft
Mobile
Network
Operating System
Digital Photography
Programming
Software
Web
Web Design
More O'Reilly Sites
O'Reilly Radar
Ignite
Tools of Change for Publishing
Digital Media
Inside iPhone
O'Reilly FYI
makezine.com
craftzine.com
hackszine.com
perl.com
xml.com

Partner Sites
InsideRIA
java.net
O'Reilly Insights on Forbes.com