Hypervisors and Virtual Machines (VMs)
What is a VM?
A Virtual Machine (VM) is a software-based emulation of a physical computer. It can run an operating system and applications just like a physical computer. However, unlike a physical computer, a VM is isolated from the physical hardware, meaning multiple VMs can run on a single physical machine, each operating as if it were a standalone system. The operating system and applications running on a VM do not realize they are not running on actual hardware, as everything is emulated to provide the illusion of a physical machine.
What is a Hypervisor?
A Hypervisor is the "OS" between physical hardware and the VMs, managing and allocating the necessary resources to each VM. Essentially, the hypervisor acts as a cop, directing the use of physical resources such as CPU, memory, and storage so that each VM can run independently without interference from other VMs. This software layer is crucial for creating and managing VMs, ensuring they operate smoothly and efficiently.
Types of Hypervisors
There are two main types of hypervisors: Type 1 and Type 2. Both serve the same fundamental purpose of managing VMs but differ significantly in their architecture and use cases.
Type 1 Hypervisor (Bare-Metal)
A Type 1 hypervisor runs directly on the physical hardware, bypassing the need for a host operating system. This is why it is often referred to as a "bare-metal" hypervisor. When people discuss hypervisors, they usually refer to Type 1 hypervisors.
Type 1 hypervisors are typically used in enterprise environments and data centres where performance and scalability are critical. Examples include VMware ESXi, Microsoft Hyper-V, and Xen. The direct interaction with hardware means fewer layers between the VM and the physical resources, reducing overhead and potential points of failure.
Type 2 Hypervisor (Hosted / Software)
In contrast, a Type 2 hypervisor runs on top of an existing operating system. This type of hypervisor relies on the host OS to manage the underlying hardware resources. Because of this, it is generally easier to set up and use, making it suitable for personal use or small-scale deployments.
Examples of Type 2 hypervisors include VMware Workstation and Oracle VirtualBox. They offer the advantage of flexibility, as they can be installed on any system that supports the host OS. However, the additional layer of the host operating system introduces more overhead, which can impact performance and lead to more potential issues due to the dependency on the host OS.
Components of a VM
A VM consists of three main components, of which the hypervisor is the only one. The other two components are the Guest OS and the Virtual Hardware.
The Guest OS is the operating system that runs within the VM. It operates independently of the host OS and behaves just like it would on a physical machine. This operating system could be Microsoft Windows, Debian, or any other the user chooses.
Virtual Hardware consists of simulated hardware components, such as virtual CPUs, memory, disk storage, and network interfaces. The hypervisor maps these virtual components to the physical hardware resources, allowing the Guest OS to interact with what it perceives as physical hardware.
Why Use VMs?
One of the primary benefits of using VMs is resource efficiency. Organizations can optimize resource usage and reduce costs by allowing multiple VMs to share the same physical hardware. Another benefit is that VMs are isolated, meaning that security issues in one VM generally do not affect other VMs, even though they run on the same hardware.
VMs also provide scalability. Thanks to their virtual hardware, the hardware can easily be expanded, such as by increasing the amount of virtual memory the VM has access to. They can also offer higher reliability than a normal hosted system, as VMs can be deployed into clusters (a group of hypervisors). This setup allows for seamless VM migration to another hypervisor if a hypervisor fails, ensuring minimal downtime.
Additionally, VMs can be easily copied, backed up, or moved thanks to their virtual disk, simplifying disaster recovery and improving data protection.
Common Uses of VMs
Due to their flexibility, VMs are used in a variety of scenarios. In development and testing environments, VMs allow developers to create isolated environments to test software without affecting their main systems. In production, VMs enable using different operating systems and applications, ensuring high availability.
VMs are also used to support legacy systems. Some outdated applications cannot run on modern hardware, but VMs can emulate older hardware, allowing old software to continue to be used. This is particularly useful for businesses that rely on specialized software that may not have modern equivalents.
Issues with VMs
VMs are not without challenges. One of the primary issues is performance overhead. The virtualization layer can introduce overhead that impacts speed and efficiency. This is particularly noticeable with Type 2 hypervisors, where the additional layer of the host OS can further degrade performance.
Resource contention is another potential issue. When multiple VMs run on a single host and are not managed properly, they can compete for the same physical resources, such as CPU, memory, and storage. If not managed correctly, this can lead to bottlenecks and reduced performance for all VMs on the host.
Security is also a concern. While VMs provide isolation, vulnerabilities in the hypervisor can expose all VMs to threats if not patched regularly.
Hypervisor Type image by TecAdmin