We all have our favourite Operating Systems (OS). May it be Windows, Linux, MacOS or something else entirely. But from time to time there will be some instances where a different OS is convenient. An easy way to cope with such situations is using a Virtual Machine (VM). The VM has the same functionalities as the Operating System, but it is used like an application on your PC.
In this article I will give you a step-by-step guide on how to install and setup your VM for Ubuntu 20.04 from Windows (but you can apply these steps similarly for every OS you want).
Download and Install Requirements
Before you start installing the OS of your choice make sure you start downloading the .iso of it first. It is usually a couple of GB big and takes some time to download. Since I will install Ubuntu 20.04 I downloaded it from the official Ubuntu website. Next you want to download and install VirtualBox from their official website. Just search for your Operating System, download the installer and follow the instructions to install VirtualBox. After the installation is complete you can open VirtualBox.
Create the Virtual Machine
We are now ready to create our first VM. Therefore you click New and enter the name of your VM. In the example below I will create a Linux VM with the name TheBeginnersCodingBlog. The version I will keep as the default Oracle (64-bit).
Next up is the memory size you want to give your VM. This is the amount of RAM that you are willing to give to your VM. Since I have a machine with 16GB of RAM and I am not going to use my machine a lot when I am working on the VM, I'm setting it to 8GB (giving your VM half of your available RAM is generally fine).
In the last step you need to create a hard disk for your VM. Just click create and in the next window click on VDI (VirtualBox Disk Image). Next you have to choose if you want to dynamically allocate the hard disk or use a fixed size. I recommend using a fixed sized, although it takes longer to create, it will be faster when you use the VM. To finalize the creation of the hard disk you need to set the size of your hard disk. Now this heavily depends on the tasks you want your VM to do. If you need a lot of memory (e.g. for video editing) you should use a bigger size. For coding, smaller sizes are usually sufficient. Just make sure to at least use 12GB, otherwise you might run into performance issues. I will set the size to 80GB (better have some more space than to run out of it later).
Start the Virtual Machine
After following all the above steps, you should see your created VM in the VirtualBox Manager. Start the VM by double clicking it. You will be prompted with a message to insert an installation medium. That is the .iso that you downloaded at the start. Either use the folder icon provided or go to Devices -> Optical Drives -> Choose/Create Image an choose the .iso you downloaded. Afterwards the installation begins, so follow the instructions on screen. After the installation is finished you usually need to restart. When you start the VM again it will prompt you with a message to remove the installation device, which you can safely ignore. Your VM is now ready to use.
Tips and Tricks
The tips provided in the below list are all in regard to an Ubuntu 20.04 VM, although some of the points are generally applicable.
- Enable the bi-directional clipboard (this will allow copy/paste from your host to your VM and the other way round)
- In the VirtualBox Manager go to Settings -> General -> Advanced and set Bidirectional for both of the available options
- Enable 3D Acceleration (only works if the VM is shutdown)
- In the VirtualBox Manager go to Settings -> Display and check the box for Enable 3D Acceleration
- Set the Graphics controller to VMSVGA
- Install Guest Additions for your VM (that will greatly improve your experience with your VM)
- Open a terminal with Ctrl + Shift + T
- Run sudo apt-get update
- Run sudo apt install virtualbox-guest-dkms virtualbox-guest-x11 virtualbox-guest-utils
- In your VirtualBox Manager go to Devices -> Optical Drives -> VBoxGuestAddition.iso
- You will be prompted to run it, afterwards the Guest Additions will be installed
If you have problems with the resolution, make sure to install the Guest Additions, it will most likely solve the issue.
If you are struggling with setting up your Virtual Machine then drop a comment and I make sure to help you through it.