Skip to content

Oracle VirtualBox Cheatsheet

3ORACLE VIRTUALBOX CHEATSHEET Here are some of the things I had to look up at some point when using Oracle's VirtualBox hypervisor.

INSTALL GUEST ADDITIONS

To install the Guest Additions into your CentOS VM:

  1. First we install necessary packages

    sudo dnf install epel-release
    sudo dnf install binutils kernel-devel kernel-headers libgomp make patch gcc glibc-headers glibc-devel dkms
    sudo dnf groupinstall "Development Tools"
    sudo dnf update
    systemctl reboot
    
  2. After rebooting and getting to the terminal/GUI in the VM, we must inject the Guest Additions CD image into the VM.

    • Goto the "Devices" pulldown menu in VirtualBox, and select "Insert Guest Additions CD Image"
    • VirtualBox will request to download the CD image, allow it to do so
    • After download, it will ask to attach it to the VM, allow it to do so
    • You will now have a CD image attached to the system. The CD has been built to autorun the appropriate installer. So, for example, in GNOME, you can double click on the CD desktop icon.
    • You will have a terminal window open that will start the installation process.
    • After installation process, you must reboot

      systemctl reboot
      
    • Each time you install a new version of VirtualBox, or the kernel in a VM, you will need to repeat this step

  3. To mount your shared drive:

    • On the fly, in the terminal

      sudo mount -t vboxsf SHARENAME MOUNTPOINT
      
    • In /etc/fstab

      SHARENAME MOUNTPOINT vboxsf defaults 0 0
      
    • Sample setup

      sudo mkdir /mnt/host-downloads
      sudo mount -t vboxsf host-downloads /mnt/host-downloads
      
  4. References

    https://www.virtualbox.org/manual/ch04.html#sharedfolders

EL8/EL9 REPO

To install on EL:

  1. Install dependencies

    sudo dnf install epel-release
    sudo dnf install binutils kernel-devel kernel-headers libgomp make patch gcc glibc-headers glibc-devel dkms
    sudo dnf groupinstall "Development Tools"
    sudo dnf update
    
  2. Install repository

    wget http://download.virtualbox.org/virtualbox/debian/oracle_vbox.asc
    sudo rpm --import oracle_vbox.asc
    
  3. Install VirtualBox

    sudo dnf config-manager --add-repo=https://download.virtualbox.org/virtualbox/rpm/el/virtualbox.repo
    sudo dnf install VirtualBox
    
  4. Reboot (necessary)

    sudo systemctl reboot
    
  5. Add user to "vboxusers" group

    sudo usermod -a -G vboxusers YOURUSERNAME
    newgrp vboxusers
    

FEDORA REPO

  1. Install dependencies

    sudo dnf install kernel-devel kernel-headers dkms
    sudo dnf groupinstall "Development Tools"
    sudo dnf update
    
  2. Install repository

    wget http://download.virtualbox.org/virtualbox/debian/oracle_vbox.asc
    sudo rpm --import oracle_vbox.asc
    
  3. Install VirtualBox

    sudo wget http://download.virtualbox.org/virtualbox/rpm/fedora/virtualbox.repo -O /etc/yum.repos.d/virtualbox.repo
    sudo dnf install VirtualBox
    
  4. Reboot (necessary)

    sudo systemctl reboot
    
  5. Add user to "vboxusers" group

    sudo usermod -a -G vboxusers YOURUSERNAME
    newgrp vboxusers
    

UBUNTU 17.10+ REPO

  1. Install dependencies, update system, and reboot

    sudo apt-get -y install gcc make linux-headers-$(uname -r) dkms
    sudo apt update
    sudo apt upgrade
    sudo systemctl reboot
    
  2. Install Repository

    wget -q https://www.virtualbox.org/download/oracle_vbox_2016.asc -O- | sudo apt-key add -
    sudo sh -c 'echo "deb [arch=amd64] http://download.virtualbox.org/virtualbox/debian $(lsb_release -sc) contrib" >> /etc/apt/sources.list.d/virtualbox.list'
    
  3. Install VirtualBox

    sudo apt install virtualbox