I've recently installed Ubuntu on Oracle's Virtualbox. Now I want to install the guest additions.
I started up my Ubuntu guest OS, clicked "Devices" and chose "Install Guest Additions". Nothing happened, and I don't see the CD icon on my desktop.
How can I make this work?
Installing Guest additions from the repositories
In case we have installed the OSE edition of Virtual Box from the repositories we can add the guest additions from the repositories in the guest. This will install guest additions matching the Virtual Box version as obtained from the repositories. It is not recommended to install these in newer releases of Virtual Box as obtained from the Oracle repository (see below).
Alternatively we can install the package virtualbox-guest-additions-iso in the host Ubuntu.
The .iso file with an image of the OSE edition of the guest additions CD will install in the host directory
/usr/share/virtualbox/VBoxGuestAdditions.iso
. Mount this .iso file as a CD in your virtual machine's settings. In the guest you will then have access to a CD-ROM with the installer.Installing Guest Additions from Virtual Box Manager
In case the Guest Additions fail to build we may have to install the Linux kernel headers (see How do I install kernel header files?) or build-essential tools in addition. It is also recommended to have dkms installed (see below - Note 4). You can run this command in a terminal to install both:
Selecting Devices -> Install Guest Additions (or press Host+D from the Virtual Box Manager) the Guest Additions CD .iso will be loaded but not installed in your guest OS. To install we need to run the installer script
VBoxLinuxAdditions.run
as root or from the Autorun Prompt (see below).GNOME Shell
To install the Guest Additions we will have a CD icon on our desktop as soon as the virtual drive is mounted:
Next step is to run the autorun.sh script (as root) on this mounted CD by opening the drive and clicking on the "Run Software" button. This will build and install the vbox kernel modules needed.
Unity
The guest additions is mounted as a virtual CD visible on the launcher:
In case the system is set up to autorun a CD it should just open the following autorun dialogue (if not select the CD symbol, choose open, then choose Open Autorun Prompt)
After having entered your credentials for root access the guest additions will build as seen from the terminal output:
Press Return to close the terminal.
Installing Guest Additions from a Terminal
In case Guest Additions are not installed properly we may not be able to boot to the GUI. In this case we need to boot holding the Shift key to access the Grub menu where we access a root shell as depicted in the following question (we do need to mount the filesystem read/write to proceed):
The Guest Additions .iso file needs to be installed on
/dev/cdrom
from the Virtual Box Manager (see above). We then may install Guest Additions by typing the following commands:Remove Guest Additions
In case something went wrong with installing the guest additions, or the guest OS can not boot after installing we may have to remove the additions. This can also be done from a root shell by running an uninstallation script located in the guest
/opt
directory.Replace
x.x.xx
with your current version of guest additions.You could also try the following (this worked for me after I had to reinstall the Guest Addtitions after Update Manager killed them). Solution found here:
http://www.unixmen.com/install-guest-addition-in-ubuntu-1010-maverick-meerkat-fix/
In summary:
This found and updated the correct version of the VirtualBox Guest Additions and my system seems to work properly again, and I'm assuming this will also work if Guest Additions are failing to install from the menu item.
One other thing of note. I originally tried to run this under the fish shell - make sure you're using bash (i.e. type "bash" into the terminal before you start).
Note on more recent systems, the command has been changed to
Within the guest operating system, install the package
virtualbox-guest-dkms
. For example, using the Terminal application, typesudo apt-get install virtualbox-guest-dkms
.Here are the manual steps to install VirtualBox Guest Additions kernel modules inside the VM:
Download the ISO file, e.g.
Mount the ISO file:
Run installer (add
-x
aftersh
to debug):To find the right version of ISO file, check it at: http://download.virtualbox.org/virtualbox/
If you're using Vagrant, installation is much simpler by following these commands:
The standard "virtualbox-guest-additions" package on the .iso provided by Oracle, has general tools for different Guest Operating Systems...
However, Ubuntu has its own dedicated Ubuntu-specific Guest Addon package(s)...
named
virtualbox-ose-guest-dkms and ..-x11 and ..-utils
.These 'virtualbox-ose-guest-*' packages are DKMS aware..
"(DKMS is a framework designed to allow individual kernel modules to be upgraded without changing the whole kernel.)"
Here is the link to a question I asked 5-6 months ago on this issue... How can I get Compiz to work in a VirtualBox VM
Here are the steps I ran which finally worked, but as user named 'pcworld' stated above it may have been the case that only the last command was actually required. I'll never know, but I want to share in case this helps anyone else:
And don't forget to set your VirtualBox instance to use like 128MB video ram and Enable 3D Acceleration under the "Display" settings section for your instance, for good performance.
This worked for me for a Ubuntu Server 14.04 guest VM (no GUI):
Edit: also works with Ubuntu Server 15.04 and 16.04
1) Install dkms. From the guest run:
2) From the VirtualBox VM window menu select: Devices --> Insert Guest Additions CD image...
3) Use blkid to identify the CD-ROM device. From the guest run:
One of the lines in the output should look like this:
The first part (
/dev/sr0
) is the name of the CD-ROM device.4) Mount the CD (replace
/dev/sr0
by the device name found above):5) Run the Guest Additions installer:
6) Reboot the guest.
The procedure is quite simple.
In Virtual Box menu select Devices > Insert Guest Additions CD Image....
The following popup will appear on your Ubuntu desktop :
Select Run and Guest Additions will automatically be installed.
I think the right way to do this right now (2020-Apr-27) with the newest stable Ubuntu (20.04) and the current Virtualbox (6.1.6) is to just do the following:
sudo apt install virtualbox-guest-dkms virtualbox-guest-x11 virtualbox-guest-utils
I just did that and it worked.
I guess this won't get a lot of attention down here but at least if somebody searches for 20.04 they might be able to find some more recent information. ;)
The
virtualbox-guest-additions
package has to be installed. Furthermore, it may appear that nothing has happened, but all the "Install Guest Additions" button do is mounting the cdrom. You should open the File manager (Nautilus / Dolphin), select the "CD device" and run the installer.