Software I like: VirtualBox

1. Introduction

VirtualBox is a virtualizer for x86 and amd64/intel64 hardware, that is, it allows one to run a guest operating system under a host operating system. On this page the focus is on Debian GNU/Linux as the guest operating system.

If you have problems getting VirtualBox to work, an open-source alternative is QEMU, which I haven’t tried. Another alternative for Linux is KVM. Another alternative is VMWare Workstation Player, which is a commercial product that is free of charge for personal non-commercial use. It is available for MS Windows and for Linux; VMWare Fusion is available for the Mac but is not free of charge.

Windows Subsystem for Linux is another possibility for running Linux applications under MS Windows. It is available under Windows 10. It is intended mainly for developers, and apparently there are (or were) stability problems when using graphics.

VirtualBox is not included in Debian 9 (Stretch) but can be installed from stretch-backports or directly from virtualbox.org.

This page mostly assumes that the guest operating system is Linux.

2. Installing a guest operating system

If you’re running 64-bit MS Windows and want to install a 64-bit Linux but VirtualBox only offers 32-bit versions in the list of types of operating systems, it may be because your computer has virtualization disabled or because Windows has a conflicting kind of virtualization enabled. Things to check:
As of version 6.1.0 (2019 Dec 10) software virtualization has been dropped, so a CPU supporting hardware virtualization is required.
If a previously working virtual machine starts to refuse to start, it may be because its virtual disk has filled up. The disk can be made larger, or a new virtual machine can be created with a larger disk and the contents of the old disk can be extracted.

In the VirtualBox Manager, do Machine ► New. In the window that pops up, select the type of operating system to be used on the new machine (e.g., Linux) and the version (e.g., Debian 64-bit) and specify a name (e.g., Debian-11-64, or whatever you like). In the next windows:

When a new virtual machine is started the first time, you will be prompted for the location of a virtual or physical optical drive from which to boot or install the guest operating system. For example, browse to where you’ve downloaded and stored a CD .iso image file on your host computer.

Follow the usual installation procedure for the guest operating system. If you plan to use AudiLab software, follow this installation procedure. Then install the VirtualBox Guest Additions.

3. Guest Additions

Guest Additions are additions to the operating system that has been installed as a VirtualBox guest. The additions provide important features such as access to directories and files on the host from within the guest operating system; mouse pointer integration; shared clipboard and drag-and-drop between host and guest; automatic resizing of the guest desktop when its host window is resized; and ‘seamless’ mode (View ► Switch to Seamless Mode in the guest). Guest Additions may be necessary for proper functioning of the mouse and keyboard when the host operating system is macOS.

To make sure you have the required packages for adding the Guest Additions, open a terminal window in the virtual (guest) machine by doing
Applications ► System Tools ► MATE Terminal
Give the command
sudo apt install make gcc dkms build-essential perl linux-headers-amd64
Enter your password when requested, to enable sudo, then type Y and Enter when asked whether to continue or not.
(These packages may not be available to you if you have not specified a download mirror in your /etc/apt/sources.list file.)
The architecture specification amd64 in the package name linux-headers-amd64 may not be appropriate for you. The output of the command uname -r can be used in place of amd64 in the package name.

Once you’ve installed these packages, it may be necessary to restart the virtual machine before doing the next step.

A procedure (the best one?) for installing Guest Additions in a Linux guest: If a virtual CD called something like VBox_GAs_n.n.n doesn’t already appear on the desktop of the the Linux guest, then in the VirtualBox window of the running guest machine do Devices ► Optical Drives ► Remove disk from optical drive; if you see a message saying Unable to eject …, click on Force Unmount. To ensure that no disk is present in the virtual optical drive, you can shut down the virtual machine by doing Machine ► ACPI Shutdown in the VirtualBox menu, or System ► Shut Down… in the Linux menu. Then in the VirtualBox Manager window, under Storage ensure that it says [Optical Drive] Empty; if it doesn't, click on [Optical Drive] and use Remove disk from optical drive, then restart the guest machine. Then do Devices ► Insert Guest Additions CD image …. A virtual CD should appear in the Places menu (e.g., VBox_GAs_n.n.n) and possibly on the desktop. If that doesn't work, try Devices ► Optical Drives ► Choose/Create a disk image…. You should see VBoxGuestAdditions.iso as ‘Attached’; select it and click on Choose. If necessary, click on Force unmount If a window pops up saying You have just inserted a medium … Choose what application to launch., you can just select Do Nothing and click on OK. In a terminal window (e.g., Applications ► System Tools ► MATE Terminal) do
cd /media/cdrom
If that doesn’t work, you can determine the correct directory for the guest additions by double-clicking on the CD icon on your desktop. For example, you may need to do something like
cd /media/username/VBox_GAs_n.n.n
Once you’re in the correct directory, do
sudo sh ./VBoxLinuxAdditions.run
and wait while it works. Check the output carefully to determine whether the process was successful or not.

After successful completion of VBoxLinuxAdditions.run, restart the guest machine. One method is to give the command
sudo shutdown -r now.
Alternatively, do System ► Shut Down ► Shut Down then restart the guest machine.

4. Sharing files between guest and host

The Guest Additions must have been installed. Shared Folders List

To add a shared folder:

5. Sharing clipboards between guest and host

The Guest Additions must have been installed.

To enable the sharing of clipboards between guest and host, do Settings ► General ► Advanced. Under Shared Clipboard select Bidirectional or one of the other options. You can also enable Drag'n'Drop between guest and host here.

6. CD’s and DVD’s

