Sounds good, but what exactly is a Virtual Machine (VM) and how does it work?
The official definition of a virtual machine is ‘an efficient, isolated duplicate of a real computer machine’. This basically means that a virtual machine is an emulated computer system that can operate in exactly the same way as a physical machine, but within the confines of a dedicated virtual machine operator, or Hypervisor.
The Hypervisor itself, is an app that will allow you to install a separate operating system, creating a virtual computer system within itself, complete with access to the Internet, your home network and so on.
The Hypervisor will take resources from the host system – your physical computer, to create the virtual computer. This means that part of your physical computer’s: memory, CPU, hard drive space and other shared resources, will be set aside for use in the virtual machine and therefore won’t be available to the physical computer until the hypervisor has been closed down.
This resource overhead can be crippling for the physical machine if you don’t already have enough memory, or hard drive space available, or your computer has a particularly slow processor. While it’s entirely possible to run virtual machines on as little as 2GB of memory, it’s not advisable. Ideally, you will need a minimum of 8GB of memory (you can get away with 4GB, but again, your physical computer will begin to suffer with the loss of memory to the virtual machine), at least 25 to 50GB of free space on your hard drive and a quadcore processor (again, you can have a dual-core CPU, but that can cause a bottleneck on your physical computer).
The limit to how many different virtual machines you host on your physical computer is restricted, therefore, by the amount of physical system resources you can allocate to each, while still leaving enough for your physical computer to operate on.
From within a hypervisor you’re able to run a number of different operating systems. The type of OS depends greatly on the hypervisor you’re running, as some are better at emulating a particular system over others. For example, VirtualBox, a free and easy to use hypervisor from Oracle, is great at running Windows and Linux virtual machines, but isn’t so good at Android or macOS. QEMU is good for emulating ARM processors, therefore ideal for Android and such, but it can be difficult to master.
There are plenty of hypervisors available to try for free, with an equal amount commercially available that are significantly more powerful and offer better features. However, for most users, both beginner and professional, VirtualBox does a good enough job.
Within a hypervisor, you’re able to set up and install any of the newer distributions of Linux, or if you feel the need, you’re also able to install some of the more antiquated versions. You can install early versions of Windows, even as far back as Windows 3 complete with DOS 6.22 – although you may find some functionality of the VM lost due to the older drivers (such as access to the network).
With this in mind then, you’re able to have an installation of Linux Mint, or the latest version of Ubuntu, running in an app on your Windows 10 PC. This is the beauty of using a virtual machine. Conversely, if your physical computer has Linux as its installed operating system, then with a hypervisor you’re able to create a Windows 10 virtual machine – although you will need to have a licence code available to register and activate Windows 10.
Using virtual machines removes the need to dual-boot. Dual-booting is having two, or more, physical operating systems installed on the same, or multiple, hard drives on a single computer. As the computer powers up, you’re given the option to choose which OS you want to boot into. While this sounds like a more ideal scenario it isn’t always as straight forward as it sounds, as all the operating systems that are booted into will have full access to the computer’s entire system resources.
The problems with dual-booting come when one of the operating systems is updated. Most updates cover security patching, or bug fixing, however, some updates can alter the core – the kernel, of the OS. When these changes are applied, the update may alter the way in which the OS starts up, meaning the initial boot choice you made could be overwritten, leaving you without the ability to access the other operating systems installed on the computer. To rectify this, you’ll need to access the Master Boot Record and alter the configuration to re-allow booting into the other systems.
There’s also the danger of possibly overwriting the first installed OS, or overwriting data and more often than not, most operating systems don’t play well when running side-by-side. Indeed, while good, dualbooting has more than its fair share of problems. In contrast, using a virtual machine environment, while still problematic at times, takes out some of the more nasty and disastrous aspects of using multiple operating systems on a single computer.
Advantages For Coders
For the coder, having a virtual machine setup offers many advantages, the most popular being cross-platform code. Meaning if you write code within Windows 10, then with an installation of a Linux distro in a hypervisor, you’re able to quickly and effortlessly power up the virtual machine and test your code in a completely different operating system. From this, you’re able to iron out any bugs, tweak the code so it works better on a different platform and expand the reach of your code to non-Windows users.
The advantage of being able to configure a development environment, in specific ways for specific projects, is quite invaluable. Using a virtual machine setup greatly reduces the uncertainties that are inherent to having multiple versions of programming languages, libraries, IDEs and modules installed, to support the many different projects you may become involved in as a coder. Elements of code that ‘talk’ directly to specifics of an operating system can easily be overcome, without the need to clutter up your main, host system with cross-platform libraries, which in turn may have an effect on other libraries within the IDE.
Another element to consider is stability. If you’re writing code that could potentially cause some instability to the core OS during its development phase, then executing and testing that code on a virtual machine makes more sense than testing it on your main computer; where having to repeatedly reboot, or reset something due to the code’s instabilities, can become inefficient and just plain annoying.
The virtual machine environment can be viewed as a sandbox, where you’re able to test unsecure, or unstable code without it causing harm, or doing damage, to your main, working computer. Viruses and malware can be isolated within the VM without infecting the main computer, you’re able to set up anonymity Internet use within the VM and you’re able to install third-party software without it slowing down your main computer.
While you’re at the early stages of coding, using a virtual machine may seem a little excessive. However, it’s worth looking into because coding in Linux can often be easier than coding in Windows, as some versions of Linux have IDEs pre-installed. Either way, virtualisation of an operating system is how many of the professional and successful coders and developers work, so getting used to it early on in your skill set is advantageous.
To start, look at installing VirtualBox. Then consider taking a look at our Linux titles, to learn how to install Linux in a virtual environment and how best to utilise the operating system.