Figure 1: Oracle VM VirtualBox Manager 5.0.4

Figure 1: Oracle VM VirtualBox Manager 5.0.4, running under KDE Plasma 5.4.1 on Sabayon

If I had to rank which pieces of application software I like the most, Oracle VM VirtualBox (previously called Sun VirtualBox and Sun xVM VirtualBox, henceforth I will call it simply VirtualBox or VB) would probably be at the number 1 position. This is because I love Linux and through VirtualBox I can try any Linux distribution or BSD derivative I want. In fact, I first tried Sabayon through VirtualBox, so I owe my new love of Sabayon, in part to this piece of software. In this post I will talk about how you can install VirtualBox on Sabayon and how you can install VirtualBox Guest Additions in a Sabayon virtual machine.

Before I proceed I should define some terminology, a guest operating system (OS) is one being run through a virtualization program (such as VirtualBox), while the host OS is the OS on which the virtualization program is being run. VM is an acronym for Virtual Machine, which is the “virtual” computer, created by the virtualization program, in which a guest OS can be run. VDI is an acronym for VirtualBox Disk Image, a type of file format used by VirtualBox, in which the hard drive of a VM is stored.

Sabayon Guest Additions

If VirtualBox is used to run Sabayon then in Sabayon you may wish to install VirtualBox guest additions (VBGA). What VBGA does is it essentially more seamlessly integrates the guest and host OS. This allows for more seamless adjustment of screen resolution within the guest OS and for clipboard integration: that is when your guest OS and host OS use the same clipboard, so if you copy something in your guest OS and want to paste it into your host OS you can.

VBGA can be installed via three major methods, each may be appropriate under different circumstances. Regardless of the method by which you install VBGA you will need to add yourself to the vboxguest user group and reboot before you can use it, namely by running (where, of course, <USERNAME> will need to be replaced with your actual username):

root # gpasswd -a <USERNAME> vboxguest
root # reboot

Entropy

The most obvious (and also easy) way would be to install the package virtualbox-guest-additions via Entropy, but it is worthwhile noting that this version of VBGA is often out of date. For example, as of 23 September 2015 the version of VBGA in the Entropy store was 4.3.28, while the latest version of VBGA was 5.0.4. Consequently, if you are using a newer version of VirtualBox than 4.3.28 to run your Sabayon VM VBGA installed via Entropy may not work properly. To install VBGA using Entropy run:

root #  equo i virtualbox-guest-additions

Portage

Installing VBGA through Portage sounds like the natural alternative, if the version of VBGA provided by Entropy is unsuitable, but in my experience this method often returns errors. To give it a try, run:

root # ver=5.0.4 #replace 5.0.4 with the version of VBGA you want
root # emerge =app-emulation/virtualbox-guest-additions-$ver
root # equo rescue spmsync && equo mask app-emulation/virtualbox-guest-additions

VirtualBox Extension Pack

Figure 1: VirtualBox Preferences window

Figure 2: VirtualBox Preferences Window.
Click the highlighted icon to the right of the Preferences Window to add your VBEP file.

If neither of these methods work or are suitable, get the VirtualBox Extension Pack (VBEP) and install it. To do this go to File→Preferences, within VirtualBox, and click “Extensions” in the left-menu of the Preferences Window. Then click the button highlighted (the one near “Adds new package.” box) in figure 2 and in the file browser that pops up find your VBEP file and add it. Check that at least one blank disk is attached to the VM before you boot it, see figure 3 for assistance on this.

Figure 3: Disks and controllers for a VM

Figure 3: Disks and controllers for a VM
The disk icon (with “Empty” written next to it), that is circled (in red), to the left of the “Storage Tree” area needs to be present in order for you to be able to insert the Guest Additions CD image. The other CD image icon that is circled (in purple) is what you need to click in order to add a empty disk, if you do not have one.

After this, start your VM, go the Devices menu and select “Insert Guest Additions CD image” in this drop-down menu (refer to figure 4). If this is the first time you have inserted the guest additions CD image, you will need to wait for VirtualBox to download the CD image ISO.

Figure 3: Screenshot of a Fedora 23 VM with the "Insert Guest Additions CD Image..." option highlighted

Figure 4: Screenshot of a Fedora 23 VM with the “Insert Guest Additions CD image…” option highlighted.

After this, in your guest machine (that is, the VM), enter root (with su) and run:

root # mkdir /media/VBox
root # mount -r /dev/cdrom /media/VBox
root # cd /media/VBox
root # ./VBoxLinuxAdditions.run

add your user account to the vboxguest group (with root # gpasswd -a <USERNAME> vboxguest) and reboot.

Sabayon Host

If you would like to run VirtualBox on Sabayon there are two major ways you can install VirtualBox on Sabayon: A.) using Entropy and B.) using Portage. Option A is the easiest, but option B is the way you will have to go if you want the latest version of VirtualBox. See, as previously mentioned, Entropy houses a fairly out-of-date version of VirtualBox and related packages (4.3.28 vs. the latest version of VirtualBox, as of 23 September 2015, 5.0.4), while the main gentoo overlay of Portage contains a frequently-updated and currently up-to-date VirtualBox ebuild. Additionally if you install VirtualBox through Portage you should not have to install the VBEP, afterwards, as this will have been done during the installation of VB. You can also build the documentation for VirtualBox if you install it with Portage, via enabling the doc USE flag (note this USE flag is not available for the binary Portage package). To install VirtualBox with Entropy run:

root # equo i app-emulation/virtualbox

while to install VirtualBox with Portage run:

root # ver=5.0.4 #as before, replace this with the version of VirtualBox you want
root # emerge =app-emulation/virtualbox-$ver
root # equo rescue spmsync && equo mask app-emulation/virtualbox-bin

or, if you would rather a faster install (as you will be installing a binary package and not a source code package), emerge the virtualbox-bin package instead of virtualbox:

root # echo “app-emulation/virtualbox-bin PUEL” >> /etc/portage/package.license
root # ver=5.0.4 #as before, replace this with the version of VirtualBox you want
root # emerge =app-emulation/virtualbox-bin-$ver
root # equo rescue spmsync && equo mask app-emulation/virtualbox-bin

in my experience installing VirtualBox with Portage occurs much more seamlessly than installing VBGA with Portage. Regardless of method you use to install VirtualBox, after installing it you will need to run:

root # gpasswd -a <USERNAME> vboxusers

 

Running VirtualBox

After you have installed VirtualBox, you will naturally want to use it. The slideshow below covers the process of setting up a VM in VB, in 14 slides.

After starting the VM from the live ISO you can run the installer (if there is any) or otherwise follow the same method to install the guest OS as you would if you had booted from a live USB. Or, if you would prefer, you can just keep running a live session, just remember any changes you make will be lost as soon as you shutdown the VM. Using this method of installation I have managed to install the following OSs:

  • antiX 15
  • Arch Linux
  • Bodhi Linux 3.11
  • CentOS 7
  • Debian 8.0, 8.1 and 8.2
  • elementary OS 0.3 and 0.3.1
  • Fedora 22, 23 alpha/beta and rawhide
  • GhostBSD 10.1
  • Kali Linux 2.0
  • KaOS
  • Korora 21 and 22
  • Linux Mint 17.1 and 17.2
  • Mageia 5
  • MakuluLinux 7.0
  • Manjaro Linux
  • OpenMandriva 2014.2
  • openSUSE 13.2
  • PC-BSD 10.2
  • PCLinuxOS 2014.12
  • Sabayon Linux
  • Trisquel 7
  • Vector Linux 7.1
  • Xubuntu 15.04
  • Zorin OS 9 and 10

Further Reading