Sun VirtualBox Notes

Russell Bateman
January 2013
last update:

The last time I installed VirtualBox, I did it on Mint 13.

    $ sudo bash
    $ cd /etc/apt/sources.list.d/
    $ vim oracle_vbox.list
        Insert "deb precise contrib" in this file!

Download contents of to ~/Downloads.

    $ apt-key add /home/russ/Downloads/oracle_vbox.asc
    $ apt-get update
    $ apt-get install virtualbox-4.2

Experience setting up VirtualBox for a Windows VM

It's been about three years since I wrote an article on using Sun VirtualBox and I thought I'd update it here. I had trouble installing Windows 7 Professional 64-bit and also Windows XP (which I was trying to install as a last resort). For the trouble pictures, not exhaustive, see the set of four at the end of this page.

I had trouble with...

  • Getting Windows 7 install to admit I did have virtualization enabled in my BIOS; see the first image in the second set below.
  • Getting VirtualBox to find my CD-ROM drive; see first image of first set below.

Found CD drive...

Here's the layout summary for the new VM...

Here we are beginning the Windows 7 Installation...

...the installation continuing successfully.

Starting to launch the Windows installation: let's tell a lie and say that virtualization isn't enabled...

Installation starting, though doomed to failure...
What did I do differently when Windows installation actually started? Not sure, however, I carefully scrutinized the images above and ensure the settings were identical to the last time this worked.

The nastygram coming as a shock...

Window XP installation: my last-ditch effort. This may still be a CD problem...

Attempt to install Windows XP

This fails even after doing the CD as shown above (and below, which also describes what I did for Windows 7, but in greater detail):

Here's a Windows XP VM set up...

Having clicked on Storage in the last image, I click on the first little disk icon...

...which confirms I'm going to configure a CD; I choose to leave it empty...

...then I select it... on the disk icon and choose my CD drive...

...and make it passthrough...

But, the final result is identical to the original one, i.e.: FATAL: No bootable medium found! System halted.

Getting Guest Additions to install

This is way more frustrating than it was a few years ago when I had so much success with VB.

The problem is that my Windows guest VM comes up with no outside window around it. It's in this window (see Conquering Sun VirtualBox for Dummies like Me) that the Devices menu appears to let you install the guest additions.

The moral of this story is not to go horsing around optimizing your guest OS window at least until you've at least installed the Guest Additions. The second time I installed, I was careful and did not have to do anything other than grab the menu at the top of the guest window Devices -> Install Guest Additions....

Instead, I had to download the guest additions ISO (see here) and then go through my (unlaunched) VM's Settings -> Storage > Controller: IDE, etc. to mount the ISO (that I downloaded) as a CD.

Then, I launched the Windows VM and opened the (now showing CD) in Windows File Explorer. It would not AUTORUN. Duh. And double-clicking AUTORUN only opend the file in NotePad. Double duh. So, to get it to install, I double-clicked VBoxWindowAdditions-amd64. It took a while to launch.

What's the mess here? Somewhere along the way, I either naively got rid of the outside VB window around my launched Windows guest VM or VM just sucks. I googled heavily, found others complaining also and no one offered a solution except to repeat "install guest additions by pressing HOST + D". One respondant even said, " the documentation. I can't improve on it." I was never able to get the VirtualBox window (parent) of my Windows 7 guest VM back which would have made installing guest additions easier.

Shared-folder joy

As soon as I got the guest additions installed on Windows, however, I immediately saw what I was looking for: a working, shared-folder relationship with my Lucid host. The first illustration is the VM settings for my Windows guest showing where I thought I'd be sharing a mount point. The second is what I see in Windows File Explorer, i.e.: an ISO I had intended to share (for purposes unrelated to this discussion). The third shows you where this is on my Lucid host.

Supplementary notes

I tried installing Ubuntu Precise Server on Linux Mint 13 under VirtualBox. A sore problem with getting help on this topic is understanding when respondees are talking about something to do or happening on the guest OS as compared to the OS hosting VirtualBox.

