Linux Virtualization


Top 10 Linux Virtualization Software


Virtualization is the latest buzz word. You may wonder computers are getting cheaper every day, why should I care and why should I use virtualization? Virtualization is a broad term that refers to the abstraction of computer resources such as:

  1. Platform Virtualization
  2. Resource Virtualization
  3. Storage Virtualization
  4. Network Virtualization
  5. Desktop Virtualization

This article describes why you need virtualization and list commonly used FOSS and proprietary Linux virtualization software.

Why should I use virtualization?

  • Consolidation – It means combining multiple software workloads on one computer system. You can run various virtual machines in order to save money and power (electricity).
  • Testing – You can test various configuration. You can create less resource hungry and low priority virtual machines (VM). Often, I test new Linux distro inside VM. This is also good for students who wish to learn new operating systems and programming languages / database without making any changes to working environment. At my work place I give developers virtual test machines for testing and debugging their software.
  • Security and Isolation – If mail server or any other app gets cracked, only that VM will be under control of the attacker. Also, isolation means misbehaving apps (e.g. memory leaks) cannot bring down whole server.
Open Source Linux Virtualization Software
  1. OpenVZ is an operating system-level virtualization technology based on the Linux kernel and operating system.
  2. Xen is a virtual machine monitor for 32 / 64 bit Intel / AMD (IA 64) and PowerPC 970 architectures. It allows several guest operating systems to be executed on the same computer hardware concurrently. XEN is included with most popular Linux distributions such as Debian, Ubuntu, CentOS, RHEL, Fedora and many others.
  3. Kernel-based Virtual Machine (KVM) is a Linux kernel virtualization infrastructure. KVM currently supports native virtualization using Intel VT or AMD-V. A wide variety of guest operating systems work with KVM, including many flavours of Linux, BSD, Solaris, and Windows etc. KVM is included with Debian, OpenSuse and other Linux distributions.
  4. Linux-VServer is a virtual private server implementation done by adding operating system-level virtualization capabilities to the Linux kernel.
  5. VirtualBox is an x86 virtualization software package, developed by Sun Microsystems as part of its Sun xVM virtualization platform. Supported host operating systems include Linux, Mac OS X, OS/2 Warp, Windows XP or Vista, and Solaris, while supported guest operating systems include FreeBSD, Linux, OpenBSD, OS/2 Warp, Windows and Solaris.
  6. Bochs is a portable x86 and AMD64 PC emulator and debugger. Many guest operating systems can be run using the emulator including DOS, several versions of Microsoft Windows, BSDs, Linux, AmigaOS, Rhapsody and MorphOS. Bochs can run on many host operating systems, like Windows, Windows Mobile, Linux and Mac OS X.
  7. User Mode Linux (UML) was the first virtualization technology for Linux. User-mode Linux is generally considered to have lower performance than some competing technologies, such as Xen and OpenVZ. Future work in adding support for x86 virtualization to UML may reduce this disadvantage.
Proprietary Linux Virtualization Software
  1. VMware ESX Server and VMWare Server – VMware Server (also known as GSX Server) is an entry-level server virtualization software. VMware ESX Server is an enterprise-level virtualization product providing data center virtualization. It can run various guest operating systems such as FreeBSD, Linux, Solaris, Windows and others.
  2. Commercial implementations of XEN available with various features and support.
    • Citrix XenServer : XenServer is based on the open source Xen hypervisor, an exceptionally lean technology that delivers low overhead and near-native performance.
    • Oracle VM : Oracle VM is based on the open-source Xen hypervisor technology, supports both Windows and Linux guests and includes an integrated Web browser based management console. Oracle VM features fully tested and certified Oracle Applications stack in an enterprise virtualization environment.
    • Sun xVM : The xVM Server uses a bare-metal hypervisor based on the open source Xen under a Solaris environment on x86-64 systems. On SPARC systems, xVM is based on Sun’s Logical Domains and Solaris. Sun plans to support Microsoft Windows (on x86-64 systems only), Linux, and Solaris as guest operating systems.
  3. Parallels Virtuozzo Containers – It is an operating system-level virtualization product designed for large-scale homegenous server environments and data centers. Parallels Virtuozzo Containers is compatible with x86, x86-64 and IA-64 platforms. You can run various Linux distributions inside Parallels Virtuozzo Containers.

Personally, I’ve used VMware ESX / Server, XEN, OpenVZ and VirtualBox.


Virtualization solutions on Linux systems – KVM and VirtualBox


1. Introduction

