DEV Community

Quame Jnr
Quame Jnr

Posted on

Virtual Machines: How One Computer Becomes Many

Introduction

Virtual machines (VM) virtualize the hardware of a physical computer (like CPU, RAM, storage) to allow multiple isolated operating systems (OS) on the physical computer.

Brief History

Before the age of personal computing, computers used to be these large mainframes that were being used in big organizations and schools like MIT. These mainframes had relatively a lot of resources at that time and thus to use resources efficiently and reduce idle time, Compatible Time Sharing System (CTSS) was introduced

  • In the early 1960s, researchers on MIT's Project MAC introduced CTSS. CTSS allowed multiple users to use the same computer at the same time giving them the illusion that they are the only ones who had access to the computer at the time. It provided some form of isolation protecting your personal files but you still used the same applications and OS on the machine.
  • In the 1960s, IBM introduced the CP-40, an experimental time sharing project that laid the groundwork for VMs. It took CTSS a step further by using virtualization to give users the illusion that they had their own dedicated machine. Users could run multiple isolated computing sessions on the machine giving them greater control, flexibility and isolation.
  • Building on the CP-40 experiment, IBM released VM/370 in August 1972, which became the first commercial virtual machine system. This marked the true beginning of virtualization as we know it today.

This early virtualization concept from VM/370 evolved over decades, eventually becoming the foundation for today's hypervisor technology.

How does it work

Virtual machines use what we call a hypervisor to create virtualized hardware that allows operating systems to run in isolation over a physical computer's hardware. This allows different operating systems to run on top of the computer hardware unaware it is not directly on the physical machine. The process involves 3 components.

Components

  • The host machine: This is the physical computer that provides the hardware resources.
  • The guest machine: This is the virtual machine that will be running on top of the host machine.
  • Hypervisor: This sits between the host and guest machine and acts as a translator. It acts as a translator managing host's resources to the guest VMs.

Process

Assuming the guest operating system wants to write to a file in the virtual hard disk, it will issue a syscall to perform the action just as it would on a physical machine.

  1. Intercepting requests: The hypervisor will intercept the request coming from the guest machine.
  2. Translating requests: The hypervisor will translate the request to the host machine. In this case, it ensures the file the guest machine is trying to write into maps to the specific folder on the physical drive. This is because virtual machines, its configs and applications all exist in a specific folder on your drive. It also translates the commands into instructions the host computer can understand.
  3. Resource allocation: The hypervisor will manage and allocate resources to the guest VM from the host's pool and ensure each VM is isolated.
  4. Returning Results: Once the physical machine is done performing the action, the hypervisor translates back to the format the guest OS can understand.

Types of Hypervisors

Hypervisors are of two different types based on where they sit on the stack.

  • Type 1: In type 1, the hypervisor runs directly on the bare metal hardware without a traditional host OS underneath it. This makes it fast and efficient. This is mostly used in enterprise data centers and cloud environments. Eg. VMware ESXi.
  • Type 2: Type 2 hypervisors are installed as an application on the host machine's OS. This adds an extra layer as the hypervisor has to translate requests through the host OS instead of directly to the hardware. This is simple to install and mostly used by developers for testing in a different OS and playing around safely in a different OS. Eg. VirtualBox

Why should you care?

VMs are incredibly useful, they provide isolation, flexibility and portability and these are some of the reasons I think you should care;

Sandboxing

VMs create the ultimate sandbox if you're a developer or curious. You can use it to;

  • test untrusted software
  • mess around with system configs
  • test your program on multiple operating systems

Running Multiple Operating Systems

  • if you are Mac user, curious about linux, you can install it on a VM without having to partition your disks
  • you can try out platform specific applications without having to switch your host OS.

Conclusion

Virtual machines are ubiquitous albeit abstracted. When you create an instance on AWS, you are creating a virtual machine on one of Amazon's big machines and you are not alone. Virtual machines give you the illusion that you have a dedicated machine. This VM technology has also paved the way for containers, another virtualization approach that's become essential in modern software deployment.

Top comments (1)

Collapse
 
peter_bernasko_3510f678c4 profile image
Peter Bernasko

Nice piece👍🏿