This went well, but I could not:

  1. Install Guest Additions.
  2. Use Ctrl key on guest.

More installing Guest Additions

Per, I did this:

  1. apt-get install dkms build-essential linux-headers-generic
  2. thinking that this would allow the (Guest window) Devices -> Install Guest Additions... to work. It did not.

Ultimately, I was able to install the Guest Additions, but I did not note how. As I remember, I used the advanced packaging tool.

The best way to avoid trouble is not to jack with any of the settings, but just dismiss the alerts each time you start up.

Mounting host's optical drive (CD, DVD, etc.) in VM

How to mount what's in the host's CD, DVD, Bluray, etc. drive in the running virtual machine (VM):

  1. Open VirtualBox manager dialog (main window that lists all the VMs) if not open.

  2. Select the running VM.

  3. Click Settings (will be for this VM), then Storage.

  4. Click Controller: IDE → Empty; you should see something like this:

  5. Click to mark Live CD/DVD if not checked.

  6. Click disk icon (choose a virtual disk...) and choose the drive in the host running VirtualBox you wish to mount in the VM.

  7. Click OK.

At this point, you should hear the drive begin to whir, then see it mount on the VM's desktop.

I hid the VirtualBox menu in the VM and can't get it back

To save screen real estate, I hide menu bars, but now I don't know how to get it back.

  1. Open VirtualBox (main) dialog box.
  2. Select (running) virtual machine (VM) whose menu you want back.
  3. Click on Settings → User Interface.
  4. Click the Enable Menu Bar checkbox.

Look at the VM in the host; the menu should have reappeared.

Installing VM from ISO: no bootable medium found

Be sure that, under Settings → System for the VM, you do not mindlessly uncheck Optical thinking you don't need it because you will need it in support of the ISO during installation.

Installing guest additions on a headless-server VM

On a headless, Linux-server VM, installing VirtualBox Guest Additions isn't too straightforward. These commands are all run as root.

  1. In the top menu of the guest VM window, click Devices → Insert Guest Additions CD Image. This puts the (virtual) CD at your VM's disposal.
  2. Mount this CD. Before you can do that, you'll need to create a mount point if it's not already there (see first three commands). If you've done this before, it will still be there, but you'll have to (re)mount it—it doesn't survive reboots:
    # cd /media
    # mkdir cdrom
    # chmod 770 cdrom (or chmod u+rwx,g+rwx cdrom)
    # mount /dev/cdrom /media/cdrom
    mount: /media/cdrom: WARNING: device write-protected, mounted read-only.
  3. Install dependencies via the advanced packaging tool:
    # apt-get install -y dkms build-essential linux-headers-generic linux-headers-$(uname -r)
    If you've got trouble with your package manager (maybe a PPA that's hiding), you might get errors doing this, but they should not be fatal to the overall objective.
  4. Next, install the Guest Additions package:
    # cd /media/cdrom
    # ./

Mounting a shared folder on a headless-server VM

To mount the host's (shared) folder (VirtualBox Guest Additions must be present, installed and mounted). The mounted folder was designated in the VirtualBox GUI Settings → Shared Folders configuration. For instance, maybe you're running VirtualBox on Windows and sharing your Documents folder. Here's how to mount that on a headless, Linux server. These commands are all run as root.

  1. Create a mount point under /media.
    # cd /media
    # mkdir sf_Documents
    # chmod 770 Documents
  2. Fix up the vboxadd user to belong to group vboxsf:
    # adduser vboxadd vboxsf
    # groups vboxadd
    vboxadd : daemon vboxsf
  3. Mount the shared volume:
    # mount -t vboxsf Documents /media/sf_Documents
    /sbin/mount.vboxsf: mounting failed with the error: Protocol error
    This seems always to happen when the guest is headless. Fighting it for hours results in it working, but there appears no rhyme or reason for it to have failed in the first place and to begin working in the second. The last time I got it to work, this was the configuration:
    VirtualBox → Settings → Shared Folders → Name/Folder:
    # mount -t vboxsf dev /media/sf_dev