CD’s and DVD’s are made available to the guest operating system using File ► Virtual Media Manager (Optical disks tab) in the Oracle VM VirtualBox Manager window and using Devices ► Optical Drives in the Oracle VM VirtualBox window of a running guest operating system. Real disks can be used in the host’s physical CD/DVD drive, and .iso files can be used as virtual disks.

7. Network

Under Windows 7, VirtualBox makes a network connection that appears, at least in my case, as an Unidentified network that is shown as having no network access but which works fine. In one case, after upgrading VirtualBox the network connection did not work. I fixed it by disconnecting and reconnecting the network using Devices ► Network ► Connect Network Adapter.

See this overview of networking in VirtualBox. There are more details in virtual-networking chapter of the VirtualBox manual.

8. Powering off the guest machine

The guest machine can be powered off using Machine ► Close. The three options are provided:

If things are going oddly with the virtual machine, it’s better to do a shutdown rather than saving its state. The Discard button in the VirtualBox Manager window can be used to discard a virtual machine’s saved state.

9. Resizing a virtual disk

It is possible to increase (but not decrease) the size of an existing virtual disk (e.g., refs 1, 2, 3). The following instructions are for VirtualBox 6.1. They make a lot of assumptions and ignore a lot of alternatives.

  1. Shut down the virtual machine.
  2. In the host machine, download and save the Live CD for GParted, the GNOME partition editor. Read the instructions about which version of the .iso CD image file to download.
  3. In the VirtualBox Manager window, do File ► Virtual Media Manager. Under Hard disks select the virtual disk that you want to modify. Select Properties in the toolbar at the top.
  4. Use the Size slider or the number box to select the new larger size for the virtual disk. Make sure it’s not too big because you won’t be able to reduce it later. Click Apply.
  5. Still in the Virtual Media Manager, select Optical disks and then select Add from the toolbar. Browse to find the .iso file that you downloaded (e.g., gparted-live-1.1.0-5-amd64.iso. Click Open and then Close.
  6. In the VirtualBox Manager window, select the virtual machine whose disk you’re enlarging, go to Settings, and select Storage. Under Controller: IDE, click where it either says Empty or names an already inserted virtual CD (e.g., VBoxGuestAdditions.iso), the click on the CD icon (at the right in the Attributes section) and select the GParted .iso that is listed in the pop-up menu. The name of that .iso file should now appear under Controller: IDE. Click on OK.
  7. In Settings ► System, make sure that in Boot Order the entry for Optical is listed above Hard Disk and has its box checked.
  8. GParted screenshot Start your virtual machine. It should boot into GParted Live. You can probably accept Default settings, KMS (you probably don’t need to know what KMS is, it’s related to graphics) and accept the default keymap, language, and graphics mode.
  9. In the screenshot on the right, we see a colour-coded representation of a typical setup with an 8-GB virtual disk that includes a 6-GB main partition (sda1) and a 2-GB swap partition (sda5 nested inside sda2). We could create a new partition to use the newly available space. However, since the swap partition doesn’t contain anything valuable, it’s easy to work around it and extend the sda1 partition. The swap partition can be deleted (delete sda5 first and then sda2) and then recreated after sda1 has been extended. (The newly created partitions will get temporary names until you actually apply your changes, at which point they’ll get names of the form /dev/sdan.)

    Alternatively, the swap partition can be moved to the end of the disk by (1) extending sda2 to the end of the disk; (2) moving sda5 to the end of sda2; and then (3) resizing sda2 by moving its start up against the start of sda5.

    To avoid small 1- and 2-MB bits of unused space, and also avoid certain error messages, the partition alignment can be changed to None in spite of the dire warnings, as long as you don’t touch sda1 except to extend it.

    As you specify changes, they’ll be listed at the bottom of the GParted window, and they can be undone. Once everything looks right, click on the green checkmark icon to apply the changes. Before you do that, convince yourself that you’ve backed up anything on the virtual disk that you don’t want to lose, in case something goes wrong.

  10. If, after doing all this, you get a message when booting which says
    A start job is running for /dev/disk/by-uuid/…
    and the system waits while a timer counts down, it may be that the universally unique identifier (UUID) of one of your disk partitions has changed. To check if the problem is with your swap partition, give the command
    sudo swapon -s (or sudo swapon --show)
    If nothing is displayed, it means that your swap partition is not functioning. To see what the UUID of your swap partition is, do
    sudo blkid | grep swap
    To see what the system thinks is the UUID for your swap partition, do
    more /etc/fstab|grep swap
    If the two UUID's are different, you can edit the file /etc/fstab. First make a backup copy using the command
    sudo cp -p /etc/fstab /etc/fstab_old
    Then invoke the nano editor:
    sudo nano /etc/fstab
    Change the UUID for the swap partition and exit from nano, saving the modified file. Hopefully the delay when rebooting will no longer happen.

10. Problem with Wacom driver

As of 2015 Mar 29 I have a problem with my Windows 7 running out of memory and requiring me to shut down applications. It’s probably related to this Wacom forum posting (dated 2014 Nov 19) about a memory leak in the Wacom Bamboo driver when VirtualBox is running, even if the device isn’t being used. At this moment, for example, Pen_Tablet.exe has a Working Set size of ~1.8 GB and growing. The problem seems to have arisen for me only in the past few weeks. With the Task Manager I cannot directly kill the process Pen_Tablet.exe, nor stop the service TabletServicePen directly by right-clicking, but I could stop it by using the Services button, at which point the memory was released.


R. Funnell
Last modified: 2022-09-07 11:12:37