Virtualization is a way to run more than one Operating System (OS) on a system. The ability to do this allows a server to use more of its resources than it normally would use with a single OS. The virtualization allows for more servers without having to purchase physical equipment which can be costly. Terminology The main OS on a system is called the Host. A Host is required to provide the virtualization. Each system installed is a Virtual Client (VC), or sometimes called a Guest Machine or Virtual Machine (VM). Each VC will have its own resources such as RAM and drive space. Fault Isolation is one VC fails it will not cause another VC to fail. NOTE: If the Host fails then every VC can and most likely will fail. Performance Isolation is where each VC has resources allocated to it and one VC will not take resources from another VC. If a VC is no longer being used, then it should be removed to release the resources allocated to it. The way it generally works with libvirt is that the hardware is managed by the Host OS. In our case the Host OS will be Linux. Within the Host OS is a Hypervisor. The Hypervisor allows for the creation and execution of Virtual Clients. The Virtual Clients, when addressing hardware, will send the request to the Hypervisor, which in turn sends the request to the Host OS which then accesses the Hardware. Data being sent back to the VC will travel in the reverse route. Hardware For a good Host System to handle virtualization you need a fast system with plenty of RAM. There must be enough RAM to provide an adequate amount for the Host OS as well as each VC. There should be enough drive space for the Host OS and the space allocated to each VC. The main thing needed is a Central Processing Unit (CPU) which handles Virtualization. To find out if your system can handle Virtualization you need to perform the following command: cat /proc/cpuinfo | grep flags The output should be something like Figure 1. Each CPU model will have different flags. The specific flag for virtualization is either VMX, for Intel, or SVM, for AMD. FIGURE 1 In Figure 1 you can see ‘vmx’ in the second last row. The output shows my Intel CPU can manage virtualization. NOTE: When using the command there will be a section for each processor core. If your CPU is a dual-core then there will be two identical sections. A quad-core will have four identical sections. Once you know you have a CPU which handles virtualization then you need to make sure it is enabled in the BIOS. Reboot your system and enter the BIOS Settings (usually F2 or some other key) during the boot when the BIOS Screen is displayed. The Virtualization Setting can be nearly anywhere in the BIOS. I have seen it in the Security Settings as well as the System Settings. Look everywhere and enable it when you find it. Once enabled you can continue setting up a Virtual Client. Install ‘libvirt’ Even if you install the Linux Server and check to install Virtualization it does not install all of the files you need. On your Linux system open a Terminal and type the following command: sudo apt-get install -y qemu-kvm libvirt-bin virtinst Once the process is completed you can create a Virtual Client. Virtual Client Creation To create a VC on the Virtualization Server, or Host, you need to first have a bootable ISO file of the client you wish to install. For my example I will install Ubuntu 14.04 Minimal to my Virtualization Server. To create the Ubuntu Guest I will download the Ubuntu 14.04 Minimal ISO file and place it in ‘/home/jbuse/ISO/’. Once the file is in place I can issue the following command: sudo virt-install -n ubuntu_vm -r 4000 --disk path=/var/lib/libvirt/images/ubuntu_vm.img,bus=virtio,size=10 -c /home/jbuse/ISO/Ubuntu-14.04-Minimal.iso --network network:default,model=virtio --graphics vnc,listen=0.0.0.0 --noautoconsole -v The command name is ‘virt-install’. To specify the name of the Virtual Client use the ‘-c’ parameter followed by the name you wish to use. Be sure not to use any characters which are normally not allowed when creating a file. To set the amount of RAM to allocate to the VC use ‘-r’ followed by the amount of RAM in MB. The disk path sets the folder for the location of the drive space image file and the ‘size=’ value is the amount of space in GB. The ISO file location is after the option ‘-c’. Other options should be left as defaults for a Linux VC. Once the command is executed then you can open the VC on the Host System with the command ‘virt-viewer’. Once opened a list of current Virtual Clients will be listed which are running. Select the client you want to view and interact with and select ‘Connect’. Once connected to the Ubuntu VC the screen looks like Figure 2. The installation of Ubuntu continues as normal. FIGURE 2 Instead of using the ‘virt-viewer’ on the Host you can also connect using a VNC program such as Remmina. To install Remmina enter the following command into a Terminal: sudo apt-get install remmina To get a list of all of the running Virtual Clients and their names use the command: virsh list The IP Address is the address of the Host System. To find the port number you need to issue the command from the Host: virsh domdisplay <VC_Name> The result should be something similar to ‘vnc://localhost:0’ The ‘0’ shows that the port number to connect to the VC is ‘5000’ or 5000 + 0. If the result were ‘2’ then the port number would be ‘5002’. To connect to the VC with Remmina the address would be the Host System IP Address ‘:5002’. If the Host IP is 192.168.0.3 and the port is 5002 then the address is ‘192.168.0.3:5002’. Now it is simply a matter of managing the Virtual Clients as needed. Managing Virtual Clients Sometimes it may be necessary to reboot a VC or even stop it. There are a few things you can do to a VC once it is created. Some of the major commands are: virsh start <name> - starts the named VC virsh shutdown <name> - stops the named VC virsh reboot <name> - reboots the named VC virsh destroy <name> - destroys the named VC virsh setmaxmem <name> - sets the maximum memory for the named VC virsh autostart <name> - autostarts the named VC when Host boots To see a full list of the virsh parameters use the command ‘virsh -help’. Set up a Virtual Server on a system which will support it and create some Virtual Clients. Test the clients and have some fun with them. Enjoy!