What a shared folder on a Windows guest looks like

Enabling Intel VT-X on HP EliteDesk 800 American Megatrends, Inc. BIOS

Without Intell VT-X (or AMD-V), VirtualBox (nor VMware Workstation) can support 64-bit guest OSes.

I once got an HP EliteDesk 800 with i7 that came with VT-X disabled which I did not know until I ran VirtualBox to install a new VM ("ERROR: VT-X is not available"). I went into the BIOS, but could not find where to enable it and thought that this wasn't an available feature. Later, I found on an HP support site how to do this:

  1. Press Esc as the computer boots up to gain entry to the BIOS.
  2. Choose Computer Setup.
  3. Use the right-arrow key to reach the Security menu (!).
  4. Use the down-arrow to reach System Security.
  5. Enable VT-X.

VirtualBox VM networking options matrix

It's relevant to understand what one's networking options are in a VM depending upon the network type chosen in Settings → Network → Attached to:. See 6.2. Introduction to networking modes.

                network type →
direction ↓
NAT NAT Network Bridged Internal Host-only
VM ⇆ Host - - -
VM ⇆ VM -
VM → Internet - -
VM ← Internet port-forwarding port-forwarding - -
static-address support - - - -

To read what's in the table's left column, take VM ⇆ Host; this means, "from VM to host or host to VM." VM → Internet means, "from VM to Internet (but not from Internet to VM)."

Bridged networking in a VirtualBox guest means more or less that the VM behaves on the network as if a computer host separate from the one on which it's a guest. The other types come with various limitations that make them not behave as an independent, separate host.

Disable the screensaver of a Linux/headless server VM

...because, really, any screen-saving should be a function of the host OS unless you're just trying to be clever.

  1. Edit /etc/default/grub.
  2. Add consoleblank=0 to (probably the end of) what's already there for GRUB_CMDLINE_LINUX_DEFAULT.
  3. Run update-grub.
  4. Reboot the server.

modprobe vboxdrv error: "Could not insert..."

The VirtualBox Linux kernel driver (vboxdrv) is either not loaded or there is a permission problem with /dev/vboxdrv. Please install virtualbox-dkms package and load the kernel module by executing

# modprobe vboxdrv

as root. If it is available in your distribution, you should install the DKMS package first. This package keeps track of Linux kernel changes and recompiles the vboxdrv kernel module if necessary. Note that modprobe should be found on the path /sbin/modprobe or /usr/sbin/modprobe. Here are some particulars you might need as you work through this. Note that you might benefit from updating your Linux kernel or uninstalling then reinstalling virtualbox-dkms.

# apt-get remove virtualbox-dkms
# apt-get remove --purge virtualbox-dkms
# apt-get install -y linux-headers-amd64 linux-image-amd64
# apt install --reinstall linux-headers-$(uname -r) virtualbox-dkms dkms
# apt-get install -y virtualbox-dkms

If [/usr]/sbin/modprobe itself is missing, try this for Ubuntu, at least:

# apt-get install kmod

modprobe module signing...

When attempting to bring a working Virtual Box up on a base OS to which you don't have root access, there arises the need to sign the modules.

When you run the command:

# modprobe vboxdrv

...and get some kind of error, you may discover that the solution requires signing the vbox modules before Virtual Box will work error-free. What's worse, you won't discover which vbox modules you need to sign except as you discover them one by one trying to set up a VM.

Here's how to perform this signing, but first, consider that... must register these modules for Secure Boot (which component is what's causing you this nightmare in the first place). Since Linux kernel version 4.4.0-20, it's enforced that unsigned kernel modules will not be allowed to run with Secure Boot enabled, so you must sign all modules you wish to use. Start by installing the mokutil module:

