Xen lets you create guest operating systems, so called “virtual machines” or domUs, under a host operating system (dom0). Using Xen you can separate your applications into different virtual machines that are totally independent from each other e.g. a virtual machine for a mail server, a virtual machine for a high-traffic web site, another virtual machine that serves your customers’ web sites, a virtual machine for DNS, etc., but still use the same hardware. This saves money, and what is even more important, it’s more secure. If the virtual machine of your DNS server gets hacked, it has no effect on your other virtual machines. Plus, you can move virtual machines from one Xen server to the next one.
To install Xen, simply run,
# yum install kernel-xen xen virt-manager -y
Before rebooting the system with the Xen kernel, we must tell the boot loader GRUB about it.
# vim /boot/grub/menu.lst
Then change the value of default=1 to default=0.
Save and exit the file.
Now reboot your system,
The system should now automatically boot the new Xen kernel. After the system has booted, we can check that by running
# uname -r
Run xm list to check if Xen has started. It should list Domain-0 (dom0):
# xm list
|Don’t Miss to Read|
Run virt-manager and follow steps to install DomU on host OS. Before installation, it will ask few questions like:
- What is the name of your virtual machine? <– vm1
- How much RAM should be allocated (in megabytes)? <– 256
- What would you like to use as the disk (path)? <– /vm/vm1.img
- How large would you like the disk (/vm/vm1.img) to be (in gigabytes)? <– 5
- Would you like to enable graphics support? (yes or no) <– no
- What is the install location?
After the installation, we stay at the vm1 console. To leave it, type CTRL+]. virt-install has created the vm1 configuration file /etc/xen/vm1 for us (in dom0). It should look like this:
# cat /etc/xen/vm1
# Automatically generated xen config file
name = “vm1″
memory = “256″
disk = [ ‘tap:aio:/vm/vm1.img,xvda,w’, ]
vif = [ ‘mac=00:AA:3C:B3:e4:86, bridge=xenbr0’, ]
uuid = “5Bbfedf1-dc36-421e-68cc-147c1cb8nd9e”
on_reboot = ‘restart’
on_crash = ‘restart’
# xm list
To shut down vm01, do this:
# xm shutdown vm1
To start vm1 again, run
# xm create /etc/xen/vm1
If you want vm01 to start automatically at the next boot of the system, then do this:
# ln -s /etc/xen/vm1 /etc/xen/auto