Virtualization packages are means for users to run various operating systems without “bare-metal” hardware – basically, you can run more than one operating system on a single computer without dual-booting or similar approaches. Virtualization software emulates a real machine and “fools” the guest operating system into thinking it’s running on a real computer. Besides the more obvious advantages, virtual machines help create a greener and easier to administer computing environment. Looking at the trends in the IT industry, virtualization has seen quite a boom in the last few years, because it fits the concepts ofutility computing and/or software as a service. Virtualization can be useful to you if you are an enterprise architect, developer, a home user or basically everything in between. We will begin with a short introduction about virtualization in general, then we will specifically treat VirtualBox and KVM as they seem to be most popular open source full virtualization solutions. You are expected to know your way around Linux systems, how to install a Linux distribution and how to install software on it, although we will show you how to install the two aforementioned virtualization packages on some of the popular Linux distributions.

There are two types of virtualization : one that can run the guest system as-is (as in, unmodified) and another that request a modified kernel on the guest’s side in order to run. The first category is named full virtualization, because it emulates a complete hardware environment, the second is named paravirtualization, because it doesn’t emulate hardware and hence needs special modifications at guest level, a good example of this type of virtualization being Xen. These are part of a bigger category named hardware virtualization, but there are also other (software, network or storage, amongst others) virtualization types, which we will not detail here. The two pieces of software we will talk about fit into the full virtualization category. Other popular hardware virtualization technologies include QEMU, Bochs, VMware, Parallels, HyperV or OpenVZ.If you still have some questions after reading this article please try our new LinuxCareer Forum.

1.1. When is virtualization useful?

1.1.1. Linux distributions

The Linux world is full of interesting and tempting offers. There are over 600 (!) Linux distributions to choose from, which makes it hard for a person that only has one computer to try them all, or just a few even. LiveCDs aren’t always helpful, so one may need to install in order to get the gist of it. Every Linux distribution release brings new and exciting features, and you may feel the thrill and the impulse to install and test it. Enter virtualization. You download the ISO, install the distro in a virtual environment and you’re good to go, all in a short time. You don’t like it, you delete it. Especially when you’re kinda new to the Linux world and you might be confused by the big number of available distributions, this might just be what you need. Also, if you’re a developer and need to run the development branch of your distro (think Fedora Rawhide or Debian Sid) but that is too unstable for everyday use, install in a VM and start developing.

1.1.2. Other operating systems

This extends to other operating systems you might need : maybe you have a propgram that runs only on Windows and you don’t wanna install Windows just for that one program. Maybe you want to learn Solaris but lack the hardware. Provided you have the appropriate computer configuration that supports virtualization, now you can do it.

1.2. What you will need

Modern processors have special CPU instructions for hardware emulation. You can live without, but you really don’t want to, since the host operating system will have to emulate the lacking virtualization instruction and this will slow down your guest(s) significantly. We presume your host OS has Linux installed and your CPU has the necessary virtualization capabilities. The most simple way to check if your CPU has what it takes, do

 $ egrep ‘(vmx|svm)’ /proc/cpuinfo 

and if that returns either vmx (Intel CPUs) or svm (AMD CPUs), you’re good to go. But that of course isn’t the only request on the hardware side. Check the web page of the system you want to install as guest to check if you meet its’ hardware requirements. We recommend at least 20GB free in your home directory and a minimum of 2GB of memory on the host, so you can allocate a mean amount of 768MB to the guest for optimal performance. Of course, should you want to run multiple virtual machines (maybe in parallel), those requirements grow considerably.

1.3. KVM or VirtualBox?


KVM virtualization on linux


First of all, why would we offer you two virtualization packages? Why not one for all your needs? Well, we believe in the “right tool for the job” concept. KVM offers some features thatVirtualBox does not and the other way around. There is no such thing in the IT world as a universal tool, so it’s important to use something that fits your needs. The basic idea is : if you want to install a binary Linux distribution as a guest, use KVM. It’s faster and its’ drivers are included in the official kernel tree. If your guest involves lots of compiling and needs some more advanced features, and/or isn’t a Linux system, better go with VirtualBox.

The technical reasons are quite simple : KVM is better integrated with Linux, it’s smaller and faster, and while you can use it with other guests besides Linux, we found the experience to be quite troublesome : BSDs tend to have slow I/O and Solaris (OpenIndiana, to be exact) tends to panic immediately after booting the installation ISO. Since we use CURRENT versions of BSD (and compile/update the system from source often) and also need Solaris, we found VirtualBox to be a better option.


virtualbox virtualization on linux


