Virtual Machines

Learn how VMs virtualize hardware, how hypervisors schedule resources, and how to build a safe local lab.

6 min read 8 lesson sections
  • #virtualization
  • #hypervisor
  • #virtual machine
  • #kvm
  • #virtualbox
  • #isolation
Virtual Machines: Learn how VMs virtualize hardware, how hypervisors schedule resources, and how to build a safe local lab.
Concept map

Virtualization lets one physical computer behave like several independent computers. A software layer divides the host’s processor, memory, storage, and network into virtual resources, so each guest can run its own operating system and applications. This makes it possible to test another operating system, consolidate services, or create a repeatable learning lab without buying another machine.

Picture it: A physical computer is like an apartment building. The hypervisor is the building manager, and each VM is a private apartment with its own space and rules.

What makes a virtual machine?

A host is the physical computer and its operating system. A guest is the operating system installed inside a virtual machine (VM). The hypervisor, also called a virtual machine monitor, creates the VM and mediates its access to the host’s hardware.

The VM sees virtual devices: a number of CPU cores, a portion of memory, a virtual disk, and network adapters. The guest operating system uses these much like physical hardware. The hypervisor schedules virtual CPUs on real CPU cores, allocates memory, and stores the virtual disk as files or logical volumes.

Interactive diagram

One VM · guest OS plus virtual devicesCompute requestsCompute requestsMemory viewMemory viewDisk I/ODisk I/ONetwork framesNetwork framesvm-vcpu ↔ vm-hypervisorvm-memory ↔ vm-hypervisorvm-disk ↔ vm-hypervisorvm-vnic ↔ vm-hypervisorPhysical resourcesPhysical resourcesGuest OS and appsGuest OS and appsvCPUvCPUGuest memoryGuest memoryVirtual diskVirtual diskvNICvNICHypervisorHypervisorPhysical hostPhysical host
Legend

Current step

The guest schedules work on vCPUs

A vCPU is a virtual scheduling context; it is not automatically one permanently reserved physical core.

The guest sees virtual devices, not a dedicated physical computer. The hypervisor schedules and maps requests to the host resources available to it.

Documentation example: addresses use the RFC 5737 ranges and ASNs use the reserved private range. Nothing here connects to a real network.

Hypervisor types

Type 1 hypervisors run directly on the hardware and are common in data centres. Examples include VMware ESXi, Microsoft Hyper-V, and KVM-based platforms. They are designed to manage many VMs and make efficient use of server resources.

Type 2 hypervisors run as applications on a desktop operating system. VirtualBox and VMware Workstation are familiar examples. They are convenient for a personal computer because you can start and stop VMs alongside your normal apps.

Both types create isolated guests, but neither makes a VM invulnerable. Keep the host and guest patched, use trusted VM images, and avoid exposing services you do not need.

Interactive diagram

Server virtualization layerVirtual devicesVirtual devicesVirtual devicesVirtual devicesSchedules and maps resourcesSchedules and maps resourcesGuest VM AGuest VM AGuest VM BGuest VM BType 1 hypervisorType 1 hypervisorPhysical server hardwarePhysical server hardware
Legend

Current step

Hardware provides a finite resource pool

The physical server supplies processor time, memory, storage, and network devices.

This is a teaching model. Some Type 1 platforms also use a privileged management partition or operating-system services; the key difference is where the virtualization layer sits.

Documentation example: addresses use the RFC 5737 ranges and ASNs use the reserved private range. Nothing here connects to a real network.

Why use virtualization?

  • Isolation: a guest’s operating system and applications are separated from other guests.
  • Consolidation: multiple services can share one physical server instead of each needing its own machine.
  • Repeatability: a VM can be recreated from a known image, making tests and training exercises easier to repeat.
  • Snapshots: many hypervisors can save a VM’s state before a change, which is useful for short-lived experiments.

The trade-offs are resource use and operational work. Every full VM needs an operating system, memory, storage, updates, and backups. Containers usually start faster and use fewer resources because they share the host kernel, while VMs provide a separate guest kernel and a stronger boundary for many use cases.

Interactive diagram

VM includes a guest OS and kernelContainers share the host kernelvm-hardware ↔ vm-hypervisorvm-hypervisor ↔ vm-guestvm-guest ↔ vm-appcontainer-hardware ↔ container-kernelcontainer-kernel ↔ container-runtimecontainer-runtime ↔ container-acontainer-runtime ↔ container-bPhysical hardwarePhysical hardwareHypervisorHypervisorVM · guest OS + kernelVM · guest OS + kernelApplicationApplicationPhysical hardwarePhysical hardwareHost OS kernelHost OS kernelContainer runtimeContainer runtimeContainer AContainer AContainer BContainer B
Legend

Current step

A VM virtualizes hardware

The hypervisor presents virtual devices and each VM runs its own guest OS and kernel.

Both approaches provide useful isolation, but at different layers and with different trade-offs. Containers can also run inside VMs, combining application packaging with a VM boundary.

