Chinaunix首页 | 论坛 | 博客
  • 博客访问: 1918449
  • 博文数量: 312
  • 博客积分: 10170
  • 博客等级: 上将
  • 技术积分: 3667
  • 用 户 组: 普通用户
  • 注册时间: 2005-10-26 15:27
个人简介

可干百业,无一精通。

文章分类

全部博文(312)

分类: LINUX

2007-11-22 20:13:28

Building Xen from source on Ubuntu to run Windows

       -------Posted by Fraser Campbell on Friday, August 04, 2006


For unix administrators one key to a pleasant life is having a stable and friendly workstation from which to launch scripts, X clients, test/debug programs, etc. As an added bonus that workstation should be portable so that you can hack whether you are at the office, in a train or on the beach sipping your beverage of choice.

As a Linux administrator for over 10 years my choice of workstation is a Linux desktop. However, running the Linux desktop in some environments can be challenging as there are many vendors who force the use of their tools to the exclusion of others.

Among the numerous barriers I have encountered are:

  • Microsoft Exchange/Outlook combination
  • Microsoft Visio
  • spreadsheets which think they are applications (macros)
  • Lotus Notes
  • websites that don’t function on anything but Internet Explorer

Cutting the story short, Microsoft Windows is a necessary evil for most unix administrators unless they have the fortune of working for small highly-focused technical companies.

For the past year my goal has been to run Windows as a guest on a Xen enabled laptop – avoiding hacks such as Citrix and Terminal Server.

Thanks to the common availability of Intel VT extensions there is now a good chance that this can be done. What follows is my account of how I did it …

I have purchased a Dell Inspiron 6400 laptop. The basic specs are:

  • Intel Core Duo @ 1.83 GHz (T2400), 2MB cache
  • 1 GB RAM
  • 120 GB Hard Drive

My Inspiron comes with a BIOS option for enabling/disabling VT extensions (disabled by default on my laptop). I also had the opportunity to look at a Toshiba Satellite A100-SK8 and an HP Pavilion dv1660ca, both of these laptops are also VT capable (though interestingly no BIOS option to turn it off). So, it would appear that most laptops with Core Duo processors (T2300, or greater) should be Intel VT capable.

If you want to be certain that VT is enabled on your laptop then the best bet is to bring a bootable Linux CD to the store with you and (with sales clerk’s permission) boot up Linux. Look at /proc/cpuinfo to see if the vmx processor flag is present, see below for example:

fraser@dell:~$ cat /proc/cpuinfo
processor : 0
vendor_id : GenuineIntel
cpu family : 6
model : 14
model name : Genuine Intel(R) CPU
T2400 @ 1.83GHz
stepping : 8
cpu MHz : 1830.982
cache size : 2048 KB
fdiv_bug : no
hlt_bug : no
f00f_bug : no
coma_bug : no
fpu : yes
fpu_exception : yes
cpuid level : 10
wp : yes
flags : fpu tsc msr pae mce cx8 apic mtrr
mca cmov pat clflush dts acpi mmx
fxsr sse sse2 ss ht tm pbe nx
constant_tsc pni monitor vmx
est tm2 xtpr
bogomips : 3663.00

A few notes on the core duo:

  • the core duo is a dual core processor so you will see 2 processors listed (if you have SMP kernel installed)
  • though the hyperthread (ht) flag is shown it would appear that the processor is not hyperthreaded (at least in Linux). If anyone has details on that please leave some comments, I’d be interested in hearing why ht doesn’t give us 4 “processors” in Linux.
  • the core duo is not 64bit capable (note lack of lm flag), not much of a concern for a laptop of course.

With my laptop in hand the first step was to install Linux, Ubuntu is my current favorite Linux desktop distribution so I grabbed my Ubuntu 6.06 install CD and performed the install. If you would like to check out Ubuntu go to and you can get 10 install CDs mailed to you at no charge – or if you have broadband just download your own copy.

I am going to spare you the details on installing Ubuntu as that is well documented elsewhere. Briefly, here are the steps that I took:

  • boot ubuntu-6.06-alternate-i386.iso CD image, select text-mode install
  • delete all partitions except first which contains some Dell utilities (/dev/sda1)
  • create 2 partitions (128MB /boot and one large physical volume for LVM)
  • make logical volumes for /, /var, /home, /opt, /tmp and /usr – all fairly small and using reiserfs so that I can resize later as needs arise

The complete install process took about 1/2 hour. At the end of it I had a pure Ubuntu install with 1024×768 video resolution (should be 1280×800), functioning sound and functioning wifi – everything plug and play (although I haven’t tried and don’t care about the modem).

Now that Ubuntu is installed, time to get Xen up and running …

