Sunday, February 05, 2012

Install XEN dom0 and domU on Ubuntu 11.10

I had trouble getting Xen working on Ubuntu 10.04 and had to do many things, in fact still failing with LVM. Luckily with Ubuntu 11.10 installing Xen dom0 and domU is much easier, here is the steps to get dom0 working on Ubuntu.

Creating dom0


Login as root (sudo su)

Install required packages and the hypervisor

apt-get install xen-hypervisor-4.1-amd64
apt-get install xen-utils-4.1
apt-get install xenwatch
apt-get install xen-tools
apt-get install xen-utils-common
apt-get install xenstore-utils
apt-get install virtinst
apt-get install virt-viewer
apt-get install virt-manager

Now you have installed everything you need to run your dom0. Before you restart your system edit “/etc/xen/xend-config.sxp” and add the following (rather uncomment)

(xend-unix-server yes)

Next restart your system and pick the xen-kernel from the grub menu (if you want you can edit /etc/default to pick the correct kernel automatically). Now you are good to go.

Simply run “xm info” or “xm list”, you will see your system is running.


Creating a domU


Now Here are the steps to create an Ubuntu Lucid guest (domU) using xen-create-image utility, for that follow following steps.


Step1: go to /etc/xen-tools (edit xen-tools.conf or create a new conf file)
Step 2: Configure it as follows


dir = /mnt/xen
install-method = debootstrap
size = 8Gb # Disk image size.
memory = 1024Mb # Memory size
swap = 128Mb # Swap size
# noswap = 1 # Don't use swap at all for the new system.
fs = ext3 # use the EXT3 filesystem for the disk image.
dist = lucid # Default distribution to install.
image = sparse
dhcp = 1
nameserver = IP address of DNS Server
bridge = virbr0
kernel = /boot/vmlinuz-`uname -r`
initrd = /boot/initrd.img-`uname -r`
mirror = http://archive.ubuntu.com/ubuntu
ext3_options = noatime,nodiratime,errors=remount-ro
ext2_options = noatime,nodiratime,errors=remount-ro
xfs_options = defaults
reiserfs_options = defaults
btrfs_options = defaults
boot = 1
passwd = 1
serial_device = hvc0
disk_device = xvda

Step 4: now run
xen-create-image –hostname=Ubuntu10

Step 3: In the middle of the image creation it will ask for the root password, simply put the password you like. Your domain will start automatically

Step 4: You can login to it using

xm console Ubuntu10


to terminate
xm destroy Ubuntu10

To restart
xm create –c /etc/Ubuntu10.cfg

12 comments:

Alee said...

Hi dude!
I have installed ubuntu server 11.10 in virtualbox and then following your steps. I have a 32bit system.

apt-get install xen-hypervisor-4.1-amd64
apt-get install xen-utils-4.1
apt-get install xenwatch
apt-get install xen-tools
apt-get install xen-utils-common
apt-get install xenstore-utils
apt-get install virtinst
apt-get install virt-viewer
apt-get install virt-manager

these all packages installed successfully without any error.
i have also tried apt-get install xen-hypervisor-4.1-i386
and then edit “/etc/xen/xend-config.sxp” as mentioned in your blog. then i tried to restart the system. I didnt get any thing like xen-kernel at grub menu, After rebooting i run “xm info” and xm list i got this:

root@ubuntu:~# xm info
WARNING! Can't find hypervisor information in sysfs!
Error: Unable to connect to xend: No such file or directory. Is xend running?

Help me out plzzzz

Alee said...

Hi dude!
I have installed ubuntu server 11.10 in virtualbox and then following your steps. I have a 32bit system.

apt-get install xen-hypervisor-4.1-amd64
apt-get install xen-utils-4.1
apt-get install xenwatch
apt-get install xen-tools
apt-get install xen-utils-common
apt-get install xenstore-utils
apt-get install virtinst
apt-get install virt-viewer
apt-get install virt-manager

these all packages installed successfully without any error.
i have also tried apt-get install xen-hypervisor-4.1-i386
and then edit “/etc/xen/xend-config.sxp” as mentioned in your blog. then i tried to restart the system. I didnt get any thing like xen-kernel at grub menu, After rebooting i run “xm info” and xm list i got this:

root@ubuntu:~# xm info
WARNING! Can't find hypervisor information in sysfs!
Error: Unable to connect to xend: No such file or directory. Is xend running?

Help me out plzzzz

Deepal Jayasinghe said...

make sure you boot to the correct kernel. When system starts, select the xen-4.1 kernel. That should solve the problem.

Alee said...

Sorry bro i wont work on my system, not showing any xen-4.1 kernel option in grub menu. Is there any other way to install xen hypervisor on ubuntu 11.10?

Alee said...

i have installed every thing and and create virtual machine using virt-manager.
Thx

Do u know that how to create xen virtual machine without using any tool like virt-manager? I mean to say by using terminal?? I u have some info about this plz share. thx

Prad said...

Hi I followed your instructions.
I have a oneiric 332 bit machine.
I got the following error during #xend start


WARNING! Can't find hypervisor information in sysfs!
xc: error: Could not obtain handle on privileged command interface (2 = No such file or directory): Internal error

Prad said...

Hi I followed your instructions.
I have a oneiric 332 bit machine.
I got the following error during #xend start


WARNING! Can't find hypervisor information in sysfs!
xc: error: Could not obtain handle on privileged command interface (2 = No such file or directory): Internal error

Deepal Jayasinghe said...

You need to make sure boot into the correct kernel. You can do it either by picking the correct one when the system boots or you can change the default boot order. One way or another you need to boot into xen enabled kernel. To change the default grub order following the instruction below:
- Edit "/etc/default/grub"
- In my case I put "GRUB_DEFAULT=2" (index of XEN kernel was two)
- update-grub
- restart

Gennaro said...

I suppose xen can onny work with 64 bit systems...

Carlo said...

It seems that these commands you post here doesn't derive on a new xen kernel, so it ahs to be compiled or found ni some way...
In debian squeeze it is very easy..
just #apt-get install xen-linux-system

and then you are ready to virtualize your family ;)

Rui F Ribeiro said...

if you are in wheezy and having the error cant find.... , run dpkg-divert --divert /etc/grub.d/08_linux_xen --rename /etc/grub.d/20_linux_xen

Hacker said...

I reached last step. Now it is asking Ubuntu 10 login:
what to write there?