HOW TO: Use VirtualBox to Set Up Virtual Machines

 

Virtual Machines ( VM ) are great. They allow you to emulate additional operating systems, each in their own individual window, on a computer. For example, your can run a Linux instance in a VM on your Mac or Windows PC.

Many people have, at least, heard of VMWare and/or Parallels. But today we’re going to focus on a free, open-source and cross platform alternative. VirtualBox.

ALSO READ:

 

DOWNLOAD and INSTALL VIRTUALBOX

macOS and Windows users can download and install VirtualBox from the downloads page of the official website. Once VirtualBox is downloaded, proceede with the installation as normal.

Linux users should be able to find VirtualBox in the default repos however, depending on the distro you’re using, the package can be an outdated one. Unless you’re an Arch ( or derivates ) user, please refer to this page on how to install VirtualBox on your system.

 

INSTALLING VIRTUALBOX EXTENSION PACK

The VirtualBox Extension Pack adds support for USB 2.0 and USB 3.0 devices, VirtualBox RDP, disk encryption, NVMe and PXE boot for Intel cards. It can be downloaded from the same downloads page ( linked above ).

Once VirtualBox is installed on your machine, download the extension pack. IF you can’t open the extension pack directly with virtualbox to install it, then you should open VirtualBox go to Preferences > Extensions and to add it.

 

Also, while in Preferencesgo to General and modify ( if you want ) the default folder location of where your VMs will be installed.

 

 

CREATING a VIRTUAL MACHINE ( VM )

When you first open VirtualBox you will get a screen similar to the one seen in the screenshot below. Obviously, you won’t have any virtual machines created. So let’s create one.

 

1. Download the operating system that you want to install in a VM ( virtual machine ). I’ll use Pop!_OS

2. Click on New to start creating your VM.

 

3. Name your VM. Usually VirtualBox will autodetect the type and version of your OS. IF you’re using a major distribution. For example Windows, or Debian, Ubuntu, Fedora or Arch.

Since Pop!_OS is a derivate of Ubuntu, VirtualBox can’t autodetect it, and you’ll need to manually select the type of OS ( Linux in this case ) and version ( Ubuntu 64-bit in this case ).

 

4. On the next screen set the amount of RAM you want to allocate to your VM. Usually 4GB ( 4096 MB ) should be enough. But if you can spare it allocate 8GB (8192 MB ).

 

5. Now it’s time to create the virtual disk where VirtualBox will store the data. VirtualBox can create two types of virtual disks. Dynamic and fixed.

The dynamically allocated virtual disk will only take space on your actual drive as it’s getting filled. For example, let’s say you create a 100GB virtual drive. But the VM only takes 10GB, the dynamically allocated disk will only take 10GB of your actual drive space. And it will take more and more space as the virtual drive gets filled.

The fixedvirtual disk is self explanatory. You create a 100GB fixed virtual disk, it will take 100GB of your actual drive space.

 

CONFIGURING the VIRTUAL MACHINE ( VM )

1. Once you’ve created your VM, you’ll have the virtual drive with a basic configuration which you can see a summary of on the main screen.

 

2. To configure your VM you have two options. You can either click on each section to quickly modify the parameters …

 

… or select your VM and click on Settings

 

3. Now you can configure your VM. I won’t go through every single options. I’ll just show you the most important ones that will get you up and running.

NOTE: this configuration is for only ONE VM. If you want to run more VMs at the same time, you should allocate RAM and CPUs accordingly.

General – Enable disk encryption if needed.

 

System > Motherboard – Enable EFI if needed

 

System > Processor – Add more CPUs.

 

Display > Screen – Max out Video Memory, choose your graphics controller and optionally enable 3D acceleration.

 

Storage – Select the empty optical drive and add your downloaded .iso

 

 

INSTALLING YOUR VIRTUAL MACHINE ( VM )

Now that you’ve created and configured your VM, it’s time to start it. To do that you can either double click on your VM or select it and click on Start

 

Your VM will start and you can install the OS of your choice.

 

INSTALLING GUEST ADDITIONS

Once the OS has been installed on your VM, you will probably ( at least ) notice that the screen resolution is not the correct one and you might not even be able to scale the window.

To fix this issue and add more functionality to your VM, you will need to install Guest Additions.

VirtualBox Guest Adttitions are a set of device drivers and system applications that optimize the guest operating system for better performance and usability.

If you installed Windows, installing Guest Additions is easy. While running your Windows VM, go to the manu of your virtual machine, choose Devices and then choose Insert Guest Additions CD image....

VirtualBox will mount the Guest Additions ISO file inside your virtual machine. A Windows guest should then automatically start the Guest Additions installer, which installs the Guest Additions on your Windows guest.

The VirtualBox Guest Additions for Linux are provided on the same virtual CD-ROM file as the Guest Additions for Windows. They also come with an installation program that guides you through the setup process. However, due to the significant differences between Linux distributions, installation may be slightly more complex when compared to Windows.

So let’s fix this for Pop!_OS/Ubuntu. Open up the terminal and run sudo apt install virtualbox-guest-dkms virtualbox-guest-x11 -y.

Reboot your VM and you will notice that Auto-resize Guest Display ( enable/disable from View menu found in the menu bar ) , drag-and-drop between host and VM and shared clipboard between host and VM ( enable/disable from Devices menu in the menu bar ) all work.

Also, you can now mount the Guest Additions image and install it. Open up the terminal and cd into path cd /media/USER/VBox_GAs_6.1.16. Now install VirtualBox Guest Additions with sudo ./VBoxLinuxAdditions.run. When prompted type yes.

For more info on how to install Guest Additions on Linux, check out this page.