VirtualBox/Guest Additions/Ubuntu

From Wikibooks, open books for an open world
Jump to navigation Jump to search

Here we install the Guest Additions on an Ubuntu guest system running inside Virtualbox.[1]

This chapter assumes you already have Ubuntu installed in a VirtualBox virtual machine, perhaps using the process described in VirtualBox/Setting up a Virtual Machine/Ubuntu.

(This was tested on Ubuntu Desktop 18.04 LTS as a guest in VirtualBox-6.0.18 on a Windows 10 host. Other versions and other hosts should work similarly.)

  1. Go back to the host operating system. At the top of the "testUbuntu18 [Running] - Oracle VM VirtualBox" window, choose Devices >> "Insert Guest Additions CD image..."
  2. (VirtualBox simulates inserting a CD into the simulated optical drive of the VM, and Ubuntu auto-mounts that CD under "/media/a/").[2]
  3. When Ubuntu gives the "VBox... Would you like to run it?..." pop-up window, hit "run".
  4. Hey, remember that password we wrote on a sticky note earlier? Type it in and hit the Authenticate button.
  5. Ubuntu pops up a new terminal window and takes a minute to install and start up "VirtualBox Guest Additions".
  6. With a fresh Ubuntu 18.04 LTS install, it typically says "This system is currently not set up to build kernel modules. Please install the gcc make perl packages from your distribution." If that happens,
    1. Inside the Ubuntu 18 VM, open up a terminal with Ctrl+Alt+T . Inside that terminal run:
   sudo apt update
   sudo apt install build-essential
   reboot

(What is build-essential? see https://superuser.com/questions/151557/what-are-build-essential-build-dep )

    1. (Earlier advice also recommended installing "dkms", but apparently that is no longer necessary).
    2. (Earlier advice also recommended installing gcc, make, and perl, but apparently they are already included with build-essential).
    3. When the VM starts up again, right-click the CD image on the desktop and Eject.
    4. install the Guest Additions again from the beginning.


  1. When there are no errors and the last line of that terminal window says "Press Return to close this window...", click inside that window and press Return.
  2. Go back to the host operating system. At the top of the "testUbuntu18 [Running] - Oracle VM VirtualBox" window, most people find it convenient to enable Devices >> Shared Clipboard >> Bidirectional.
  3. Shut down the virtual machine from the tiny triangle icon in the upper right corner, the power icon, "Power Off".
  1. Open up the Oracle VM VirtualBox manager. The "testUbuntu18" VM currently has the "Powered Off" icon, right? Select the VM, and hit the green arrow "start" icon.
  2. (Now when you look under "/media/a/", the "Guest Additions CD image" is still there -- do I need to do something to "take it out of the (virtual) drive"? If so, how?)
  3. (optional) To automagically resize the size of the virtual monitor to fill the "testUbuntu18 [Running] - Oracle VM VirtualBox" window whenever you stretch or shrink that window,
    1. At the top of the "testUbuntu18 [Running] - Oracle VM VirtualBox" window, choose View >> Auto-resize Guest Display.
    2. When you installed the Guest Additions (as described above), that option should have been enabled. There is apparently two separate bugs that can keep it greyed out even after installing the Guest Additions and rebooting:[3][4]
    3. Some people suggest editing a "/etc/X11/xorg.conf" file, but that file apparently no longer exists in Ubuntu14.
    4. Some people suggest using apt-get to (re)install guest additions, uninstalling that version, and then re-install the guest additions again from the VirtualBox ISO:[5]
      1. Inside the virtual machine, open a terminal window and run "sudo apt-get install build-essential dkms virtualbox-guest-additions-iso". Hit "y" to continue.
      2. Next, uninstall the guest additions: "sudo apt-get remove --purge virtualbox-guest-additions-iso". (We only installed it to pick up a bunch of dependencies; it's probably the wrong version for whatever version of VirtualBox you have running on your host).
      3. At the top of the "testUbuntu14 [Running] - Oracle VM VirtualBox" window, choose Devices >> "Insert Guest Additions CD image..." and re-install it, as described above.
      4. Reboot
      5. wait a minute until the GUI desktop comes up
      6. At the top of the "testUbuntu18 [Running] - Oracle VM VirtualBox" window, choose View >> Auto-resize Guest Display.

References[edit]