# apt-get update && apt-get upgrade && apt-get install mokutil

Next, create signing keys:

# openssl req -new -x509 -newkey rsa:2048 -keyout MOK.priv -outform DER -out MOK.der -nodes -days 36500 -subj "/CN=VirtualBox/"

Note that in whatever current working directory from which you issue these signing commands, there is created—and therefore appended to—files MOK.priv and MOK.der. Don't try to issue the signing command while your current working directory is other.

Sign the modules in question (I would do at least these two up front):

# /usr/src/linux-headers-$(uname -r)/scripts/sign-file sha256 ./MOK.priv ./MOK.der $(modinfo -n vboxdrv)
# /usr/src/linux-headers-$(uname -r)/scripts/sign-file sha256 ./MOK.priv ./MOK.der $(modinfo -n vboxnetflt)

If you feel like it, you can confirm that the module is signed:

# tail $(modinfo -n vboxdrv) | grep "Module signature appended"

Then, register the keys to Secure Boot:

# mokutil --import MOK.der

This forces you to enter a password. Make it simple and remember it. Then, restart your base OS (i.e.: bounce your computer). A blue screen will appear and you'll see an option, Enroll MOK. You should take this option (pressing Enter), then Continue, then input the password.

(Likely, you will not need this password again, but hang onto it just in case.)

And, once you've rebooted, if you feel like it, you can confirm that the key was enrolled (and should work). Remember to be in that same current working directory as when you signed the modules:

# mokutil --test-key MOK.der

Important note

The solution to the problem that sent you to this note doesn't exactly have anything to do with Virtual Box, but with the fact that Secure Boot has been imposed upon your hardware. This also has nothing to do with the version of Virtual Box. (When I wrote this note, I was working with Virtual Box 6.1.)

Building a Linux VM using an ISO

We're going to install a VM running Linux Mint 21.2 Cinnamon 64-bit as an example.

Create a new VM in Virtual Box thus:

  1. Click New.
  2. Fill in (VM- and host) Name.
  3. Choose where this VM will reside in your local filesystem. (Pick default.)
  4. Choose the Type (Linux)...
  5. ...and the Version (Ubuntu 64-bit)
  6. Click Next.
  7. Dial in the amount of memory you want (16384), click Next.
  8. Click Create a virtual hard disk now, click Create.
  9. Choose whether to create the disk immediately or only virtually. If you're going to be using the VM in a serious way (e.g.: for development), you may wish to go with an "up-front" solution, VHD. Click Next.
  10. Pursuant to the previous instruction, choose a Fixed size disk and click Next.
  11. Choose the File location and size, that is, what to call and where to put the diskspace as well as how big. (The default is /home/username/VirtualBox VMs/hostname/hostname.vhd.) I'm going to size my disk as 1 Tb (1000 Gb).
  12. Click Create.

Once you've created the VM, configure it by clicking Settings.

    Serial Ports
    Shared Folders
    User Interface

The new VM is created and configured, however, before launching, you must consider how the OS will be sourced. The purpose of this note is to demonstrate a particular installation, that of Linux Mint 21.2 Cinnamon 64-bit. We have an ISO.

  1. Click Settings.
  2. Click Storage.
  3. Click under Controller: IDE, Empty.
  4. Click Live CD/DVD.
  5. Click icon, "Choose optical disk..."
  6. Click Chooose a disk file.
  7. Navigate to the ISO you downloaded (something like ~/Downloads/linuxmint-21.2-cinnamon-64bit.iso).
  8. Click Open.
  9. Click OK to dismiss Settings dialog.
  10. Click Start.
  11. Click Start Linux Mint 21.2 Cinnamon 64-bit to install.
  12. Press Enter to launch the ISO.
  13. Double-click the desktop icon, Install Linux Mint.
  14. Walk the installation just as if you were installing from a DVD ISO in the optical drive of a piece of hardware.