Saturday, March 04, 2023

Virtualization and Virtual Machines

Why virtualization is necessary

Sabbir Ahmed
Virtualization and Virtual MachinesBanner

What is Virtual Machine?

We have a windows os based laptop. Which operates on windows os. So far so good. What if in some cases, we need to run linux. Then what? Then we need a whole different laptop based on Linux OS.

what-is-virtual-machine.png

So, instead of buying new laptop again, we can achieve it differently. Here, virtualisation concept comes into play. In virtualisation technique we don’t need separate hardware. We can share those hardware to achieve different OS in a single host machine.

  • We can run windows on windows
  • Linux on windows
  • Linux on Linux
  • Windows on Linux

We can achieve that by using something called Hypervisor.

what-is-hypervisor.png

What is Hypervisor?

Hypervisor allows multiple OS to operate on top of the single physical host machine OS. One of the most popular hypervisor technology is VirtualBox. Owned by oracle, open-source and works on all OS.

hypervisor.png

So, hardware resources are shared here. But they are completely isolated from each other. If something breaks inside VM, it doesn’t affect the host machine. Again, what is the use cases/benefits of VM in the first place?

  • Don’t need to buy a new computer for different OS.
  • Don’t need to endanger our main OS.
  • Test application in different OS.

There are 2 types of hypervisor

  • Type 2
  • Type 1

Type 2 works with a host OS. But in Type 1, hypervisor software directly talks with hardware. That’s why it’s called Bare Metal Hypervisor.

VMWare ESXi and Microsoft Hyper-V is a good example of that.

type-1-vs-type-2-hypervisor.png

And Cloud provider like AWS uses Type 1 hypervisor system. So, whenever we create any EC2 instances, we actually create a virtual machine on a physical hardware.

type-1-hypervisor.png

Use cases of Type-1 hypervisor

  • Efficient use of hardware resources.
  • Users can choose any resource combinations.

Why companies adopting virtualisation?

  • Abstraction of the Operating System from the hardware.

Before Virtualisations, company need to manage their own servers. They installed OS, installing applications like Jenkins, Postgres. And when the OS directly installed on hardware without the hypervisor layer, then the OS is tightly coupled with hardware. So, if the hardware component of that computer fails, then all the other applications will be useless. So, relying on one physical box means single point of failure and therefore high risk of loosing of data and services.

companies-adopting-virtualization.png

Since, with virtualisation have files, we can use

  • OS as a portable file → Virtual machine images (In that image, including OS there will be all other applications like Jenkins, Chrome etc.)
  • Since it is file, and on that file we configured Jenkins previously with all other apps, we can copy that file and put into a new server. So, we can keep backup file by coping and keeping that file in our private directory. This coping system called taking snapshot. So, now we have OS Snapshots. So, if one of our VM hacked or destroyed somehow, then what we’ll do? We will delete/destroy that VM and create a whole different VM with hypervisor and put that image/snapshot on it. That’s it. We don’t need to re-configure everything. As, we took OS Snapshot previously.

companies-adopting-virtualization-2.png

For any reason, if one of the VM is died or compromised, then we can easily take other snapshot and spin up that snapshot on a different computer with hypervisor setup. So, these are the main benefits of using hypervisor layer on physical server.

abstraction-of-os.png