Another plus for Oracle VirtualBox is the fact that it supports suspend, that is you can save the machine state on the host’s hard disk and close VirtualBox and when (re)starting, the system will pick up from where it left. That is why we referred to source compilation : if you have a noisy machine you don’t wanna leave on overnight but your Gentoo virtual machine just compiles a new gcc version, suspend the machine state, shut down the host and continue tomorrow.

1.4. What you will learn

We will show you how to install KVM and VirtualBox and how to install and configure a Linux guest on a Linux host. Examples with other Unices are very similar, so we see no need to repeat ourselves.

2. Installation

2.1. KVM

Although KVM advertises Solaris, BSD, ReactOS, Windows and others as supported guests, our experiences were less than fruitful. This isn’t a criticism, since we did not, in all honesty, sit down and examine the issue too much. But this is not out of laziness : after talking with other people on the ‘Net, we found that we are not the only ones with issues regarding Unix(-like) guests besides Linux, so we just went with VirtualBox for those. As always, your mileage may vary : we too would want to use KVM exclusively because it’s more “free”, but because of the aforementioned problems, which of course might just be something specific to our setup, we had to use VirtualBox. At the moment, KVM is developed by Red Hat and is easily installable on most Linux distributions. As we did before, we will outline only the installation procedures pertaining to major Linux distributions.

2.1.1. Fedora

Since Red Hat, the sponsor of Fedora, is now developing KVM, Fedora offers a plethora of tools for virtualization. The official documentation, although it’s for Fedora 13, is applicable to later versions. You can just install KVM with

 # yum install kvm 

to go the command-line way, or you can install some graphical tools to help you manage your virtual installations :

 # yum install virt-manager libvirt libvirt-python python-virtinst 

You will not need to execute further commands since the installation process on Fedora will mark the kvm module for autoloading. If you don’t want to reboot, use modprobe to load the module in-place.

2.1.2. Debian

Debian’s wiki comes to the rescue yet again, and if one follows the instructions, one will have KVM installed and ready to go in no time. It’s all about

 # apt-get install qemu-kvm libvirt-bin 

to install, setup and have the kvm-(amd|intel) kernel module loaded at boot.

2.1.3. Slackware

Here you will find a slackbuild for KVM which you can use according to this guide. If you have a modified kernel or just want to make sure your kernel has KVM enabled, type

 $ cat /boot/config |grep -i kvm 

and also check /etc/rc.d/rc.modules to see if the kvm module is set to be loaded at boot.

2.1.4. Arch

The wiki is a good guide for everything KVM-related. Since Arch, like Slackware, is a DYI distribution, you might need to take a few extra steps to start using KVM. The installation is as simple as

 # pacman -S qemu-kvm 

The same steps are to be taken here as on a Slackware machine : add your user, check that your CPU supports virtualization and that KVM is enabled in your kernel.

2.2. VirtualBox

2.2.1. Fedora

The VirtualBox site offers a repo file to be added in /etc/yum.repos.d/ and then perform a

 # yum update

to let yum know about your new repo and index it. Then perform a

 # yum install VirtualBox-4.0 dkms gcc
 # /etc/init.d/vboxdrv setup 
 # usermod -G vboxusers -a username 

and you should be set.

2.2.2. Debian

We don’t want to take sides here, but it looks like Debian’s documentation is better and more thorough. To install, just type

 # apt-get install linux-headers-$version virtualbox-ose 

which will install all necessary packages, compile the kernel module for you and set it to load at startup.

2.2.3. Slackware has a VirtualBox (the Open Source edition, which is the only one we will talk about here) entry. For a HOWTO on using slackbuilds, go here. Additional info can be found on, info which you might find useful especially if you are on a Slackware 13.37 64-bit machine. Remember to read the README of the slackbuild and it should be ok.

2.2.4. Arch

Arch’s documentation is helpful and complete, on par with Debian’s, so you should have no issues finding the info you need. All you need to do installation-wise is

 # pacman -S virtualbox qt 

and you’re set. You will need Qt for the GUI, if you need just CLI, don’t install it.The rest of the configuration steps are resemblant to Fedora’s so use the documentation to be able to get started.

3. Usage

3.1. KVM

As you might have noticed, we’re against copying blindly from a manual page and trying to substitute said manual. We will outline general and usual options and command-line flags (yes, we recommend the usage of CLI when working with KVM and GUI when working with VirtualBox), but you reading the manual page is essential, especially when dealing with a piece of somewhat complex software like this.

3.1.1. Storage

We recommend you create a separate directory where you will store the virtual disk images and another separate directory that will hold the ISO files used for installation. In the end, only you know best how to organize your files, but this setup, we think, will make your life easier. For the sake of example, let’ s say we want to install Fedora. We noticed when using KVM a somewhat smaller bandwidth than that available from our ISP, a problem that VirtualBox doesn’t seem to have. So, we install from DVD :

 $ cd ~ && mkdir iso && cd iso/ 
 $ wget -c\

