Before we talk about Virtualization and virtual machines, let's consider a scenario where you have a PC in your home.
We usually have an operating system installed in it, let it be Windows, Linux, or macOS. We have a processor running, some memory and some storage, and all other hardware components which run your computer.
Without Virtual Machines💻
Imagine you are using Windows on your PC and wanted to learn or work on Linux. Then you should buy another hardware setup and install any Linux distribution on it and then use it.
Know more about Linux Distributions here.
What if you no longer need it? What if you don't use much of the memory or storage you bought? What if the memory or storage you bought is not enough for your work? What if you did something and your system crashed?
In all these scenarios, the whole hardware you bought would go waste and maybe you can't use it for another purpose in the future.😢
How awesome could it be, if we can dynamically specify the specifications, or allocate the unused resources for another work?🤔
Virtualization
The process of utilizing the maximum of the hardware capacity by dividing the resources into multiple environments or users dynamically is called Virtualization. It allows us to create a machine virtually with dynamic configurations like RAM, storage, CPU, etc...
The major change it brought to computers is that it removed the interdependence between the hardware and the operating system. Virtualization made operating systems portable as files. We can download operating systems as we download files and power up a new virtual machine with a new OS within minutes.
How can we use Virtual Machines?
We can achieve virtualization with the help of software called Hypervisor. Hypervisor allows us to create virtual machines. We can create as many VMs as we want and we can remove them whenever we want.
The hypervisor creates virtual RAM, and virtual Storage by borrowing from the host hardware. We can install an OS in the hypervisor, the same way we install it on our hardware directly.
We'll talk more about Hypervisors later. Let's understand the properties of VMs.
Virtual Machines
- The interesting thing about VMs is, that they think they are independent machines running on the hardware directly.
- They’ll never know that they are virtual machines or there are other VMs running along with them.
- Even if something like a system breakdown happens in a VM, it won’t affect the hardware or the host OS. We can simply delete that VM and boot up a new one.
- This isolation helps us in securing the host hardware or the other VMs running along with it.
Hypervisors
In general, there are 2 types of Hypervisors,
- Type 1 Hypervisors
- Type 2 Hypervisors
Type 2
Let's talk about type 2 first and then we'll discuss type 1
These are the general-purpose hypervisors that are used in normal PCs. They are installed on top of a host OS
Host OS: Operating system which runs directly on physical hardware.
These are used only for learning or to test a software product on different OSs. We can't use them for heavy workloads.
The most widely used Type 2 Hypervisors are
- Oracle VirtualBox (open source)
- VMware workstation
- Microsoft virtual PC
Type 1
These are the hypervisors used in large serves or in cloud servers.
They don’t need any Host OS, they are directly installed on top of the hardware. So they are called Bare Metal Hypervisors.
These hypervisors can directly interact with hardware. They are very helpful because if one VM is crashed then it can be easily discarded and create a new one. No need to rely on the Host OS. We can work with each VM without disturbing the other.
Most widely used Type-1 Hypervisors are,
- VMware
- HyperV by Microsoft
To know more, watch this video.