All you need to know about virtual machines (VM’s)
Introduction
You use macOS, but you need to run project on Windows, or you need more than two, three or even more operating systems on your computer, or you want to play retro games or use program that is not available on newer operating systems? You want to test software which may harm your computer, you need a copy of the existing operating system? These are reasons why you might want to use a VM.
But what exactly is a virtual machine? From definition, virtualization is the process of simulating the existence of logical resources by software that uses physical resources determined during configuration. For example, a virtual machine uses virtualization to emulate the operation of a machine with a given operating system, thus allowing you to study the behavior of this machine and its software without affecting the real operating system on which we are working. They allow system and network administrators to have a dedicated machine for every service they need to run. Not only does this reduce the number of physical servers required, but it also saves time when trying to troubleshoot issues.
Hypervisor
A hypervisor, also known as a virtual machine monitor or VMM, is software that manages the whole process of virtualization. A hypervisor allows one host computer to support multiple guest VMs by virtually sharing its resources, such as memory and processing.
There are two main hypervisor types, known as “Type 1” and “Type 2”. The difference between them is that “Type 1” acts like an actual operating system and runs directly on hardware, and “Type 2” is more like other computer programs and runs on the software layer.
Type 1
It is also called the bared-metal hypervisor, because as I mentioned before it is a layer of software installed directly on top of a physical hardware.
Advantages
- Efficiency – Type 1 is highly efficient because of its direct access to hardware.
- Security – The direct connection to hardware decreases attack surface to minimum for a potential hacker.
Disadvantages
- Management – It often needs a separate management machine to administer the various VMs and control the host hardware.
Examples of Type 1 hypervisors are: VMware for windows and KVM for Linux
Type 2
It is also called a hosted hypervisor and runs inside the physical host machine’s operating system. They often contain additional toolkits that users can install in the guest OS. These tools provide enhanced connections between the guest and the host operating system, often allowing the user to cut and paste between them or access host operating system files and folders from within the guest virtual machine.
Advantages
- Management – There is no need to install separate software on another machine to create and maintain your virtual environment. You can switch fast between different OSes.
Disadvantages
- Efficiency – The host OS creates additional pressure on physical hardware, which may result in VMs having latency issues.
Examples of Type 2 hypervisors are: Oracle VM VirtualBox and Windows Virtual PC
So the main difference is that Type 2 needs to share the hardware with the host OS while Type 1 has the hardware for itself. Choosing between two types of hypervisor depends on individual needs. For smaller deployments and personal usage, Type 2 might be recommended. For big deployment which need to use 100% of your hardware, don’t hesitate to choose Type 1 hypervisor.
Creating a Virtual Machine
Okay, so let’s start with choosing an operating system. I’ll show you how to create a Virtual Machine with Ubuntu on my host computer with Windows 11. Link to Ubuntu. In the second step I will download a hypervisor type 2 which is Oracle VM VirtualBox link. After you install VirtualBox, run it and choose “New” to start. Choose name for VM folder where it should be located, and ISO image of the downloaded OS.
The next step is username and password, and some additional options, which you can leave as default. Then choose your memory size and virtual CPU count. It depends on how much you need, and you can afford, but remember if you assign maximum values you might have a problem with the efficiency of host OS. Then you need to choose how much of space from your disc VM should have. I used 50 GB. Just think how much you need besides the space for your operating system. The last step is a summary of everything you inserted before, and after you click “finish” your VM will be ready.
Now you’ve got a fully operated Ubuntu which works totally normally, you can do whatever you need like on a normal OS. But now let’s speak about useful options of the VirtualBox.
VirtualBox useful operations
I’d like to tell you now about useful options you can use while working with VirtualBox, which may come in handy later.
Cloning
You can use it when you need to have more than one machine with similar configuration and the same pack of programs. A Virtual machine clone is a copy of VM. The existing machine is called a parent and the new one is a clone. After the cloning operation you obtain exactly the same VM with the properties and setting of the existing one. Installing a new virtual machine from scratch, and installing each time the same needed programs, can take a great deal of time. Using cloning, you perform installation and configuration only once, and then use cloning as a basis for next VM’s. VM cloning is most useful for deploying multiple identical virtual machines to a group of users. For example, a sysadmin can clone a virtual machine for each employee in a particular department, since the employees use the same applications, their setups should be the same.
There are two types of cloning, you can make a full clone or a linked clone.
Full clone is a completely separate copy of VM that does not share any system resource with the parent while both are running. The linked clone, on the other hand, continues to share a virtual disc with the parent while they both running. Since both parent and clone run independently, a full clone has a faster performance than a linked one. A full clone takes more time to create, while linked clones are faster to create and saving a disk space by allowing multiple virtual machines to run off a single software installation.
Snapshot
VirtualBox allows users to create a snapshot of a virtual machine. The snapshot preserves the current state of a VM. You’re saving configuration of the VM, which you can revert to later. Snapshots provide a change log for the virtual disk and are used to restore a VM to a particular point in time when a failure or system error occurs. But remember that snapshots alone do not provide backup!
Settings
VirtualBox provides some setting that might be both useful and harmful. For example, you can share the clipboard between the host OS and the virtual machine, you can allow copying from the host to VM, from VM to host or both ways.
In default, you have got a virtual machine connected to the network using NAT (Network Address Translation which in simple words work like your home router), which means that address of your VM is different from the address of the host, but you can change it for example to bridged adapter, and your VM will have direct access to your network as host. You need to think what you want to choose, in reference to security.
Shared folders, as a clipboard, you can make a folder as a place of exchange of files in both directions. But as previously I said, it might be a better idea to keep a VM more isolated because of the security of your host machine.
Summary
It was just the basics and a fragment of knowledge about virtualization, because different virtualization programs have different characteristics, there will be also differences between deploying a virtual machine in a cloud or on another remote computer. But it’s definitely a good basis to start with virtualization, because it’s something that is used in IT all the time, it’s an essential skill in many areas of IT.