Opensource Hypervisors and Starting Virtual Machine with Oracle Virtualbox
This article will be break down into two sessions. First session is an introduction to hypervisor and virtualization and show you the different open source hypervisors you can leverage. Second section will be focused on an example of how you can start running a first virtual machine with Oracle Virtual Box, which is an open source software for its basic version.
Hypervisor and Virtualization
If virtualization is the principle behind any cloud system, then a hypervisor is that software **enabling the virtual machine creation process. Of course, the concepts of virtualization and hypervisor can go much deeper, but, for now, let’s just say that a hypervisor is the software that emulates the physical computer machines by virtualizing the available physical layer. And you should be glad to know there are number of open source hypervisors available. But first, here is one question you should ask first.
Why do I need a virtual machine?
Broadly, there are two reasons why you might consider to get a virtual machine.
REASON 1: Using the virtual machine as workstation
If you need to use a virtual machine to test out some softwares, work on documentation or spreadsheet, or run an Interactive Development Environment (IDE), although there is a cloud based IDE called Eclipse Che, which is also an open source, you need the virtual machine as a workstation. This clearly has numerous benefits over the traditional way of installing an operating system directly on a hard drive. For example, when you use a virtual machine, you can pretty much modify anything you want without worrying about changing the sensitive configuration or important registration file on the actual physical machine. Also, running the virtual machine as a workstation allows you to experiment with different operating systems and different hardware settings.
And you do not have to restrict a workstation to a single machine. Some companies like Citrix or VMWare can provision the multiple workstations, and the users can just login through Lightweight Directory Access Protocol (LDAP) or Active Directory (AD). However, the similar feat can be achieved with the open source technologies. A team can provision multiple virtual workstations using hypervisors, auto-install with the essential software and libraries, and connect to the workstation directly, use ssh to connect, or even leverage the graphical environment using something like VNC client.
Using the Virtual Machine as Service
But the true strength of virtual machines lies in provisioning the virtual machines as server or service layers. Imagine running a DevOps tool, a database, or a micro service application. To consume any of these applications, the tool has to be put into a service where a client can interact with the service to operate or to exchange data. These services can be installed into a single physical server, but the concept of virtualization allows you to slice the hardware resources into multiple portions while offering isolated environment.
Since you now know what you want to do with your virtual machine, we will look into two types of hypervisors and see how they are different from each other. And we will introduce some of popular open source hypervisors.
Type I Hypervisor: Running Directly on the machine’s physical hardware
Type 1 Hypervisor is the most basic but an important one as well as most widely used one. Type 1 Hypervisor directly virtualizes the hardware resources. For example, processor, memory, storage, and network layer can be all virtualized. Type 1 Hypervisor is also known as the “bare metal hypervisor” because it does not require an operating system.
Here is the list of open source Type I Hypervisors:
Type II Hypervisor: Running as virtual machine manager on top of an Operating System
Type II Hypervisor manages the hardware resources indirectly through an operating system. This is accomplished by virtualizing the instances as software processes. The benefit of Type II is that hypervisor can run without too much complex deployment and management compared to Type I Hypervisor. However, the downside is that Type II Hypervisor is limited to run a highly scalable dynamic virtualization due to high overhead.
Oracle Virtual Box: https://www.virtualbox.org
Among these, I want to briefly expand Kernel-Based Virtual Machine (KVM).
More detail about Kernel-Based Virtual Machine (KVM)
People debate whether KVM falls under Type I or Type II, but KVM is indeed a Type I Hypervisor because it virtualizes x86. Many Linux distributions including Centos, Debian, and Red Hat Linux all can leverage KVM. It can manage multiple virtual machines, not only for Linux but for any operating system including Windows or MacOS. KVM offers the numerous benefits including the following:
Security: KVM uses a combination of security-enhanced Linux (SELinux) and secure virtualization (sVirt) for enhanced VM security and isolation. SELinux establishes security boundaries around VMs. sVirt extends SELinux’s capabilities, allowing Mandatory Access Control (MAC) security to be applied to guest VMs and preventing manual labeling errors.
Memory Management: KVM inherits the memory management features of Linux, including non-uniform memory access and kernel same-page merging. The memory of a VM can be swapped, backed by large volumes for better performance, and shared or backed by a disk file.
Performance and Scalability: KVM inherits the performance of Linux, scaling to match demand load if the number of guest machines and requests increases. KVM allows the most demanding application workloads to be virtualized and is the basis for many enterprise virtualization setups, such as data centers and private clouds.
Full list of benefits can be found here: Benefits of KVM
In the remaining of this article, we will go through how to start an operating system with Virtual Box.
How to run a Linux with Virtual Box
These steps will walkthrough how you can run a virtual machine as a workstation with Virtual Box. However, you can also leverage other hypervisors to achieve the similar feat.
STEP 1: Download a Virtual Box
First step is to download a Virtual Box from the following link:https://www.virtualbox.org
Once you complete the installation process, you will be able to launch the application. For me, I installed on the Mac, so I can launch with clicking the Virtual Box icon.
When you start a first time, you will see an empty project that looks like this.
STEP 2: Download a Linux Operating System Distribution
Next step is to download an operating system for your virtual machine. You can pretty much run any operating system including Windows or Mac OS, as long as you have the appropriate license and the image. However, since Linux is free, we will use a downloadable Linux distribution. I am going to use Centos, but you can use pretty much as Linux distribution. Some famous ones are listed below:
Centos : https://www.centos.org/download
STEP 3: Configuring the Virtual Machine setting
Once you downloaded the OS image, click New button to start a new virtual machine. Give some name, change the type, and choose the appropriate Linux version. In my case, I downloaded a Centos 64 bit version, so I am using Red Hat (64-bit).
Next step will ask you whether you want to create a new virtual hard disk. You definitely need one unless you have a pre-configured image file or you want more complex setup. I chose Create a virtual hard disk now option and chose Create.
After you chose a hard disk option, it will ask to select the hard disk file type. You can proceed with the default option, which is VDI (VirtualBox Disk Image).
This step will ask you select how you want your virtual hard disk to grow. The recommended option is Dynamically allocated, which is default.
Last step will ask you to select the file location and also configure the size of virtual hard disk. I left the name as the default, but you can choose pretty much any name. For virtual hard disk size, I set as 8GB as the size seems big enough to store on hard disk.
You completed adding virtual machine. There are few more settings you can go through such as configuring the network drive by clicking Settings, but let’s just try to launch our VM for now. Click Start button.
Here, you browse your file system to choose the image where you downloaded your Linux image. Click Start to launch the virtual machine.
Congratulation! You successfully started your first virtual machine through Virtual Box. The screen might look different depending on your chosen Linux distribution, but you can proceed with installing the operating system on virtual machine.