A virtual machine (VM) is a software program that emulates a physical computer and its components, including the operating system, hardware, applications, and stored data. A VM allows a user to run an OS and software inside another OS, providing resource isolation and virtualization.
How Virtual Machines Work
A VM runs as a process on top of a physical machine called the “host.” The software that creates and runs VMs is called a “hypervisor.” It partitions the physical resources of the host to allocate to each VM.
There are two main types of hypervisors:
- Type 1 – Runs directly on host hardware
- Type 2 – Runs as an application inside the host OS
Popular Type 1 hypervisors:
- VMware vSphere Hypervisor
- Citrix XenServer
- Microsoft Hyper-V
Popular Type 2 hypervisors:
- Oracle VM VirtualBox
- VMware Workstation
- Parallels Desktop
A VM emulates various components in software, including:
- CPU – VM is allocated virtual CPU threads mapped to physical CPU cores
- Memory – Host RAM is partitioned and allocated per VM
- Storage – Virtual hard disk files act as VM hard drives
- Network – Virtual NIC allows network connectivity
This provides each VM with its own set of virtual hardware resources.
Isolation from Host
VMs run in isolation from each other and the host system. The hypervisor creates these isolated VM environments called “containers.” This helps security and stability – issues in one VM won’t affect others.
Resources are dynamically allocated to VMs as needed. So multiple VMs can run on a single server.
Why Use Virtual Machines?
There are many benefits of virtualization using VMs:
- Portability – Easily move VMs to different hosts
- Scalability – Adjust hardware resources on demand
- Efficiency – Consolidate multiple workloads on one server
- Isolation – Contain and segment environments
- Disaster Recovery – Replicate VMs for availability
- Testing & Development – Create test environments
This makes VMs very useful for data centers and cloud computing.
Comparison to Containers
Containers are another form of workload isolation and virtualization. The key differences from VMs are:
|Emulate full hardware stack
|Abstract OS kernel
|Larger resource footprint
|Slower boot up
|Very fast startup
So containers complement VMs in many environments today.
Popular Platforms and Tools
There are many tools and platforms built specifically for managing VMs:
- VMware vSphere – Industry leading virtualization platform
- Microsoft Hyper-V – Hypervisor built into Windows
- KVM – Open source hypervisor in Linux
- VirtualBox – Free hypervisor from Oracle
- QEMU – Hosts and emulates virtual CPUs
Third party tools also help manage VM environments, like Vagrant and Packer.
And many major cloud platforms provide VMs on demand today:
- AWS EC2 Instances
- Azure Virtual Machines
- Google Compute Engine
Use Cases and Examples
VMs have many production use cases:
Development & Testing
- Spin up disposable dev and test servers on a single host machine.
- Standardize environments across teams.
- Scale up and down flexibly.
- Consolidate multiple apps onto fewer physical servers.
- Optimize hardware utilization.
- Allocate resources dynamically.
- AWS, Azure and GCP all provide on-demand cloud VMs.
- Quickly scale capacity up and down.
- Consistent environments across hybrid cloud.
Recovery & Migration
- Replicate VMs onto other hosts for disaster recovery.
- Migrate VMs across servers with no compatibility issues.
- Virtual machines emulate dedicated hardware, isolated from host.
- Hypervisors manage and provision resources to VMs.
- Benefits include portability, efficiency and scalability.
- VMs are widely used for development, testing and production.
- Cloud platforms provide on-demand access to VMs.
Virtual machines provide flexible, isolated environments by partitioning physical servers into separate containers. This allows multiple workloads to run efficiently on a single server.
VMs emulate dedicated hardware resources for each environment. Hypervisors manage the virtualization layer and allocation of resources like CPU, memory and storage to each VM.
Key benefits of using VMs include increased efficiency, scalability, availability and portability. This makes them invaluable for development, testing, server consolidation, cloud computing and disaster recovery scenarios.
Frequently Asked Questions
- What is a virtual machine?
A virtual machine is a software program that emulates a full computer system, including CPU, memory, storage and network resources. This provides a virtualized environment isolated from the underlying host server.
- How does a VM work?
A hypervisor creates and runs virtual machines by partitioning resources from the host hardware. This allows multiple VMs with dedicated CPU, memory and storage allocation to run on a single physical server.
- What does a VM do?
A VM provides a self-contained, isolated environment to run operating systems and software. It behaves like a separate physical computer from the end user’s perspective.
- What runs a virtual machine?
Specialized virtualization software called a “hypervisor” runs VMs by virtualizing and managing access to the underlying physical hardware resources. Popular hypervisor platforms include VMware, Hyper-V, KVM and VirtualBox.
- How are VMs different from containers?
Containers provide operating system-level virtualization by abstracting the OS kernel. VMs emulate hardware and run a full OS, so have larger overhead than containers but provide total environment isolation.
- Can you run an OS in a VM?
Yes, a VM allows you to run a “guest” operating system within a “host” OS. For example, you can run Linux inside a Windows VM, or vice versa on the same physical hardware.
- What is vSphere?
VMware vSphere is the leading server virtualization platform used to create, manage and monitor virtual machines. The vSphere hypervisor natively runs each VM directly on the server hardware .
- What is Hyper-V?
Hyper-V is Microsoft’s native hypervisor for managing Windows virtual machines. It is tightly integrated at the Windows kernel level to efficiently allocate resources to VMs.
- What’s the difference between XenServer and ESXi?
These are two competing bare metal hypervisor platforms – XenServer from Citrix, and ESXi from VMware. They have different architectures but both enable server consolidation by hosting multiple VMs.
- Can you convert a physical server to a VM?
Yes, physical-to-virtual (P2V) conversion tools can replicate an existing physical server into a virtual machine within a hypervisor environment. This allows lifting and shifting workloads into new infrastructure.
- What tools help manage VMs?
Platforms like vCenter Server, System Center VMM, and Red Hat Virtualization Manager centralize administration, monitoring and provisioning of VMs and hosts. Tools like Packer automate OS image builds.
- How do clouds use virtualization?
Public clouds make extensive use of virtualization to provision customer VMs on-demand. This allows them to abstract physical resources and rapidly allocate/de-allocate them using orchestration and automation tools.
- What is a virtual machine monitor?
A Virtual Machine Monitor (VMM) is an alternative name for a hypervisor – the software layer that manages virtual machines. Microsoft calls its native Windows hypervisor Hyper-V VMM.
- What is VM live migration
Live migration refers to the ability to move running virtual machines across physical hosts without disrupting the VM. This avoids any downtime for maintenance or failovers. Memory, storage and network state are transferred.
- What does a virtual machine emulate?
A VM emulates a full computer system. The hypervisor virtualizes physical hardware like CPU processors, memory, storage devices, network interface controllers to present a virtual set of hardware resources to each VM.
- Why should I use VMs?
There are many benefits:
- Portability – Move VMs easily
- Isolation – Contain environments
- Utilization – Consolidate workloads
- Availability – Replicate VMs