Skip to content

Virtualbox

reinstall virtualbox

I start with reinstall because it means remove and install and install is the next chapter.

Some of the symptoms that were solved by this :

(VirtualBox program) Kernel driver not installed (rc=-1908)

(/var/log/vbox*) Building the PCI pass-through module. Error building the module:

(/var/log/vbox*) make: *** No rule to make target 'install'. Stop.

Whenever you have any problems installing virtualbox it is wise to just remove any remainders and then do a new installation.

clean install
1
2
3
4
5
dpkg -l  | grep virtualbox # tells you which version(s) are installed
# i use the actual examle i found, remove it : 
apt-get remove virtualbox-6.0 --purge
rm -rf /etc/vbox
rm -rf /opt/VirtualBox

Last time on re-installation i got messages like this :

error
ln: failed to create symbolic link '/usr/share/icons/hicolor/48x48/apps/virtualbox.png': File exists

This suggest you can also make a command that removes all these icons, an attempt:

remove all icons
# this is not tried, but might work
rm /usr/share/icons/hicolor/*/virtualbox*

However the installer messages are warnings so you could just as well ignore them, there only might be a few too many icons afterwards.

Now proceed to installing :

install virtualbox

Only install the "All distributions" version, it has a 100% success rate.

You can find it here : https://www.virtualbox.org/wiki/Linux_Downloads

It is a script containing binary data so you can wget a particular version with

install virtualbox
1
2
3
4
# note : you should realy get the latest version and not this one :
wget https://download.virtualbox.org/virtualbox/6.1.2/VirtualBox-6.1.2-135662-Linux_amd64.run
chmod +x VirtualBox-6.1.2-135662-Linux_amd64.run
sudo ./VirtualBox-6.1.2-135662-Linux_amd64.run

pxeboot

So VirtualBox can act as PXE and TFTP server to the virtual hosts on the NAT network. It cost me days to find the actual statement but :

Virtualbox has an embedded tftp server !!!

I found it in the small print here : https://www.virtualbox.org/manual/ch09.html (chapter 9.11.2)

It operates on address 10.0.2.4 !!!

Setting up seems straightforward, but none of the tutorials worked out of the box. So here is an example of a setup with notes on how to find out what's wrong, the chapters are based on all the problems encountered.

copy the files

The setup for a tftp server would be something like /tftpboot, for Virtualbox another location had to be found to not bite the server's tftpboot setup, so it is :

tftp
~/Library/Virtualbox/TFTP

Or.. at least a TFTP directory in the file where your VirtualBox.xml is located. On Mac OSX this is that directory. The tutorials i found did not include all files needed. So let's get the base packages needed which are :

base packages
1
2
3
4
5
syslinux : 
pxelinux.0
menu.c32
ldlinux.c32
libutil.c32

The last two are not in any tutorial but copy them anyway, the exact directories :

directories
1
2
3
4
cp ~/Install/syslinux-6.03/bios/com32/libutil/libutil.c32 TFTP
cp ~/Install/syslinux-6.03/bios/com32/elflink/ldlinux/ldlinux.c32 TFTP
cp ~/Install/syslinux-6.03/bios/com32/menu/menu.c32 TFTP
cp ~/Install/syslinux-6.03/bios/core/pxelinux.0 TFTP

A distribution, let's use centos6.7 see : https://docs.google.com/document/d/1LiGH75T45XNt_1p94Mhw57btYN-1IEfK5W0e8FLPwxw/edit) for a guide on how to mount the ISO file.

distribution
1
2
3
centos6.7 :
vmlinuz
initrd.img
copy
1
2
3
mkdir -p ~/Library/VirtualBox/TFTP/images/COS/x86_64/6.7/
cp -p /Volumes/CentOS_6.7_Final/images/pxeboot/vmlinuz images/COS/x86_64/6.7/
cp -p /Volumes/CentOS_6.7_Final/images/pxeboot/initrd.img images/COS/x86_64/6.7/

Also we "need" a menu file : it is called TFTP/pxelinux.cfg/default a version with and without kickstart :

boot menu
timeout 10
default menu.c32

menu title ==== Boot Menu ====
label 1
  menu label ^ 1) CenTOS-6.7 install kickstart
    kernel images/COS/x86_64/6.5/vmlinuz
      append initrd=images/COS/x86_64/6.7/initrd.img inst.stage2=hd:LABEL=Oracle Linux 6.5x20Server.x86_64 ks=http://thuis/ol65-anaconda-ks.cfg ramdisk_size=10000 repo --name="UEK3 kernel repo" --baseurl=cdrom://sr0:/mnt/source  dns=192.168.2.6 gateway=192.168.2.1 netmask=255.255.255.0 ksdevice=eth1

label 2
  menu default
  menu label ^ 2) CentOS-6.7 manual install
    kernel images/COS/x86_64/6.7/vmlinuz
      append initrd=images/COS/x86_64/6.7/initrd.img inst.stage2=hd:LABEL=OL-7.0x20Server.x86_64 ks=http://thuis/ol70-anaconda-ks.cfg ramdisk_size=10000 repo=cdrom

So... let's get on with a kickstart file as well : it is called ks.cfg

ks.cfg
1
2
3
4
#version=RHEL6
# System authorization information
auth --enableshadow --passalgo=sha512
reboot
ks.cfg
# installation media
url --url http://repo.mai.rinis.net/6/os/x86_64
# Run the Setup Agent on first boot
firstboot --enable
ignoredisk --only-use=sda
# Keyboard layouts
keyboard us
# System language
lang en_US.UTF-8
selinux --enforcing
# Network information
#network  --bootproto=dhcp --device=enp0s3 --onboot=on --ipv6=auto --activate --hostname=ol70.local
#network  --bootproto=dhcp --device=enp0s8 --onboot=on --ipv6=auto --activate --hostname=ol70.local
# Root password
rootpw --iscrypted $1$HTBAIaTI$ksFUdRQNx1E05uN23GTI01
# System services
services --enabled="httpd"
# System timezone
timezone Europe/Amsterdam --isUtc
user --name=kees --password=$1$HTBAIaTI$ksFUdRQNx1E05uN23GTI01 --iscrypted --gecos="Kees Klop"
# System bootloader configuration
bootloader --location=mbr
#autopart --type=lvm
# Partition clearing information
clearpart --linux --initlabel
%packages
@core
httpd

Just a start-off version , it will probably be heavily altered for ansible use.

However, this cannot be put in the TFTP directory since redhat only supports providing the kickstart file via http: so we need to enable apache on localhost and put the kickstart file in

sudo cp ks.cfg /Library/Webserver/Documents

To be able to reach it at http://10.0.2.2/ks.cfg Since that is localhost from the VirtualBox NAT viewpoint.

virtualbox settings

Some troubleshooting tips, you can alter the image and tftp address with commands like :

change tftpserver
VBoxManage modifyvm pxetest --nattftpserver1 10.0.2.4

But there is no way to view the current settings, however you can see those values in the file :

view settings
~/VirtualBox Vm’s/[groupname]/[vmname]/[vmname].vbox 

And the previous version ends in vbox-prev, handy if you know it.

Troubleshooting virtualbox

vboxadd

If you wonder what service this is on a VM machine, its VirtualBOX guest ADDitions.

qemu permission denied

symptom

2015-01-28T13:48:55.492767Z qemu-kvm: -drive file=/root/CentOS-6.6-x86_64-minimal.iso,if=none,media=cdrom,id=drive-ide0-1-0,readonly=on,format=raw: could not open disk image /root/CentOS-6.6-x86_64-minimal.iso: Permission denied

When running virt-install for kvm-qemu.

cause

The image file for centos was in /root, and qemu is the one running the command eventually even if you started virt-install as root !! qemu can't read the file from /root

cure

Put the image in /tmp, qemu can read it from there. --cdrom=/tmp/Centos....iso

VERR_SUPLIB_OWNER_NOT_ROOT

symptom

Failed to open a session for the virtual machine xxxxx Failed to load VMMR0.r0 (VERR_SUPLIB_OWNER_NOT_ROOT).

And the details :

Result Code: NS_ERROR_FAILURE (0x80004005) Component: Console Interface: IConsole {1968b7d3-e3bf-4ceb-99e0-cb7c913317bb}

Also if you examine the logs in ~/VirtualBox VMs/vm/Logs, you will find the line :

The owner is not root: '/usr

cause

In my case, this was cause by an installation of libflashplayer from a download. By the way do not do that, add 'contrib' to your sources.list and

flash plugin
apt-get install flashplugin-nonfree

I untarred the tar.gz file in the root which is a big nono. It unpacks files with user number 501, not root, which fucks up a lot of things. * do not fix this by chown -R root.root that will completely fuck up your system. Fix it by resetting directories to root.root, starting with /usr

cure

set rights
chown root.root /usr
chown root.root /usr/lib

In my case the two directories above where enough, but you could see in the tar.gz files that ruined it which files and directories should be reset, or by monitoring ~/VirtualBox VMs/vm/Logs .

vboxdrv setup

symptom

After every reboot, virtualbox complains about having to run :

always needed
/etc/init.d/vboxdrv setup

And it will work fine bu t be forgotten after next reboot.

cause

It is actually a bad error message, since it just means the vboxdrv is not loaded .

cure

Simply add a line :

add to /etc/modules
vboxdrv

To /etc/modules ... done!

usb support

This will not work out of the box, you have to go to the oracle site and install a special extension pack.

  • Install extension pack
  • add yourself to the group vboxusers !!
  • logout and login again or the group change won't stick
  • start virtualbox and enable USB,try adding some usb devices there

Failed to mount folders in Linux guest

Failed to mount folders in Linux guest. This is usually because the "vboxsf" file system is not available. Please verify that the guest additions are properly installed in the guest and can work properly. The command attempted was:

mount guest folders
mount -t vboxsf -o uid=`id -u vagrant`,gid=`getent group vagrant | cut -d: -f3` vagrant /vagrant
mount -t vboxsf -o uid=`id -u vagrant`,gid=`id -g vagrant` vagrant /vagrant

The error output from the last command was:

error
/sbin/mount.vboxsf: mounting failed with the error: No such device

This error is usually because of a mismatch between Virtualbox and the guest additions. Always have the same version of both. This is easily done by just following all suggestions from virtualbox after you installed a new version. It will include the new vbox guest additions iso as well.

It will possibly require you to reinstall (destroy .. up ) a vagrant box that has a mismatch.

Install guest additions on debian

  • Login as root;
  • Update your APT database with apt-get update;
  • Install the latest security updates with apt-get upgrade;
  • Install required packages with apt-get install build-essential module-assistant;
  • Configure your system for building kernel modules by running m-a prepare;
  • Click on Install Guest Additions... from the Devices menu, then run mount /media/cdrom.
  • Run sh /media/cdrom/VBoxLinuxAdditions.run, and follow the instructions on screen.

Guest Log: int13_harddisk: function 02, unmapped device for ELDL=8f

When trying to startup virtualbox machine. In this particular case i created the machine from the commandline with VBoxManage commands and the defaults turn out to give a memory of 128 MB. Changing that to 1024 MB did work for me.

error
Libvirt: ERROR No domains available for virt type 'hvm', arch 'x86_64', domain type 'kvm'

When receiving this error, you probably did not enable virtualization support in the bios.

You can test it with :

test
virt-host-validate

  QEMU: Checking for hardware virtualization                                 : PASS
  QEMU: Checking for device /dev/kvm                                         : FAIL (Check that the 'kvm-intel' or 'kvm-amd' modules are loaded & the BIOS has enabled virtualization)
  QEMU: Checking for device /dev/vhost-net                                   : PASS
  QEMU: Checking for device /dev/net/tun                                     : PASS
   LXC: Checking for Linux >= 2.6.26                                         : PASS


This failure goes away when you reboot and set the virtualization support to ‘enabled’ 

QEMU: Checking for hardware virtualization                                 : PASS
  QEMU: Checking for device /dev/kvm                                         : PASS
  QEMU: Checking for device /dev/vhost-net                                   : PASS
  QEMU: Checking for device /dev/net/tun                                     : PASS
   LXC: Checking for Linux >= 2.6.26                                         : PASS

virt-resize : unsupported feature(s) : 64 bit

The error appeared after using virt-resize :

error
1
2
3
4
Expanding /dev/sda2 using the 'resize2fs' method ...
Fatal error: exception Guestfs.Error("resize2fs: e2fsck 1.41.12 (17-May-2010)
/dev/sda2 has unsupported feature(s): 64bit
e2fsck: Get a newer version of e2fsck!")

This happened while i was resizing a centos7 VM disk image on a centos 6 hypervisor. It is the e2fsck from centos 6 that is used to resize a newer EXT4 filesystem, so you just should not do that. At least run the commands on a centos 7 host if you have to, otherwise match the versions. confirmed : after using same version OS's (centos6) this worked without error.

osx virtualbox

All my vagrant attempts failed with either a black screen or guru meditation. So i tried this site : https://www.youtube.com/watch?v=_cPlKqp8nEA since i know i had an install like this working last time.

The first attempt at my intel machine with vagrant worked, so this does seem to be an AMD issue.

Note that a black screen could be cause by the wrong chipset in :

System->Motherboard->chipset. (last time i set it to PIIX3) choose either one to test if that works better.

Working vagrant setup

CPU : Intel(R) Core(TM) i7-3770 CPU @ 3.40GHz

with vagrantfile :

Vagrantfile
1
2
3
4
5
6
Vagrant.configure("2") do |config|
    config.vm.box = "jhcook/macos-sierra"
    config.vm.provider "virtualbox" do |vb|
        vb.gui = true
    end
end

This one does NOT work on hoek, screen remains black and you cannot 'vagrant ssh'

Installing problems

Mainly this error when starting any box :

error
1
2
3
4
5
6
7
8
9
RTR3InitEx failed with rc=-1912 (rc=-1912)

The VirtualBox kernel modules do not match this version of VirtualBox. The installation of VirtualBox was apparently not successful. Executing

'/sbin/vboxconfig'

may correct this. Make sure that you do not mix the OSE version and the PUEL version of VirtualBox.

where: supR3HardenedMainInitRuntime what: 4 VERR_VM_DRIVER_VERSION_MISMATCH (-1912) - The installed support driver doesn't match the version of the user. 

And if /sbin/vboxconfig does not help, watch the error that is printed. If it is about the kernel headers you can install those with :

install correct headers
sudo apt-get install linux-headers-$(uname -r)

And if even that does not work, for instance because it cannot find the exact header files for your kernel. Try this

reinstall
1
2
3
4
5
6
sudo apt-get update
sudo apt-get upgrade
sudo apt-get dist-upgrade
# probably a reboot
sudo apt-get install linux-headers-$(uname -r)
/sbin/vboxconfig

What versions ?

First detecting what versions it is talking about, which is easy for virtualbox (click help->about). In my case it was :

version
Version 5.1.28 r117968 (Qt5.3.2)

Now for the kernel modules that it is complaining about, first find the names with lsmod :

lsmod
1
2
3
4
5
6
lsmod | grep vbox

vboxpci                22921  0 
vboxnetadp             25540  0 
vboxnetflt             27648  0 
vboxdrv               379703  3 vboxnetadp,vboxnetflt,vboxpci

So any of these will do :

modinfo
modinfo vboxdrv

filename:       /lib/modules/3.16.0-4-amd64/updates/dkms/vboxdrv.ko
version:        5.1.8_Debian r111374 (0x00280000)
license:        GPL
description:    Oracle VM VirtualBox Support Driver
author:         Oracle Corporation
srcversion:     0194E56703167BB8828186F
depends:        
vermagic:       3.16.0-4-amd64 SMP mod_unload modversions 
parm:           force_async_tsc:force the asynchronous TSC mode (int)

Neat, it is definitely not the same, and also it states where it is located. I think this module came from the backports repository i installed earlier. First i added this repository for various backport packages :

add backports
deb http://ftp.debian.org/debian jessie-backports main contrib

But when doing this advise from the virtualbox site itself it advises to install this repository :

add contrib
deb http://download.virtualbox.org/virtualbox/debian jessie contrib

Both have a (different) VirtualBox packages and clearly modules present.

Now if you search the system for vboxdrv.ko, you will get some flavours:

find vboxdrv.ko
su
updatedb
locate vboxdrv.ko

lib/modules/3.16.0-4-amd64/misc/vboxdrv.ko
/lib/modules/3.16.0-4-amd64/updates/dkms/vboxdrv.ko
/var/lib/dkms/virtualbox/4.3.36/3.16.0-4-amd64/x86_64/module/vboxdrv.ko
/var/lib/dkms/virtualbox/4.3.36/build/vboxdrv/.vboxdrv.ko.cmd
/var/lib/dkms/virtualbox/4.3.36/build/vboxdrv/vboxdrv.ko
/var/lib/dkms/virtualbox/5.1.8/3.16.0-4-amd64/x86_64/module/vboxdrv.ko

So the one we need does not even exist, we could first just remove the drivers with :

remove drivers
1
2
3
4
rmmod vboxdpci.ko
rmmod vboxnetflt.ko
rmmod vboxnetadp.ko
rmmod vboxdrv.ko

But we still need the correct driver.

Cleanup

cleanup
apt-get  autoremove --purge virtualbox*

The crux of this all seems to be that running the install command as root is not enough. You HAVE to use sudo !!!

use sudo
1
2
3
4
5
6
sudo apt-get install virtualbox dkms
...
or
...
sudo apt-get -t jessie install virtualbox dkms
modprobe vboxdrv

alter resolution OSX

For the osx box installed with vagrant, the resolution was very small. So here is a way to enlarge it with VBoxManage.

First you have to stop the VM, or it won't work, then find the id to use. :

list vms
1
2
3
VBoxManage list vms

"sierra_default_1509490487502_1974" {39df91cf-aafb-40e9-98b4-f55dd998ca29}

You can copy paste the complete name with quotes for the following command :

setextradata
VBoxManage setextradata "sierra_default_1509490487502_1974" VBoxInternal2/EfiGopMode 5

Note that the number stand for a certain resolution :

number resolution


0 640x480 1 800x600 2 1024x768 3 1280x1024 4 1440x900 5 1900x1200

On my screen 5 still fits.

osx sierra images fails above 4 GB of ram

This happens with this vagrant box on servert :

Vagrantfile
# -*- mode: ruby -*-
# vi: set ft=ruby :

Vagrant.configure("2") do |config|
    config.vm.box = "osx-sierra-0.3.1.box"
    config.vm.provider "virtualbox" do |vb|
        vb.gui = true
        vb.memory = "4096"
    end
end

Changing the memory to 3072 works. Actually i found some threads about this and the suggestion there was that this only happens when you have Chipset set to ICH9. Changing it to PIIX3 make this bug disappear.

PIIX3
Settings -> System -> Motherboard -> Chipset. 

I set it to PIIX3 and the memory tp 20GB and everything runs fine !!

curl3 curl4 mismatch

The last upgrade for python (3.5=>3.6) messed up my system :

  • many packages got uninstalled, vagrant for instance
  • apache2 and virtualbox got in a fight over libcurl3(vbox) vs libcurl4(apache)
  • an uninstallable mode

I managed to get out of it by using the next two commands :

fix-broken
apt --fix-broken install
apt-get update --fix-missing

Just issue these two a lot, they will reduce the problems reported at least. But in general i could only get or apache2 to work or virtualbox. The way out of this was suggested somewhere on a vbox forum to not install the debian package but the last link on this download list:

https://www.virtualbox.org/wiki/Linux_Downloads

The "all distributions", also this was my first 6.0 install, here is the link that worked for me:

This is a shell script so :

script
wget https://download.virtualbox.org/virtualbox/6.0.4/VirtualBox-6.0.4-128413-Linux_amd64.run
sudo bash VirtualBox-6.0.4-128413-Linux_amd64.run

I am now in a stable system again :

commands
systemctl status apache2

python3 -V
Python 3.7.2

vagrant global-status
id       name    provider   state   directory                           
------------------------------------------------------------------------
a999d17  default virtualbox running /home/kees/projects/testbed/demo  

VBoxManage list vms
"jessie" {bee9e5b5-9b30-4883-a2f0-8e470e7ad216}
"demo" {2c0a6310-9cde-46b4-bfa0-10bc16e1c252}

Virtualbox 6 looks 'ass-tight' and i will mention here if there are reasons not to step over. It seams python stepped one version further, but the whole idea was to avoid python 3.5 because of issues.

For one : you need the latest version of vagrant (>= 2.2.3) to work with vbox 6

Resolution vbguest

Suddenly the resizing with vbguest fails to work. At  least i get some info here.

One test you can do is

test
lsmod | grep vb

It seems that this only lists vboxguest and vboxsf, where it should also show vboxvideo.

Whenever vboxvideo is missing something went wrong with the installation.

troubleshooting

error
Kernel driver not installed (rc=-1908)

The VirtualBox Linux kernel driver is either not loaded or not set up correctly. 
Please reinstall virtualbox-dkms package and load the kernel module by executing

'modprobe vboxdrv' as root.

If your system has EFI Secure Boot enabled you may also need to sign the kernel modules (vboxdrv, vboxnetflt, vboxnetadp, vboxpci) before you can load them.    Please see your Linux system's documentation for more information.

where: suplibOsInit what: 3 VERR_VM_DRIVER_NOT_INSTALLED (-1908) - The support driver is not installed. On linux, open returned ENOENT.

Note that in the latest occurrence has the extra message saying you will have to sign the kernel modules if secure boot is enabled. This might set you on the wrong track.

You do NOT have to sign the kernel modules !!

Better just perform the advise that is often also printed in the error. Sometimes it is :

modprobe
sudo modprobe vboxdrv

But that was very probably the command that failed so this one will have more success:

/sbin/vboxconfig
1
2
3
4
sudo /sbin/vboxconfig
vboxdrv.sh: Stopping VirtualBox services.
vboxdrv.sh: Starting VirtualBox services.
vboxdrv.sh: Building VirtualBox kernel modules.

If it does not give this output it will say what is wrong, and mostly provides the correct headers and software you need to install, so do that and try again. After this the error is normally gone.