A virtual machine (VM) is an operating system (OS) or application environment that is installed on software, which imitates dedicated hardware. The end user has the same experience on a VM as they would on dedicated hardware.
What is a VM and how does it work?
A VM provides an isolated environment for running its own OS and applications independently from the underlying host system or from other VMs on that host. The VM's OS is commonly referred to as the guest OS, and it can be the same as or different from the host OS or the other VMs. In this way, a single computer can host multiple VMs, all running different OSes and applications, without affecting or interfering with each other. The VM is still dependent on the host's physical resources, but those resources are virtualized and distributed across the VMs and can be reassigned as necessary, making it possible to run different environments simultaneously, as well as accommodate fluctuating workloads.
From the user's perspective, the VM operates much like a bare-metal machine. In most cases, users connecting to a VM won't be able to tell that it's a virtual environment. The guest OS and its applications can be configured and updated as necessary and new applications installed or removed, without affecting the host or other VMs. Resources such as CPUs (central processing units), memory and storage appear much like they do on a physical computer. Although users might run into occasional glitches, such as not being able to run an application in a virtual environment, these types of issues tend to be minimal.
A computer that hosts VMs requires specialized software called a hypervisor. The hypervisor emulates the computer's CPU, memory, hard disk, network and other hardware resources, creating a pool of resources that can be allocated to the individual VMs according to their specific requirements. The hypervisor can support multiple virtual hardware platforms that are isolated from each other, enabling VMs to run Linux and Windows Server OSes on the same physical host.
This article is part of
The hypervisor manages resources and allocates them to VMs. It also schedules and adjusts how resources are distributed based on how the hypervisor and VMs have been configured, and it can reallocate resources as demands fluctuate. Most hypervisors fall into one of two categories:
- Type 1. Also referred to as a bare-metal hypervisor, this type of hypervisor runs directly on the physical host machine and has direct access to its hardware. Type 1 hypervisors typically run on server computers and are considered more efficient and better-performing than Type 2 hypervisors, making them well suited to server, desktop and application virtualization. Examples of Type 1 hypervisors include Microsoft Hyper-V and VMware ESXi.
- Type 2. Sometimes called a hosted hypervisor, a Type 2 hypervisor is installed on top of the host machine's OS, which manages calls to the hardware resources. Type 2 hypervisors are generally deployed on end-user systems for specific use cases. For example, a developer might use a Type 2 hypervisor to create a specific environment for building an application, or a data analyst might use it to test an application in an isolated environment. Examples of Type 2 hypervisors include VMware Workstation and Oracle VirtualBox.
Most hypervisors don't require special hardware components, but the computer that runs the hypervisor must have the resources necessary to support VMs, as well as the hypervisor's operations and the host's own operations, no matter how minimal those might be.
Why use a VM?
Organizations routinely deploy VMs in their data centers to support a wide range of use cases and workloads. They use VMs for several reasons, including:
- VMs help organizations consolidate servers and better utilize hardware resources. Because a single server can run multiple VMs simultaneously, organizations can use resources on a single server more efficiently, reducing the need to spread workloads across multiple servers, which often operate below capacity. In this way, organizations save capital and operating expenses.
- VMs provide isolated environments, making it possible to run different types of OSes and applications on a single server. Organizations can deploy legacy and business applications in the environments they require, without having to deal with contention issues or needing to purchase multiple servers to support different environments.
- VMs make it easy to scale applications and accommodate fluctuating workloads, which is one reason virtualization plays such a key role in cloud computing and systems such as hyper-converged infrastructure (HCI).
- Organizations also turn to VMs because of the extra layer of security they provide against potential threats. If a VM is compromised, it can be deleted or rolled back to a recent backup or snapshot. Because it's isolated from the host and other VMs, the threat is limited to that VM.
- VMs make it easier to manage multiple environments running different OSes. Because workloads are consolidated on fewer servers, there are also fewer physical systems to deploy and maintain. In addition, most virtualization platforms make it possible to manage the VMs from a single interface, even if those VMs are distributed across multiple hosts.
Organizations often deploy VMs when they want to run multiple applications simultaneously that require different OSes and processing power. For example, a quality assurance (QA) team might want to test multiple web servers and small databases at the same time, or IT might need to use the same server to run graphics-intensive gaming software and a customer service database. DevOps can also take advantage of VMs for their continuous integration and delivery operations, or an organization might need an environment to run legacy applications alongside other workloads.
Advantages of VMs
Although containers and other modern application technologies have affected VM usage, VMs continue to be deployed extensively by organizations of all sizes because they offer several important benefits, including:
- Virtualization limits costs by reducing the need for physical hardware systems. VMs use hardware resources more efficiently than bare-metal deployments. This reduces the number of servers that must be deployed and the associated maintenance costs. It also lowers the demand for power and cooling.
- VMs are isolated, self-contained environments that can run different types of applications and OSes on the same server, eliminating potential contention and security issues, as well as the need to deploy multiple physical servers.
- VMs can be easily moved, copied and reassigned between host servers, as well as between on-premises and cloud environments, improving hardware resource utilization, while making it easier to scale applications.
- VMs ease management in multiple ways. Administrators, developers and testers can quickly deploy VMs, and multiple VMs can be easily managed from a centralized interface. Admins can also take advantage of virtual environments to simplify backups, disaster recovery (DR), new deployments and basic system administration tasks.
- Because VMs operate in isolated environments, they can provide an extra level of protection against malicious attacks. They also support such features as snapshots and backups, which make it easy to roll back a VM in the event the current one becomes compromised or corrupted.
VMs don't require specialized or hypervisor-specific hardware. However, the host computer needs more bandwidth, storage and processing capacity than a traditional server or desktop if the physical hardware is going to host multiple running VMs. Because VMs on a physical host can consume unequal resource quantities -- one might hog the available physical storage, while another stores little -- IT professionals must balance VMs with available resources. Fortunately, virtualization platforms ease the process.
Two types of VMs
VMs are often categorized by the type of hypervisor that manages them or by the type of workloads they support. However, VMs are also categorized by VM type:
- Process VMs. A process VM is a temporary, platform-independent programming environment for executing a single process as an application. The environment provides a high-level abstraction that masks the underlying hardware or OS. A process VM is created when the process starts and is destroyed when the process ends. Two common examples of process VMs are Java Virtual Machine, which is part of the Java platform, and Common Language Runtime, which is used for the .NET Framework.
- System VMs. A system VM is a fully virtualized environment that's hosted on a physical server and runs its own OS. The VM shares the host's physical resources but provides a complete environment for running applications and services, like a physical machine, but without the overhead. System VMs rely on a hypervisor to virtualize the hardware resources and make them available to VM environments. Common examples of system VMs include those supported by virtualization platforms such as VMware vSphere and Microsoft Hyper-V.
VM vs. containers
Containers are like VMs, except they virtualize the OS only, rather than the rest of the underlying hardware. Containers include the code, system tools, runtime, system libraries and settings needed to run the containerized applications. That's why containers are often used for multiple applications running on the same OS. Containers are also used for cloud-native, distributed applications and to package legacy applications for increased portability and deployment simplicity. Docker, which entered the market in 2013 as a Linux-based container platform, is one of the leading container developers.
Containers have lower overhead than VMs and are much more lightweight. They also boot faster, use fewer server resources and are more portable, making them well suited to modern application technologies such as microservices. However, all containers running on the same host or ported to a different host must support the same OS. VMs can run different OSes and they offer a greater degree of isolation; although, they can be configured to communicate with each other as necessary. VMs are better suited for monolithic applications or for running multiple applications together. They're also handy for legacy applications that require isolated environments.
Containers and VMs can be used together to provide the best of both worlds. Although this adds overhead, it provides an additional layer of security that containers alone are missing. The combination also makes it possible to deploy infrastructure that can support modern and traditional workloads. Most HCI platforms are based on virtualization technologies, but many have added support for Kubernetes, which is implemented within the VM structure. As a result, all containerized workloads run in VMs, benefiting from the isolation, while operating alongside traditional workloads.
Setting up a VM
The process used to set up a VM depends on the virtualization platform. Many platforms offer wizards and other features that make it easy to create and deploy a VM. For example, in VMware vSphere, an admin can create a VM from a template or clone or create a single VM from scratch. Included with vSphere is the New Virtual Machine wizard, which walks the user through the process of creating the VM, whether a new one or one based on a template or clone.
Red Hat Virtualization takes a different approach to setting up a VM. For instance, to install a Linux VM, the user would take the following steps:
- Create a blank VM.
- Add a virtual disk for storage.
- Add a network interface for connecting the VM to the network.
- Install the guest OS.
- Register the VM with the Content Delivery Network and attach the necessary subscriptions.
- Install any required guest agents or drivers.
Because the process of setting up a VM is specific to the virtualization platform, users should review the platform's documentation before deploying any VMs.
Using VMs comes with several important management considerations, many of which can be addressed through general systems administration best practices and tools designed to manage VMs.
There are some risks to consolidation, including overtaxing resources or potentially experiencing outages on multiple VMs due to physical hardware failure. Although cost savings increase as more VMs share the same hardware platform, so does the risk. It might be possible to place hundreds of VMs on the same hardware, but if the hardware platform fails, it could take out dozens or hundreds of VMs. However, the use of VM backups or snapshots can help mitigate those risks.
Multiple vendors offer virtualization platforms. Four of the most popular platforms come from VMware, Citrix, Microsoft and Red Hat:
- VMware vSphere is a widely implemented virtualization platform that has been recently rearchitected to include native support for Kubernetes, making it possible to run traditional and modern workloads in VMs. VMware vSphere is highly scalable and can support high-performing applications such as SAP HANA.
- Citrix Hypervisor -- formerly Citrix XenServer -- is a high-performance hypervisor based on the Xen Project open source hypervisor. Citrix Hypervisor is optimized for virtual app and desktop workloads, as well as for Windows and Linux virtual servers. Admins can configure policies that restart VMs on another server in case one of them fails.
- Microsoft Hyper-V is a Windows Server role that enables admins to create and manage VMs. Hyper-V has the advantage of being an integrated component in the Windows Server platform, helping simplify implementations. Hyper-V supports both Windows and Linux VMs and includes features for easily moving, distributing or replicating VMs.
- Red Hat Virtualization is an enterprise virtualization platform built on Red Hat Enterprise Linux (RHEL) and Kernel-based VM (KVM). The platform can support mission-critical applications and resource-intensive workloads and comes integrated with the Red Hat OpenStack, RedHat OpenShift and Red Hat Ansible Automation platforms.
Numerous open source virtualization products have also staked their claims in the VM market, including KVM, OVirt and Proxmox VE. In addition, cloud computing makes extensive use of virtualization; however, it layers additional technologies onto the platform, such as self-service provisioning and chargeback. For example, in a virtualized data center, IT staff can spin up new VMs based on user demand or a new project. However, in a cloud environment, an end-user can provision VMs from a self-service catalog and specify resources without interacting with the underlying physical equipment or requiring the help of an admin.