VirtualBox/Guest Additions/Ubuntu

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 20.04 LTS as a guest in VirtualBox-6.1 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 "testUbuntu20 [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".
    1. At this point, with a fresh Ubuntu 20.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 20 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" and perl, but apparently that is no longer necessary).
        2. (Earlier advice also recommended installing gcc and make, but apparently they are already included with build-essential).
      2. When the VM starts up again, right-click the CD image on the desktop (if you don't see it, look in the left bar, at the bottom), and Eject.
      3. Install the Guest Additions again from the beginning.
  6. 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.
  7. Go back to the host operating system. At the top of the "testUbuntu20 [Running] - Oracle VM VirtualBox" window, most people find it convenient to enable Devices >> Shared Clipboard >> Bidirectional.
  8. Shut down the virtual machine from the tiny triangle icon in the upper right corner, the power icon, "Power Off" >> Power Off >> Power Off.
  9. Open up the Oracle VM VirtualBox manager. The "testUbuntu20" VM currently has the "Powered Off" icon, right? Select the VM, and hit the green arrow "start" icon.
  10. (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?)
  11. (optional) To automagically resize the size of the virtual monitor to fill the "testUbuntu20 [Running] - Oracle VM VirtualBox" window whenever you stretch or shrink that window,
    1. At the top of the "testUbuntu20 [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 "testUbuntu20 [Running] - Oracle VM VirtualBox" window, choose View >> Auto-resize Guest Display.

References edit