|
Xen is a hypervisor (virtual machine engine) and it is the powerful open source industry standard for virtualization, offers a powerful, efficient, and secure feature set for virtualization of x86, x86_64, IA64, PowerPC, and other CPU architectures. It supports a wide range of guest operating systems including Windows, Linux, Solaris, and various versions of the BSD operating systems. All the major Linux distributions such as Red Hat, Oracle Linux, CentOS, Debian, Ubuntu, SuSe, and Gentoo provides packages for using Xen virtualization.
This GeekyFacts tutorial provides you step-by-step instructions on how to install & startup Xen. The commands mentioned in this document are for CentOS-5. So this document could very well apply for Fedora, Redhat Enterprise Linux & Oracle Enterprise Linux. For other Linux OS - it sould work with minimal changes.
In Xen, the host operating system is called dom0 (Domain 0) and the virtual guests are called as domU (Domain-U).
Preparing the host system (dom0) :
Install the host machine as the way you regulary install any Linux [refer http://www.centos.org/docs/5/html/5.2/Installation_Guide/].
After installation, you have to do the below steps.
- Disable SELinux : Edit /etc/sysconfig/selinux and make sure that SELinux is disabled.
- Create filesystem for virtual guests: Create a filesystem named /domU/ ( or whatever you want to name it as), with ext3 filesystem and mount it. The filesystem size depends on the number of virtual machines you are going to create.
Installing Xen packages:
To install Xen and its supporting tools, you have to install the below packages. - kernel-xen
- xen
- xen-libs
- bridge-utils
- libvirt
- python-virtinst
- virt-manager (optional)
You can install these packages using "yum". This installs xen and all its dependent packages. If you are not able to install using yum, you have to manually install the packages and its dependencies.
[root@geekyfacts ]# yum install kernel-xen xen libvirt python-virtinst
After these packages are installed, change the bootloader to boot using xen kernel. Edit /etc/grub.conf to do this. Reboot the system and it will come up with xen kernel. The command "uname -a" should show "xen" in the kernel name.
[root@geekyfacts ]# uname -a Linux geekyfacts 2.6.9-78ELxen #1 Mon Aug 4 18:58:03 GMT 2008 i686 i686 i386 GNU/Linux [root@geekyfacts ]#
"Xend" is the Xen Controller daemon. This daemon starts automatically when the xen dom0 boots up. Verify whether this daemon is running.
[root@geekyfacts ~]# ps -ef | grep xend root 11700 1 0 Nov24 ? 00:00:00 python /usr/sbin/xend start root 11705 11700 0 Nov24 ? 00:00:05 python /usr/sbin/xend start root 16270 15804 0 00:45 pts/0 00:00:00 grep xend [root@geekyfacts ~]#
Once Xend is running, it will start Domain0, which is the privileged domain. Check to see that Domain0 has been created and is up and running by using the xm command as below.
[root@geekyfacts ~]# xm list Name ID Mem(MiB) VCPUs State Time(s) Domain-0 0 2048 8 r----- 14943.4 [root@geekyfacts ~]#
Make sure the bridge xenbr0 is created. Use "ifconfig -a" command to check xenbr0. Now,we are ready with a Xen host server.
Virtual machine creation:
The easy way of creating xen virtual machines is by using virt-install or virt-manager. Virt-install is command line based and Virt-manager is GUI based one. This tutorial uses virt-install to create virtual machines. It is as simple, just run virt-install on terminal and answer the questions – your virtual machine will be ready.
Here is how it is: [root@geekyfacts ~]# virt-install Would you like a fully virtualized guest (yes or no)? This will allow you to run unmodified operating systems. yes What is the name of your virtual machine? vm1 How much RAM should be allocated (in megabytes)? 2048 What would you like to use as the disk (file path)? /domU/vm1.img How large would you like the disk (/domU/vm1.img) to be (in gigabytes)? 25 Would you like to enable graphics support? (yes or no) yes What is the virtual CD image, CD device or install location? /OS/Fedora-9-dvd.iso Starting install... Creating storage file... 100% |=========================| 8.0 GB 00:00 Creating domain... 0 B 00:01 [root@geekyfacts ~]#
virt-install – requires inputs like vm name, type of virtualization, memory size, disk image & size , installer location. The question about the graphics support refers to the installer, not the virtual machine itself. It is possible to start a graphical installer, and you have to connect to it via VNC.
Your virtual machine is up now and you can check that with “xm list” command. You can connect to the host server using vnc and that gives you the console of the virtual machine. virt-install also stores the xen configuration in /etc/xen/.
[root@geekyfacts ~]# xm list Name ID Mem(MiB) VCPUs State Time(s) Domain-0 0 2048 8 r----- 14981.4 vm1 11 2055 1 r----- 3.7
That’s it , your xen host server and virtual machine is ready! |