A Beginner’s Guide To Virtualisation

I’ve spoken to a few people working in tech recently who aren’t entirely sure how this whole “virtualisation” thing works and don’t know that much about it, so I’ve decided to write an introduction to it that hopefully contains enough info to give someone new to the field a good grounding in the basics.

What is Virtualisation?

Virtualisation allows you to simulate hardware functionality to create virtual machines. Your virtual machines can run different workloads and operating systems, but all ultimately run on a single physical server.

This is perhaps best explained with a very simple scenario. Imagine a case where you have three different applications that you need to host, but none of them are very demanding in terms of compute resources – let’s say on average they use 20% of the CPU available to them. If you deployed each application to an individual server, then those servers would spend most of their time sat around doing nothing. Their hardware wouldn’t be fully utilised, but you’ll have bought multiple servers and you’ll be paying the running costs for all of them.

A diagram showing three physical servers each running their own operating systems and applications
Three physical servers each running their own operating systems and applications

Virtualisation allows you run all of those workloads as virtual machines, known as guests, on a single physical machine, known as the host. In this case, our hardware is utilised more efficiently, our costs are reduced. The hypervisor allows us to simulate virtual machines, so as far as the applications and operating systems are concerned, each one is running on their own, dedicated hardware. The hypervisor will manage resource sharing between the applications – this may be dynamically as the applications need resources, or it could be statically defined up front, like giving each VM 2 cores and 2GB of RAM for example.

A diagram showing three virtual machines each running their own operating systems and applications, but using a hypervisor to all run on one physical server.
Three virtual machines each running their own operating systems and applications, but using a hypervisor to all run on one physical server.

Hypervisors

Hypervisors are the actual software that you’ll need to use in order to create and run virtual machines.

There are two different types of hypervisors which you’ll encounter – type 1 hypervisors and type 2 hypervisors. Both of them work in the same way in that they let you run virtual machines, but the way you deploy and run them is different. Some popular hypervisor vendors offer variants of their software for each type.

Type 1 Hypervisors (Bare Metal)

A type 1 hypervisor is usually known as a “bare metal” hypervisor because it installs directly onto the hardware that you’re using – so there isn’t an operating system like Windows running between your hardware and your virtual machines. If you have a server that you only want to run VMs on, this is the type of hypervisor you would pick because it allows you to allocate all of your hardware to actually running your VMs instead of supporting additional software running in between. There are a few main bare metal hypervisors that you’ll come across (others are available):

  • Xen: an open source hypervisor which is what AWS use to power their EC2 service.
  • Hyper-V: Microsoft’s bare metal hypervisor.
  • ESXi: VMWare’s bare metal hypervisor which is the underlying technology for their VSphere suite of virtualisation tools. This could also be referred to as “VSphere” or just “VMware”.

Type 2 Hypervisors (Hosted)

A type 2 hypervisor runs inside your OS like a normal program, and is useful if you need to switch between different operating systems for testing a program or using specific tools. Type 2 hypervisors are simple to get up and running and are an ideal entry point for starting to play around with virtualisation. Again, there are a few main contenders that you’ll come across:

  • VirtualBox: an open source hypervisor developed by Oracle, VirtualBox is cross-platform and an easy way to get started with virtualisation.
  • Hyper-V: Microsoft offer a type 2 variant of Hyper-V which can be enabled on the Professional editions of Windows or Windows Server. This lets you use the same underlying virtualisation technology as the bare metal edition but from within your OS, so it’s a bit easier to get started with than the bare metal variant.
  • VMWare Workstation: VMWare also offer a type 2 variant of their virtualisation platform. There’s also a cut-down free version, VMWare Player, and VMWare Fusion if you use a Mac.

Real World Virtualisation

Virtualisation is now an essential part of running infrastructure at any scale, from the single server you keep in the corner up to public clouds operating at AWS scale. A virtual machine is usually stored on the host as a few files. Although this is hypervisor specific, in general you can expect:

  • A configuration file that defines the hardware the VM is configured with (like the number of cores and amount of RAM it has).
  • A file representing each hard drive the VM has. Anything stored on the disks in the VM is really stored in this file. You may also find in production environments that all of your files are stored directly on storage appliances attached to the network.
  • A file containing the state of the VM, like the contents of the RAM if you’ve paused the machine from executing.

Running workloads as virtual machines gives you a whole host of real-world benefits over using physical machines for everything:

  • Efficiency. you can make more effective use of the hardware that you have by consolidating workloads or applications onto fewer physical machines. This will reduce your costs for everything from hardware procurement to electricity.
  • Resiliency. you can quickly back up or move a VM to another host by copying a few files. VMWare even has a technology called VMotion which allows you to move a VM between physical hosts while it’s still running.
  • Scalability. Obviously, you won’t just have a single physical host powering all your VMs in a production environment. Hypervisors like VMWare and Hyper-V give you management tools that let you control a cluster of physical servers, and let you deploy a VM onto your pool of hardware without being overly concerned about which physical piece of hardware is running your workload.
  • Security and Testing. Virtualisation can be used to quickly spin up a lab environment that’s isolated from the rest of your network on one physical machine which you could use for risky activities like malware analysis or testing a new network architecture.

Getting Started Yourself

Hopefully this has given you an initial grounding in what virtualisation actually is, and how fundamental it is to running infrastructure today. Like most aspects of the whole tech field, the best way to understand virtualisation is to play around with it yourself and actually gain experience in creating and managing virtual machines.

Downloading VirtualBox and setting up a Linux VM is a totally free way to get started. Assuming you have a reasonably modern computer, you won’t have any issues creating a simple VM and running it side by side with your normal OS.

Once you’ve done that and got your head around how the basics work with VirtualBox, you could try installing a type 1 hypervisor onto an old computer. If you don’t have any spare hardware, you can pick up an entry level server capable of running some VMs for around £200. HP’s Microserver range is a good place to start if you’re new to it – which can lead you down a whole new rabbit hole as you set up a lab at home. VMWare’s ESXi (aka VSphere Hypervisor) is a good place to start with this, as they offer a free version which you can manage through a web browser. Once you’ve got this type of setup, you can start to delve into more advanced topics like virtual networking and failovers – there are plenty of resources available on the internet or the aforementioned /r/homelab to get started with that.