Many people that use VirtualBox, at some point come across a problem they have not encountered before.
In this article, I want to cover as many issues that may arise and how to fix them. This may be hum drum to some, but I’m sure there may be some tidbits in here that can be useful. The first part of the article is more basic than the second part.
NOTE: There are two things to keep in mind. One, the Host System is the main computer on which VirtualBox is being run. Two, the virtual system, or machine, is the Operating System being run inside VirtualBox on the Host System.
First off, everyone needs VirtualBox. The best thing is to get the latest version and keep everything up-to-date. This includes the Guest Additions as well. The version of Guest Additions must match the version of VirtualBox for them to work together.
NOTE: Be sure to upgrade your system to the latest packages by using ‘sudo apt update && sudo apt upgrade -y’.
To download the most recent version, go to ‘https://www.virtualbox.org/wiki/Downloads’. Here, you can find a link to various pages that are platform dependent. The various platforms are: Linux, Windows, OS X, Solaris and Solaris 11 IPS.
A little further down the page is the section for the ‘Guest Additions’, which is listed as the ‘Extension Pack’. The version number should be the same as the platform downloads. Make sure you get both files for a proper install.
Once the system completes the download, install the ‘VirtualBox’ file first. The second file should contain ‘Extension_Pack’ in the filename.
Even when a new update comes out, the install and upgrade is the same process.
Once the system completes the installation, you should be able to double-click on the ‘Extension_Pack’ file to open it. You may need to right-click on it and select to open it with ‘Oracle VirtualBox’.
If you have done this before, the system should ask you to ‘Upgrade’ the ‘Extension_Pack’.
Once you see the License screen, scroll to the bottom and you should now have an ‘I Agree’ button to click. Enter your password to allow Root Privileges. The installation should finish.
If you have existing Machines, you will need to re-install the ‘Extension_Pack’ in them when you use them to upgrade the Extensions to the matching version of the program. We’ll cover this momentarily.
Adding a Machine
A ‘Machine’ is a virtual Operating System that runs under VirtualBox in its sandbox.
NOTE: A sandbox is a virtual environment to allow for testing that will not affect the Host system or the network.
In this example, I will use the ISO file downloaded from ‘https://ubuntu.com/#download’. The file is the Ubuntu Desktop 22.04. The file is named ‘ubuntu-22.04-desktop-amd64.iso’. I have the file saved on my local hard disk.
In VirtualBox, select ‘New’ that is located at the top of the window in the icon section. It should be the first one. A new window should appear asking for a Name, Machine Folder, Type and Version.
The ‘Name’ is the Title that you give the new machine. This is also the name we use to reference the machine. The ‘Machine Folder’ is the location of the files used to create the machine. The location will contain the main hard disk image file. The ‘Type’ is the Operating System. ‘Version’ is the version of the OS that we are installing.
For this instance, I will use the following:
Name: Ubuntu Desktop 22.04
Machine Folder: ‘/home/jarret/VirtualBox VMs’
Version: Ubuntu (64-bit)
After clicking ‘Next’, you should be asked to set the amount of RAM to use for the Machine. VirtualBox should default to a ‘recommended’ value for the specified OS. In this case, it is 1024 MB. My system will allow me to increase the value to 2048. Click ‘Next’.
The program should be inquiring to whether you want a virtual hard disk for the machine. We will add one. The default option is to create a new image, so just click on ‘Create’. Now you are asked to specify an image type. Unless you plan on using the image with another program, just leave it as the default, VirtualBox Disk Image (VDI). Click ‘Next’.
Next, we can specify whether the disk image is a fixed size or dynamically enlarged. A fixed disk size will create a file image of the size you specify, say 20 GB. The image will occupy 20 GB no matter how much information is written to the image until it is filled. A dynamic disk starts out small and increases its size as you add files to the image. The dynamic disk will use less space, but the fixed disk is faster since its size doesn’t need to be modified as files are added. Click ‘Next’ after you make a choice.
NOTE: VirtualBox has made changes to the software and it does not allow for a fixed disk to be resized. There is a way around this, but it is an extra step.
The next window will allow you to specify the location of the image and its name. This information was specified on the first screen, but you can modify it here. You can also set a disk size. I will set it to 20 GB just in case I want to add a lot of files later. Click ‘Create’ once you have set your choices. The system should now create your disk image for the machine.
You should now be back at the main window for VirtualBox. If you were to ‘Start’ it, nothing would happen because we have not set up a boot disk to install the OS.
Before we do that, we need to set up the ‘NAT Network’. This is necessary if you have a new install or have never set it up.
Click on ‘File’ then on ‘Host Network Manager’. When the new window opens, click on the ‘Create’ icon. The defaults should be fine unless you want to change the ‘Virtual Network’ that your machines will be using. The ‘Virtual Network’ is used by the machines, especially if you are running multiple machines at once. Another network can also be created by clicking ‘File’ and the clicking ‘Preferences’. In the left pane, choose ‘Network’. From the right pane, click on the icon of the Network Interface Card (NIC). It is the only active icon if you have not created a NAT Network. Finally, click on the ‘OK’ button. The Virtual Networks have been configured for use by machines that you make.
Make sure you select your machine in the left pane and then click on ‘Settings’ at the top of the screen. We can now make more changes to the machine because it is not ready to be run.
You should have a new window and be in the ‘General’ section. In the right pane, you should be on the ‘Basic’ tab. Everything here we already set, so it should be fine. Click on the ‘Advanced’ tab. You should see a folder that specifies the ‘Snapshot Folder’ which should be fine unless you want to store them somewhere else. We’ll go into ‘Snapshots’ in a bit.
NOTE: Any of the values can be changed later after you shut down the Machine and then ‘Start’ the machine again with the new settings.
For the two options of ‘Shared Clipboard’ and ‘Drag’n Drop’ set these to ‘Bidirectional’. This allows us to copy and paste from the Machine to and from the Host system. We can also drag-and-drop file to and from the Machine to the Host machine.
Under ‘System’ in the left pane, there should be three tabs in the right pane. For the ‘Motherboard’ tab, we can change the memory value we set before. The ‘Boot Order’ is shown and you can uncheck ‘Floppy’. The ‘Optical Drive’ should be the highest option checked. All the other settings can be unchanged.
You can click on the ‘Processor’ tab and change the number of cores to use for the Machine.
Click on ‘Display’ in the left pane. Increase ‘Video Memory’ to the maximum. If you have, or want to emulate, multiple monitors, you can increase the ‘Monitor Count’. The ‘Graphics Controller’ is set to ‘VMSVGA’ by default and works for most OS. You may as well check the option for ‘Enable 3D Acceleration’.
Move to the ‘Storage’ section in the left pane. ‘Storage Devices’ should show two drives. The first is an Optical Drive and the second is the virtual drive we set up to install our OS on. The Optical Drive is listed as ‘Empty’. Click on ‘Empty’ and in the right pane there is a small CD. Click on it and select ‘Choose a Disk File…’. Find and select the Ubuntu ISO file we downloaded beforehand.
Now, let’s jump down to the ‘Network’ option in the left pane. You’ll need to change the ‘Attached To’ from ‘NAT’ to ‘NAT Network’ (that we set up previously). This should be the only adapter we need.
Go to the ‘USB’ option in the left pane. In the right-pane, select the USB type you wish to use: USB 2.0 or USB 3.0. Be aware of what USB version your Host System supports.
Click on ‘OK’ and then click on the ‘Start’ icon at the top of the screen. You should now go through the Ubuntu installation, which is similar to other Ubuntu versions for the installation process.
Once everything is installed, go ahead and run the command inside the machine: ‘sudo apt update && sudo apt upgrade -y’ to get everything up to date.
The ‘Extension Pack’ for the machines is called ‘Guest Additions’. We need to install the ‘Guest Additions’ on each machine that you want to perform the following:
- Support for USB devices
- Webcam pass-through
- VirtualBox Remote Desktop Protocol
- Disk Image Encryption
- Intel PXE Boot
Mainly, we are interested in the USB support, but you may have a need for one or more of the other options.
For Linux systems, you need to install a few packages that are required for the ‘Extension Pack’.
In a terminal, enter the following command:
sudo apt install dpkg gcc perl make -y
After the required packages are installed, click on ‘Devices’ on the menu bar for the machine. At the bottom of the drop-down list is the option ‘Insert Guest Additions CD image…’
The image is mounted on the OS in the machine and, in most cases, it will auto-start the install. Simply click on the option to run the install program.
If the image does not auto-start, then you need to do it manually. Open the CD and for Linux, there should be a script called ‘VboxLinuxAdditions.run’. Open a terminal window next to the window containing the files for the CD image. Drag and drop the ‘VboxLinuxAdditions.run’ to the terminal. The line in the terminal should now have the path and filename to the ‘run’ file. Press the HOME key on the keyboard to move the cursor to the beginning of the line. Type in the word ‘sudo’, add a space and press enter. The program needs ROOT privileges to run properly. Enter your password when prompted.
The Guest Additions should be installed, but changes were made to the kernel for VirtualBox. For the changes to take effect, you need to restart the machine. Before you do, you can right-click on the CD and select the option to ‘Eject’ the disk.
When the machine boots up, you are ready to access USB devices.
Because the article is quite long, I will split it into two articles. The second part of the article has more detailed information for people who already use VirtualBox.
For those who may be new to VirtualBox, I hope this gives you a basic understanding of how it works. At least a very basic part of it.