Install Xen 4.3.1 on Ubuntu 12.04 LTS from source

0. Install Xen Dependencies

# apt-get install bridge-utils build-essential libncurses-dev python-dev uuid uuid-dev libglib2.0-dev libyajl-dev bcc gcc-multilib iasl libpci-dev mercurial flex bison libaio-dev build-essential gettext libpixman-1-dev bin86 gawk bridge-utils iproute libcurl3 libcurl4-openssl-dev bzip2 module-init-tools transfig tgif texinfo texlive-latex-base texlive-latex-recommended texlive-fonts-extra texlive-fonts-recommended pciutils-dev mercurial make gcc libc6-dev zlib1g-dev python python-dev python-twisted libncurses5-dev patch libvncserver-dev libsdl-dev libbz2-dev e2fslibs-dev git-core uuid-dev ocaml ocaml-findlib libx11-dev bison flex xz-utils libyajl-dev

1. Download Xen Source Code

# git clone git:// ~/xen
# cd ~/xen
# git checkout -b RELEASE-4.3.1 RELEASE-4.3.1

2. Compile and Install Xen from Source

# ./configure
# ./make -j4 dist
# ./make install 

Note that the option “-j4” tells the compiler to use 4 cores(it uses 2 cores by default).

3. Update GRUB
Delete duplicate entries in /boot

# cd /boot
# rm -rf xen.gz xen.4.3.gz xen.4.3.1.gz xen-syms-4.3.1

Set priority for loading Xen-compatible kernel at boot

# mv /etc/grub.d/20_linux_xen /etc/grub.d/09_linux_xen
# update-grub

4. Load Xen Services at Boot

# update-rc.d xencommons 20 19
# update-rc.d xendomains 21 22
# update-rc.d xen-watchdog 23 22

5. Update /etc/

# ldconfig

This step is important since the system will complain about missing library files if not do so.

6. Configure Virtual Network
Assuming we use DHCP for VMs. Modify the network configuration as follow.

# vi /etc/network/interfaces
auto eth0
iface eth0 inet manual

auto xenbr0
iface xenbr0 inet static
        bridge_ports eth0

7. Manage Storage for VMs
Assuming we use LVM to manage storage for VMs. It is suggested to spare a dedicated partition for VM storage.

# pvcreate /dev/sda3
# vgcreate vg0 /dev/sda3

Now you can find the volume group at /dev/vg0

8. Reboot

9. Create a VM for Test
Check if Dom0 is running

# xl list
Name                                        ID   Mem VCPUs	State	Time(s)
Domain-0                                     0 11962     8     r-----    8582.6

Check Xen’s configuration

# xl info

Create a logical volume(LV) for a new VM

lvcreate -nwin7 -L20G vg0

Create the .cfg file for the VM. Here we’ll install Window 7 32-bit on a VM.

# vi win7.cfg
kernel = 'hvmloader'
builder = 'hvm'

## number of cores ##
vcpus = '2'

## memory size ##
memory = '4096'

## storage: use the LV we just created ##
disk = [
## name of the VM ##
name = 'windows'

## network configuration ##
vif = [ 'mac=00:16:3E:51:20:4C,bridge=xenbr0,model=e1000' ]

## events policy ##
on_poweroff = 'destroy'
on_reboot = 'restart'
on_crash = 'restart'

## boot priority ##
boot = 'dc'
acpi = '1'
apic = '1'
viridian = '1'
sdl = '0'

## VNC configuration ##
vnc = '1' ## 1 or larger numbers to turn on; 0 to turn off ##
vnclisten = '' ## network it listens to ##
vncdisplay = '6' ## VNC port ##
vncpasswd = ''

stdvga = '0'
usb = '1'
usbdevice = 'tablet'

10. VIew the VM via VNC Viewer
Use a computer with GUI to do so. Assuming we use a computer with Ubuntu running on it.

We need to install a VNC viewer first. Any type of VNC viewer should work. Here we use gvncviewer.

# apt-get install -y gvncviewer

Then connect to the VM with it

# gvncviewer

You will get a view of the VM if everything goes smoothly. Have fun!

11. Troubleshooting

  • cannot open shared object file: No such file or directory
  • Solution:

This entry was posted in Xen. Bookmark the permalink.

2 Responses to Install Xen 4.3.1 on Ubuntu 12.04 LTS from source

  1. Pingback: Xen Installation | gumdaeng

  2. Satyen Desai says:

    I’m following these steps as-is to compile xen on Ubuntu 14.04 and 12.10 Desktop (32bit version). “make dist” and “make install” completes without any error. But, I don’t find any xen*.gz images in /boot. “upgrade-grub” also doesn’t find any xen images to boot, so no option for xen is added in grub menu.

    How can I verify that build has been successful? Any specific files that I can look for?

    Any other pointers to debug this further will be of great help.

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s