(This article is based on Xen-Ubuntu and XenParavirtOPs)
Installation of Xen-4.1.2 (dom0) with paravirtual guest support on Ubuntu 10.04 involves two major tasks
- Build and install xen
- Compile a DOM0 kernel
Steps for task #1
- Install Ubuntu 10.04 with ext4 file system
- Download Xen-4.1.2 from http://bits.xensource.com/oss-xen/release/4.1.2/xen-4.1.2.tar.gz
- Install necessary libraries and utilities:
$ sudo apt-get install bcc 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 build-essential make gcc libc6-dev zlib1g-dev python python-dev python-twisted libncurses5-dev patch libvncserver-dev libsdl-dev libjpeg62-dev iasl libbz2-dev e2fslibs-dev git-core uuid-dev ocaml ocaml-findlib libx11-dev libc6-xen
- If you are running a 64 bit kernel, then install some additional packages
$ sudo apt-get install gcc-multilib xz-utils
- Extract xen-4.1.2.tar.gz
$ tar xzf xen-4.1.2.tar.gz
- Building Xen
$ cd xen-4.1.2/ $ make xen $ make tools $ make dev-docs <======= optional step, ignore warnings $ make stubdom $ sudo make install-xen $ sudo make install-tools PYTHON_PREFIX_ARG= $ sudo make install-docs <============= optional step $ sudo make install-stubdom
Cheers! You’ve completed the task 1.
Steps for task #2
- First make a directory for the Xen-kernel source at your desired location. In this article, I’ll use ‘/usr/src’.
$ cd /usr/src $ mkdir linux-2.6-xen
- You can download the dom0 kernel from your favorite location. As per suggestions, I’m going to checkout the latest xen dom0 linux kernel from a git repository. Check available branches at http://git.kernel.org/?p=linux/kernel/git/jeremy/xen.git;a=heads. You might encounter a lot of blogs, documentations suggesting to checkout ‘xen/stable-2.6.32.x’; but unfortunately that branch no longer exists in the above mentioned git repository. So I’m going to checkout ‘xen/next-2.6.32’ branch.
$ git clone git://git.kernel.org/pub/scm/linux/kernel/git/jeremy/xen.git linux-2.6-xen $ cd linux-2.6-xen $ git remote show origin <===== just to verify the branch names $ git checkout -b xen/next-2.6.32 origin/xen/next-2.6.32
- To make your life easier, copy your current Ubuntu config file to the current directory and then configure your dom0 kernel
$ cp /boot/config-2.6.32.XX-generic .config $ make menuconfig
- Enable the following options in the mentioned order. This will enable all the XEN related options. Xen dom0 support depends on ACPI support. Make sure you enable ACPI (CONFIG_ACPI=y) support or you won’t see Dom0 options at all.
--> Processor type and features Deselect: Support for extended (non-PC) x86 platforms ---> Processor family Select either: Pentium-MMX or Pentium-Pro Select: High Memory Support (64GB) --> Paravirtualized guest support Select: Xen guest support Select: Enable Xen privileged domain support
- Now consult XenSource (Configuring the kernel) for further configuration. Here is a list of required configuration options
CONFIG_X86_PAE=y CONFIG_HIGHMEM(64G) CONFIG_PARAVIRT=y CONFIG_XEN=y CONFIG_PARAVIRT_GUEST=y CONFIG_PARAVIRT_SPINLOCKS=y CONFIG_HVC_DRIVER=y CONFIG_HVC_XEN=y CONFIG_XEN_FBDEV_FRONTEND=y CONFIG_XEN_BLKDEV_FRONTEND=y CONFIG_XEN_NETDEV_FRONTEND=y CONFIG_XEN_PCIDEV_FRONTEND=y CONFIG_INPUT_XEN_KBDDEV_FRONTEND=y CONFIG_XEN_FBDEV_FRONTEND=y CONFIG_XEN_SAVE_RESTORE=y CONFIG_XEN_XENBUS_FRONTEND=y <=====(will be enabled automatically)
- Some more options for dom0 kernel
CONFIG_X86_IO_APIC=y CONFIG_ACPI=y CONFIG_ACPI_PROCFS=y (optional) CONFIG_XEN_DOM0=y CONFIG_XEN_DOM0_PCI=y <=====(will be enabled automatically) CONFIG_PCI_XEN=y <=====(will be enabled automatically) CONFIG_XEN_DEV_EVTCHN=y CONFIG_XENFS=y CONFIG_XEN_COMPAT_XENFS=y CONFIG_XEN_SYS_HYPERVISOR=y CONFIG_XEN_GNTDEV=y CONFIG_XEN_BACKEND=y CONFIG_XEN_NETDEV_BACKEND=m CONFIG_XEN_BLKDEV_BACKEND=m CONFIG_XEN_PCIDEV_BACKEND=m CONFIG_XEN_PRIVILEGED_GUEST=y <=====(will be enabled automatically) CONFIG_XEN_BALLOON=y CONFIG_XEN_SCRUB_PAGES=y
- Enable the following options in the mentioned order. This will enable all the XEN related options. Xen dom0 support depends on ACPI support. Make sure you enable ACPI (CONFIG_ACPI=y) support or you won’t see Dom0 options at all.
- Now build the kernel
$ sudo make $ sudo make modules_install install
- Now build initramfs image for the newly build kernel (e.g., 2.6.32.56)
$ sudo update-initramfs -c -k 2.6.32.56
- Add Xend and Xendomains to auto-start
$ sudo update-rc.d xencommons defaults 19 18 $ sudo update-rc.d xend defaults 20 21 $ sudo update-rc.d xendomains defaults 21 20 $ sudo update-rc.d xen-watchdog defaults 22 23
- Add the following modules to ‘/etc/modules’ file so that the kernel loads them at startup
$ sudo vim /etc/modules
and add the following lines
#Added for xen xen-evtchn xen-gntdev xen-netback xen-blkback xenfs blktap
- Now update grub after placing the following entry to the ‘/etc/grub.d/40_custom’ file:
menuentry "Xen - Linux 2.6.32.56" { insmod ext2 set root='(hd0,X)' multiboot /boot/xen.gz dummy=dummy module /boot/vmlinuz-2.6.32.56 dummy=dummy root=UUID=XXXX_YYY ro dom0_mem=512M nomodeset module /boot/initrd.img-2.6.32.56 }
Replace ‘X’ with your partition number and ‘XXXX_YYY’ with UUID listed in your current ubuntu menuentry at ‘/boot/grub/grub.cfg’ file.
- Now type:
$ sudo update-grub
- Open ‘/etc/xen/xend-config.sxp’ and replace
#(xend-unix-server no)
with
(xend-unix-server yes)
- Now reboot and boot into xen-kernel
- To test xen-dom0, type
$ cat /proc/xen/capabilities control_d
If you don’t have anything under ‘/proc/xen’ directory, then add the following line to the ‘/etc/fstab’ file and then reboot
none /proc/xen xenfs defaults 0 0
- Now try another command
$ sudo xm list
and you will see the only ‘Domain-0’ is running. If not, then consult troubleshooting XenSource.
- Now type
$ brctl show
If you see the bridge without any interface attached to it, then perform the following steps
- Open ‘/etc/xen/xend-config.sxp’ and replace
(network-script network-bridge)
with
(network-script 'network-bridge netdev=eth0')
- Now make sure your ‘/etc/network/interfaces’ looks like the following if you have a DHCP connection
auto lo iface lo inet loopback auto eth0 iface eth0 inet dhcp
or like as follows if you are a static IP (replace with your own IPv4 addressses)
auto lo iface lo inet loopback auto eth0 iface eth0 inet static address aaa.bbb.ccc.ddd netmask aaa.bbb.ccc.ddd gateway aaa.bbb.ccc.ddd
and make sure your ‘/etc/hosts’ file looks as follows
127.0.0.1 localhost 127.0.1.1 yourhostname
and just reboot your machine and try ‘brctl show’ again. It should display the bridge name ‘eth0’ and the attached interface ‘peth0’.
- Open ‘/etc/xen/xend-config.sxp’ and replace
Congrats! You are done with your xen dom0 kernel setup.. Now it’s time to chill out! 🙂
Coming soon
Installing multiple domU running guest OS on a Xen hypervisor.