Of course, if you prefer curl, kget or other download manager, use it. The same applies to the mirror : use one close to you for faster downloading. Now to set up our virtual disk(s) environment :

 $ cd ~ && mkdir kvmhdd && cd kvmhdd 
 $ kvm-img create fedora15.img 15G 

Before going further we recommend you run kvm-img with no arguments to see its main options and disk formats. What the second line above does : it creates a virtual disk file (img format) named fedora15 and having 15 gigabytes in size.

3.1.2. Installation

Now we’re ready to start the installation of Fedora 15 on our newly created disk :

 $ kvm -m 768 -boot d -cdrom ~/iso/Fedora-15-x86_64-DVD.iso -hda fedora15.img & 

What we just did : -m represents the size in megabytes of allocated memory, -boot tells kvm the primary boot device (think Windows drive letters), -cdrom is obvious, -hda is the first hard disk (you can use more than one disk, if you have the space, with -hdb being the second disk, and so on), and we used the ampersand at the end of the command line to regain control of the terminal. Ctrl+Alt will give/take control to/from the virtual machine in terms of mouse capture.

3.1.3. Using the virtual machine

After you install Fedora, in order to boot the newly installed system, change ‘-boot d’ to ‘-boot c’ and eliminate the ‘-cdrom …’ part if you don’t need it, or use the host’s CD-ROM drive with -cdrom /dev/sr0, for example :

 $ kvm -m 768 -boot c -hda fedora15.img & 

Suggestion: create a file in the kvmhdd (or the name you chose for the work directory) named that will contain the above line, make it executable and, when you need it, just run it :

 $ cd ~/kvmhdd && echo "kvm -m 768 -boot c -hda fedora15.img &" > && \
chmod +x && ./

That’s about it. Should you need more options, refer to the kvm manual page as it’s well written and will help you for certain.

3.2. VirtualBox

3.2.1. Creating a virtual machine

VirtualBox’s GUI takes the wizard approach in order to help you create a new virtual machine and we see the interface as quite a smart piece of software. Press Ctrl + N to create a new VM, then enter the name you want to give it (use something suggestive, like “Fedora15x86_64”. Based on such naming, VirtualBox will automatically determine what kind of system you want to set up and adjust itself automatically.

Next, choose the amount of memory you want Fedora to have, and VirtualBox tries to suggest a value depending on the OS and architecture. We recommend you don’t go much lower, as your VM might freeze because of out-of-memory problems (by the way, Anaconda will refuse to start the installation in graphical mode with less than 768 MB). Then create the hard disk and enter its size (the recommendation related to suggestions applies here too), allocating it dynamically (not a big problem if you don’t, just that we found this method to be a little faster in terms of I/O) and you’re set. In the main VirtualBox window you will see your new virtual machine listed and to the right, its’ settings. Change them as you see fit, and be careful to boot from DVD. Also, if you have multiple cores and want to use them, the System section is the place to go to.

3.2.2. Running a virtual machine

After installation, halt the VM and change the boot order so you can boot from the hard disk, then start by right-clicking on the entry on the left and, of course, “Start”. If everything’s alright, you will now boot Fedora 15 in a VirtualBox environment. We said earlier that the guest OS on KVM and VBOX doesn’t need alterations. While we were right, the guest experience can be improved in VirtualBox with things like full screen view or shared folders by installing the VirtualBox guest additions. This is basically a kernel module and some Xorg drivers for the guest, which you can install on your new Fedora by following the following steps :

 # yum update kernel && yum install kernel-devel kernel-headers dkms gcc gcc-c++ 

Reboot the VM after installing, then go to the Devices menu, select “Install Guest Additions”, which will mount the existing Guest Additions ISO image on the guest (on /media), and, as root, just do

 # cd /media/VBOXADD$version && sh ./ 

Afterwards, restart again and you will have advanced features of VirtualBox at your disposal.

4. Conclusion

When it comes to choosing virtualization solutions, as it is with editors, desktop environments or even operating systems, everyone has a personal opinion based on experience, reading and what their friends use. This is our experience, and we invite you to experiment and tweak until you find the best path to follow. There are, of course, other virtualization software packages but the limited space wouldn’t let us write about all of them. These are the most appropriate solutions for a home user (Open Source, that is), but that does not mean they aren’t used at enterprise-level too. We just hope this will help you get to get started.

Thank for your comments

Please log in using one of these methods to post your comment: Logo

You are commenting using your account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s