I successfuly installxen on virtualbox except graphic. Both xen and dom0 kernel arecompiled from source. They system parameters are as follow:
CPU x86_64
OS on physical machine : Ubuntu 10.04
Virtualbox: 4.0.4
Dom0: Ubuntu 10.04,
Dom0 kernel: 3.1.0-rc6
xen 4.1.2
Domu: centos 5.6
If you are beginner, it is much better that you choose the Ubuntu10.04. It is not guaranteed that other distributionhas the same process. Taking snapshot after every step is also veryhelpful.
1.Install Virtualbox and dom0.
2.Install packages in dom0. Open terminal
sudo apt-get update
sudo apt-get upgrade
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 libsdl1.2-dev libjpeg62-dev iasl libbz2-dev e2fslibs-dev git-core uuid-dev ocaml libx11-dev bison flex ocaml-findlib vim
sudo apt-get install gcc-multilib xz-utils
3.Download xen source from http://xen.org/products/xen_source.html , and unzip the source.
tar -zxvf xen-4.1.2.tar.gz
cd xen-4.1.2
Compilethe source.
sudo make xen
sudo make install-tools PYTHON_PREFIX_ARG=
ls /boot
4.Compile dom0 kernel. Download kernel from kernel.org, and choose a branch.
git clone git://git.kernel.org/pub/scm/linux/kernel/git/jeremy/xen.git
cd xen %change to kernel directory
git branch -a
git checkout -b upstream origin/upstream/xen
Change to the download directory.
cp /boot/config-2.6.32-33-generic .config
If you want to patch.
patch -p1 <../patch-2.6.26.8
sudo make menuconfig
Exit the menuconfig without modification. This will update the .config, which is helpful for further modification.
sudo vi .config
Modify the .config as
-
CONFIG_XEN_DOM0=y
-
CONFIG_PCI_XEN=y
-
CONFIG_XEN_BACKEND=y
-
CONFIG_XENFS=y
-
CONFIG_XEN_COMPAT_XENFS=y
-
CONFIG_XEN_SYS_HYPERVISOR=y
-
CONFIG_XEN_GNTDEV=y
sudo make
sudo make modules_install install
5. checkthe new file /boot, and
cd /boot
ls -l
sudo update-initramfs -c -k 3.1.0-rc6+
If there is error:W: Possible missing firmware /lib/firmware/rtl_nic/rtl8168f-2.fw for module r8169
cd ~
wget https://launchpad.net/ubuntu/+archive/primary/+files/linux-firmware_1.49_all.deb
sudo dpkg -i linux-firmware_1.67_all.deb
sudo update-grub
In file /etc/xen/xend-config.sxp, comment out
sudo chmod u+w /boot/grub/grub.cfg
Reboot your new linux kernel.
6.Modify the grub.
sudo vi /boot/grub/grub.cfg
Add a new entry.
menuentry"Xen 4.1.2/ Ubuntu 10.04 kernel 3.1.0-rc6+" {
insmodext2
set root='(hd0,1)'
multiboot /boot/xen.gzdummy=dummy
module /boot/vmlinuz-3.1.0-rc6+ dummy=dummyroot=UUID=0ca7f3e4-d12e-45ab-9b63-73a3003cac71 ro quietsplash
module /boot/initrd.img-3.1.0-rc6+
}
The file path should already exist in your file system. The parameters are copied from other entries.
Reboot your system and choose the new entry.
if it stops atChecking battery state, ctrl+alt+f1, and go to text mode. You can also remotely use ssh or xmanager to get the desktop.
7. If booting sucefully, dom0 is installed successfully. But sometimes we need starting xen tools manually.
sudo modprobe xen-evtchn
sudo /etc/init.d/xencommons start
sudo /etc/init.d/xend start
If there is an error: device is busy, start xend again
sudo /etc/init.d/xend start
If there is an error:libxenctrl.so.4.2: cannot open shared object file:No such file or directory)
added /usr/lib64 to /etc/ld.so.conf and ran ldconfig.
other change may be needed:
ln -s /usr/lib//bin /usr/lib64/xen/bin
ln -s /usr/lib/xen/boot/* /usr/lib/xen-default/boot/
You can try some commands from xen.
cat /proc/xen/capabilities
sudo xm list
sudo xm info
8.Install virt-manage.
It is unfortunately that xen cannot work when OS reboots.
Change the xen source directory, and reinstall xen tools.
sudo make install-tools PYTHON_PREFIX_ARG=
9.Install domu.
sudo virt-install --prompt
Whatis the name of your virtual machine?domu1
Howmuch RAM should be allocated (in megabytes)? 500
Whatwould you like to use as the disk (path)?/home/path/domu.img
Howlarge would you like the disk to be (in gigabytes)?10
Whatis the installURL?http://mirror.vcu.edu/pub/gnu+linux/centos/5.6/os/x86_64/
There are two errors. Donot care about them. The domu can only be installed from internet. You can refer tohttp://docs.oracle.com/cd/E11081_01/doc/doc.21/e10898/createvm.htm for detail requirement.
Connect to the new domu.
sudo xm list
if ERROR POST operation failed: xend_post: error from xen daemon: (xend.err 'Device 0 (vif) could not be connected. Hotplug scripts not working.'),
modify /etc/xen/xend-config.sxp
(network-script 'network-bridge netdev=virbr0')
The name virbr0 is from ifconfig.
sudo xm console domu1
10.Install the domu OS
Choose text mode, do not select any GUI
11. After domu installed, it requires some modifications to start.
sudo passwd root
su-
cd/var/lib/xend/domains/xxxxxxxxxxxx
ls
There is a config file.
vi config.sxp
modify PV_bootloader and bootloader to/usr/bin/pygrub
12.Log into domu.
xm create domu1 –-config config.sxp
xm console domu1
You can log into domu OS, the username isroot.
13.Try.
14. In domain 0
chown user:group ~/.Xauthority
chmod u+w ~/.Xauthority
chang the network type for domain0 from NAT to bridge