With a standard Linux System you can use ‘libvirt’ to manage Virtual Clients (VC). For more virtual ability you can add Xen to Linux. The basic installation of Xen is not a complicated one. Initial Installation The first thing to do is to set up Linux on your system. Perform the installation as normal, but watch the following settings for the hard drive use: Primary - 499.1 MB - /boot – Bootable - ext4 Logical – 20.0 GB - / - non-bootable - ext4 Logical – 2.0 GB - /swap – non-bootable - swap Logical – remaining space – no mount point – non-bootable - ext4 NOTE: The size of the Swap Partition may be changed to match the amount of RAM the system contains. The size of the root (‘/’) partition is small but this is considering the system will be a dedicated Xen Server. A sample setup is shown in Figure 1. FIGURE 1 Use GParted or the OS installer to initially configure the unused space so it has a partition label. On CentOS 7 you may need to install GParted to do this task. To install GParted on CentOS 7 type the following two commands in a Terminal: sudo yum install epel-release sudo yum install gparted Once the Linux Operating System (OS) is installed it may be best to perform an update of the repository lists and then upgrade any files which have been updated. To perform the update and upgrade for Ubuntu perform the following two commands: sudo apt-get update sudo apt-get upgrade For a Red Hat System, such as CentOS 7, perform the following command: sudo yum update Now that the system is updated you can install Xen and get it configured to begin using. Xen Basics If you have been following the previous steps you may have noticed that any remaining space on the hard drive has been left unmounted. It is the unmounted space which will be set aside for Xen. Xen is Type 1 Hypervisor and therefore is loaded before the OS since it is not exactly part of the OS. Xen will share hardware resources with Linux and not go through Linux to access the hardware. Figure 2 shows the way Xen and Linux work together. FIGURE 2 Once Xen has been installed then you will see a special entry in the GRUB menu to load Xen before Linux. The GRUB Menu may not be seen, but the specific menu entry should be loaded by default. Xen clients will be setup on the remaining partition not mounted. Xen program files will be placed on the ROOT mount. If you plan on having quite a few Virtual Clients (VC’s) then make sure the unmounted partition has the required amount of space. NOTE: Set aside enough space for the ROOT partition so you are comfortable with it. The size of the ROOT partition should allow for any future file updates and OS upgrades. Add more, if you want to, for these reasons. XEN Preparation To start the installation you need to know the partition on which XEN will be installed. Open a Terminal and type the command ‘lsblk’ and look for the unmounted partition. The partition, for example, could be ‘/dev/vda7’ as shown in Figure 3. NOTE: The labels in Figure 3 were taken from a Virtual Server and the labels are ‘VDA#’ which stand for ‘Virtual Disk A #’. On a standard system the labels would be ‘SDA#’, ‘SDB#’ or some other letter after the ‘SD’. FIGURE 3 Next we need to set the extra space up for Xen to use. The partition must be set up for the Logical Volume Manager (LVM). To set up LVM on the Ubuntu Linux system you need to install LVM support with the following command: sudo apt-get install lvm2 For a Red Hat System use the following command: sudo yum install lvm2*centos 7 Once the LVM is installed then you need use the extra partition with the LVM. We create the Physical Volume for use by the LVM with the command for both Ubuntu and Red Hat: sudo pvcreate /dev/vda7 The partition I am using is the one which was found by using the command ‘lsblk’ previously shown in Figure 3. You will be asked to ‘wipe’ or delete the existing partition, so make sure you use the proper label. Answer ‘y’ for yes to wipe the partition and then you should be set. NOTE: If you get an error message similar to ‘failed to connect to lvmetad’ then perform the following commands from a Terminal: /etc/init.d/lvm2 stop use_lvmetad=0 /etc/init.d/lvm2 start Now that the Physical Volume is set we need to create a Volume Group. A Volume Group is one or more Physical Volumes. To create the Volume Group for either Ubuntu or Red Hat you will need to perform the following command: sudo vgcreate vg0 /dev/vda7 NOTE: Keep in mind that the partition label will be different on your system. Instead of ‘vda7’ it may be ‘sda7’ or something similar. To see that the Volume Group has been created, use the command: sudo vgdisplay The output should be similar to Figure 4. FIGURE 4 The volume is set and the network card on the computer will need to be bridged with a virtual network card. The Virtual network card is used by the Virtual Clients (VC) to access the network/Internet through the physical network connection of the Host System. To create the ‘bridge’ you first need to install the software to support the bridge. Perform the following command to install the software for Ubuntu: sudo apt-get install bridge-utils For Red Hat use the command: sudo yum install bridge-utils Once installed you will need to configure the bridged network adapter for Ubuntu. You can start by looking at the network interfaces file. Try the following command: cat /etc/network/interfaces This should print out the contents of the file on the screen. There should be a line similar to the following: (Log in to hide this advertisement) iface enplls0 inet dhcp The interface is named ‘enplls0’ which most likely will differ on other systems unless you are using the same Network Interface Card (NIC). The interface is using DHCP for obtaining an IP Address. Use the name of your NIC when making the following changes. Use the following command, but change the name of ‘[editor]’ to your preferred editor installed on your system. sudo [editor] /etc/network/interfaces Find the line mentioned above and change it to: iface enplls0 inet manual After this line add the following lines: auto xenbr0 iface xenbr0 inet dhcp bridge-ports enplls0 To get the Virtual Network Bridge to start it may be best to reboot the system and allow the Bridge to start normally. To set up the Network Bridge on a Red Hat system you need to perform the following commands to disable the networking and set it to start at boot: chkconfig NetworkManager off chkconfig –levels 35 network on /etc/init.d/NetworkManager stop /etc/init.d/network restart You can look at the network interfaces file with the following command: cat /etc/sysconfig/network-scripts/ifcfg-br0 If the file does not exist, which may be the case, then you need to perform the following command: sudo gedit /etc/sysconfig/network-scripts/ifcfg-br0 Add the following lines to the editor and save the file: DEVICE=br0 TYPE=Bridge BOOTPROTO=static DNS1=192.168.0.1 GATEWAY=192.168.0.1 IPADDR=192.168.0.100 NETMASK=255.255.255.0 ONBOOT=yes SEARCH=“example.com” Set the DNS1, GATEWAY, IPADDR and NETMASK as appropriate for your network. Next, you need to perform the following command to edit the file for the Ethernet connection: sudo gedit /etc/sysconfig/network-scripts/ifcfg-eth0 Make sure the following two lines are added to the file and saved. USERCTL=“no” BRIDGE=“br0” Once the changes have been made you can reboot the Cent OS 7 system for the changes to take effect. XEN Installation Now to install Xen. On a 64-bit Ubuntu System, a 64-bit system is more highly suggested, you need to perform the following command: sudo apt-get install xen-hypervisor-amd64 On a Red Hat System you need the command: sudo yum install centos-release-xen sudo yum update sudo yum install xen After the installation you need to reboot the system to enable Xen. The GRUB Menu should appear and give you the option to load your OS with Xen with the line ‘Ubuntu GNU/Linux, with Xen hypervisor’. For Red Hat the GRUB Menu item will be ‘Centos Linux with Xen hypervisor’. Make sure you choose the option to load Xen, and if needed, make it the default option to load on startup. This should take you through the basic installation of Xen. I will cover the configuration in later articles.