Documentation example: addresses use the RFC 5737 ranges and ASNs use the reserved private range. Nothing here connects to a real network.

CPU and memory are shared resources

A virtual CPU is scheduled onto physical CPU cores; it is not automatically a dedicated core. Assign only the vCPUs the workload can use, then observe host and guest performance. Giving many idle VMs oversized CPU allocations can make scheduling less predictable.

Guest memory also comes from a finite host pool. Leave memory for the host, and monitor pressure before increasing VM allocations. Dynamic memory and overcommit features can help an administrator use capacity flexibly, but they cannot remove the host’s physical limits.

Interactive diagram

Independent guest workloadsvCPU · memoryvCPU · memoryvCPU · memoryvCPU · memoryvCPU · memoryvCPU · memoryPhysical capacityPhysical capacityApplication VMApplication VMDatabase VMDatabase VMLab VMLab VMHypervisor schedulerHypervisor schedulerPhysical host resource poolPhysical host resource pool
Legend

Current step

Guests receive virtual capacity

The hypervisor presents vCPUs and memory to each guest while drawing on the same host pool.

Illustrative only: no capacity numbers are implied. Overcommit can increase density, but sustained demand beyond available host capacity can cause contention and poor performance.

Documentation example: addresses use the RFC 5737 ranges and ASNs use the reserved private range. Nothing here connects to a real network.

Build a small learning lab

  1. Check the host. Confirm that hardware virtualization is enabled in the firmware and that your computer has enough free memory and disk space. Leave resources for the host to remain responsive.
  2. Choose a hypervisor. Use a desktop hypervisor such as VirtualBox for a first local lab, or a Type 1 platform when learning server virtualization. Download it from its official source.
  3. Choose a guest image. Obtain an operating system image from its publisher and review the system requirements. Start with one guest so it is easier to understand how resource allocation works.
  4. Create the VM. Give it a clear name, select the guest operating system, and assign a modest amount of memory, CPU, and disk. A dynamically allocated virtual disk can grow as needed, but still consumes space on the host.
  5. Install and update the guest. Boot from the image, follow the operating system installer, then apply updates. Use a standard user account for everyday work and reserve administrator access for tasks that need it.
  6. Experiment safely. Take a snapshot before a practice change, then observe CPU, memory, disk, and network use. Revert the snapshot when finished; do not treat snapshots as a backup.

Networking and storage basics

A VM’s network adapter can commonly be NAT, bridged, or host-only. NAT lets the guest make outbound connections through the host, bridged mode puts it on the local network like another computer, and host-only mode limits communication to the host and selected guests. Choose the narrowest mode that supports the exercise, especially when testing unfamiliar software.

The VM’s virtual disk is backed by storage on the host. Keep enough free space for both the virtual disk and snapshots, and make separate backups of data you want to keep. A snapshot is a convenient checkpoint, not a substitute for an independent backup.

Interactive diagram

Checkpoint relationshipCheckpoint relationshipCreate separate instanceCreate separate instanceCopy to separate systemCopy to separate systemSource VMSource VMSnapshot / checkpointSnapshot / checkpointCloneCloneIndependent backup storageIndependent backup storage
Legend

Current step

Use a snapshot for a short experiment

A checkpoint helps return one VM to an earlier state, but it is not an independent backup.

A snapshot may depend on the original virtual disk and can preserve unwanted state. A clone is a separate VM copy. An independent backup is designed for recovery even if the primary VM storage is lost.

Documentation example: addresses use the RFC 5737 ranges and ASNs use the reserved private range. Nothing here connects to a real network.

Interactive diagram

Guest traffic is translated by the hostOutboundOutboundnat-vm-b ↔ nat-switchnat-switch ↔ nat-hostnat-host ↔ nat-routernat-router ↔ nat-internetOutboundIPGuest VM AGuest VM AGuest VM BGuest VM BVirtual NATVirtual NATHost network stackHost network stackLAN routerLAN routerInternetInternet
Legend

Current step

NAT carries guest traffic outward

The guest sends through a virtual NAT service and the host network stack; return traffic is associated with that outbound flow.

Names and details vary by hypervisor. These are conceptual paths: choose the narrowest connectivity needed, and do not assume a virtual switch is a firewall.

Documentation example: addresses use the RFC 5737 ranges and ASNs use the reserved private range. Nothing here connects to a real network.

Before you finish the lab

  • The guest boots, is updated, and uses an ordinary account for day-to-day work.
  • The VM has only the CPU, memory, disk, and network access needed for the exercise.
  • You can identify which network devices can reach the guest.
  • Any snapshot is temporary; important files have an independent backup.
  • Lab-only services and resources are removed when the exercise ends.

You now have the core VM mental model: a guest OS uses virtual hardware, a hypervisor maps it to a shared host, and the administrator controls resource limits, connectivity, and recovery. Continue with the complete Virtualization roadmap to connect this VM to containers, cloud infrastructure, and server clusters.

Trusted references