To successfully build and install Xen from source there are a number of packages that you will need to install first. The build requirements are not well documented (particularly for Ubuntu) so here they are:

  • bcc
  • binutils
  • bridge-utils
  • gcc
  • libncurses5-dev
  • libsdl-dev
  • libsdl1.2debian-all
  • make
  • python-dev
  • tetex-extra
  • transfig
  • zlib1g-dev

Not all of these packages are strictly necessary (some are only needed to build documentation).

A few of the required packages are not in Ubuntu’s main repositories so you must enable the universe repository to fetch them – go to System Menu, select Software Properties, add Universe and Universe Security.

I chose to use the testing version of Xen, this version is meant to be stable but it has some additional bugfixes over the stable branch (currently the testing source appears to be labelled as Xen 3.0.2-3). Below are all the commands that you should need to prepare your system and fetch/build/install Xen:

root@ubuntu:/tmp# apt-get install bcc binutils
bridge-utils gcc libncurses5-dev libsdl-dev
libsdl1.2debian-all make python-dev tetex-base
transfig zlib1g-dev
root@ubuntu:/tmp# wget
root@ubuntu:/tmp# tar xzf xen-3.0-testing-src.tgz
root@ubuntu:/tmp# cd xen-3.0-testing
root@ubuntu:/tmp# make install

Wait for about 40 minutes and Xen should be completely built and installed.

There are a few more housekeeping steps in order for you to easily boot Xen, see below …

Edit /etc/init.d/xend and add the following line immediately after the check for /proc/xen/capability:
mkdir -p /var/run/xenstored

Modify init symlinks so that /etc/init.d/xend will be started on boot by running the following commands:

root@ubuntu:/tmp# update-rc.d xend start 99 2 3 4 5
. stop 01 0 1 6 .

Create a ramdisk for your new Xen kernel:

root@ubuntu:/tmp# cd /boot
root@ubuntu:/boot# mkdir xen
root@ubuntu:/boot# mkinitramfs -o
xen/initrd.img-2.6-xen 2.6.16.13-xen

Move the xen related boot files into a dedicated subdirectory so that Ubuntu’s grub updater will not be confused when you next update the standard Ubuntu kernel:

root@ubuntu:/boot# mv *xen* /boot/xen

Modify your grub configuration to include a config option for booting Xen, in my case the following was added to the end of /boot/grub/menu.lst:

title Xen testing / XenLinux 2.6
kernel /xen/xen-3.0.gz console=vga
module /xen/vmlinuz-2.6-xen root=/dev/mapper/system-root ro console=tty0
module /xen/initrd.img-2.6-xen

Make sure to add the Xen boot configuration at the end of menu.lst otherwise Ubuntu’s grub updater is likely to remove your Xen boot section on the next ubuntu kernel update.

Now that you have Xen installed you should reboot your computer and make sure that you select the Xen boot option from the grub menu. You are now ready to attempt installing Windows on Xen.

At this point I ran into a rather major fly in the current Xen ointment. I’ll skip that detail until the end …

XenSource has provided an excellent document titled , this document is targeted at Windows 2003 but Windows XP Home edition works just fine as well. The only different step that I took was to install Windows directly from CD (/dev/hdc) rather than using the intermediate step of generating an ISO file. I used the Dell issued Windows CD that came with my laptop.

Windows installs and seems to operate quite quickly, overall the laptop feels completely responsive throughout the install and post-install – this is pretty much expected as the laptop does have 2 processing cores.

For good measure I set up a second HVM guest using the stock Debian Sarge netinstall CD, complete (very basic) sarge installation went flawlessly and only took 11 minutes.

All things considered the Xen HVM support appears to work as advertised. It is straightforward to set up once you have the hardware capable of driving it and I haven’t observed a hint of instability after several evenings of use.

So, lastly, let’s talk about the fly in the ointment that I mentioned …

The Dell inspiron 6400 comes with a BCM4401-B0 network card. To drive this network card you need the Linux kernel module b44. The b44 driver does not work under Xen.

I have yet to track down whether there is a fix for the b44 problem but the issue was known at least back to April of this year (see mailing list post ).

Obviously having Xen fully functional along with HVM guests is quite useless if you cannot connect to the outside world. I will attempt to find a fix for the b44 issue when time permits, if anyone does know of an existing resolution please let me know.



一直想用Xen,很兴奋的下了xen4盘后,发现却是64的,吧xen官方翻了个底朝天,也没发现有32位的xen4,最近一直在下源码的4个光盘,准备自己进行编译。而这个,太有指导性了。感谢vmware.cn的sudison提供。谢谢您!附原文地址。


阅读(2509) | 评论(0) | 转发(0) |
0

上一篇:.edu邮箱

下一篇:高人高论:IT版

给主人留下些什么吧!~~