注意:

The Funtoo Linux project has transitioned to "Hobby Mode" and this wiki is now read-only.

Difference between revisions of "Package:VirtualBox"

From Funtoo
Jump to navigation Jump to search
(add exporting a virtual machine ova to help accelerate low level development by being able to share.)
 
(41 intermediate revisions by 12 users not shown)
Line 1: Line 1:
<code>VirtualBox</code> is an application that allows to run a guest O/S inside a host O/S.
{{Ebuild
|Summary=A desktop virtualization package from Oracle Corporation that allows you to run a guest operating system (Linux, Windows or other) on your Linux system.
|CatPkg=app-emulation/virtualbox
}}
'''VirtualBox''' is a free and open source [https://www.wikipedia.org/wiki/Virtualization virtualization] '[https://www.wikipedia.org/wiki/Hypervisor hypervisor]' for x86-based machines. VirtualBox can be installed and run on GNU/Linux and other Operating Systems.
 
The [https://en.wikipedia.org/wiki/Virtual_machine virtual machines] provided by VirtualBox can be used to run a number of guest Operating Systems such as GNU/Linux, Windows, and others.
 
VirtualBox is available for Funtoo Linux on the ''arch'' profiles '''x86-32bit''', '''x86-64bit''' and '''pure-64'''.
 
VirtualBox Homepage: https://www.virtualbox.org


== Glossary of Terms ==
== Glossary of Terms ==


:;Host O/S : system running on computer you are actually on;
{{TableStart}}
:;Guest O/S : system installed within VirtualBox;
{{2ColHead|Term|Explanation}}
:;Guest Additions : drivers for the Guest O/S.
{{2Col|'''''Host OS''''' |An install of Funtoo Linux on physical hardware. VirtualBox will be installed to and run from here.}}
{{2Col|'''''Guest OS'''''|The Operating System that is run '''within a Virtual Machine''' provided by VirtualBox. The Guest OS could be Funtoo Linux, another GNU/Linux distribution, Windows, etc.}}
{{2Col|'''''Guest Additions'''''|''Guest Additions'' is a collection of  applications, libraries and kernel modules/drivers that are installed in your Guest OS. These provide support for graphics, networking, and other features such as file transfer and Guest access to real physical devices such as a USB flash drive.}}
{{TableEnd}}
 
== Host OS Installation ==
VirtualBox can be installed onto your Host OS - Funtoo Linux - using one of two packages: {{c|app-emulation/virtualbox}} or {{c|app-emulation/virtualbox-bin}}. The latter "-bin" package is a binary (precompiled) copy of VirtualBox. Installing this may be preferable on machines with low computing power.
 
For a typical install, run
{{console|body=
###i## emerge --ask app-emulation/virtualbox
}}
 
=== Assign VirtualBox Users ===
 
Normal non-root users will not be able to use VirtualBox immediately after it has been installed. The Users that are to use VirtualBox must first become a member of the group  {{c|vboxusers}}. For example, a user ''alice'' is added to {{c|vboxusers}}
 
{{console|body=
###i## gpasswd -a alice vboxusers
}}
 
If currently logged in the User added to {{c|vboxusers}} must first log out before the changes will have an effect.
 
=== Load VirtualBox Kernel Modules ===
 
VirtualBox requires one or more Linux kernel modules to be loaded on the Host OS (Funtoo Linux) in order to function. As of VirtualBox version 5 these are provided by the package {{c|app-emulation/virtualbox-modules}} which is installed automatically (as a dependency) when you install app-emulation/virtualbox.
 
As ''root '' load these modules in a terminal
{{console|body=
###i## modprobe vboxdrv
###i## modprobe vboxnetadp
###i## modprobe vboxnetflt
}}
 
=== Starting VirtualBox ===
* create the loading script:
{{console|body=
###i##cat > /etc/vbox/vbox.cfg << EOF
INSTALL_DIR=/opt/VirtualBox
export QT_SCREEN_SCALE_FACTORS=1
export QT_SCALE_FACTOR=1
export QT_AUTO_SCREEN_SCALE_FACTOR=0
EOF
}}


== Versions of VirtualBox ==
VirtualBox can be started from a terminal.
{{console|body=
$##i## VirtualBox
}}


VirtualBox is available in two versions :
In a Desktop Environment, VirtualBox may also be run from a menu entry. Look for the names "VirtualBox" or "Oracle xVM VirtualBox" under menu categories "System" and/or "Emulator".


# '''Source based package''' : app-emulation/virtualbox;
=== Funtoo Linux (Host OS) kernel updates ===
# '''Binary package''' : app-emulation/virtualbox-bin.
The VirtualBox kernel modules are compiled for the kernel present on the Host, Funtoo Linux. Each time that the Host kernel is updated or changed, the VirtualBox kernel modules must also be rebuilt.


Binary package contains extensions which are not available with the source one. When we install the source based package, we must refer to the USE flags list hereafter.
As is typical for most kernel changes or updates, please run
{{console|body=
###i## emerge --ask @module-rebuild
}}
''before'' running VirtualBox under the new kernel.


== USE flags ==
If you wish to check that the VirtualBox kernel drivers will be rebuilt in this way, please examine the file {{f|/var/lib/module-rebuild/moduledb}}. For example, using the command {{c|grep}}


{| class="wikitable" style="margin: 1em auto;" width=80%
{{console|body=
! width="20%" | Use flag
$##i## grep virtualbox /var/lib/module-rebuild/moduledb
! width="10%" | Default
a:1:app-emulation/##r##virtualbox##!r##-modules-5.0.20
! width="10%" | Recommended
}}
! width="60%" | Description
|-
| style="text-align:center;" |additions
| style="text-align:center;" |Yes
| style="text-align:center;" |Yes
| Install Guest System Tools ISO.
|-
| style="text-align:center;" |alsa
| style="text-align:center;" |Yes
| style="text-align:center;" |Yes
| Add support for media-libs/alsa-lib (Advanced Linux Sound Architecture).
|-
| style="text-align:center;" |doc
| style="text-align:center;" |No
| style="text-align:center;" |
| Add extra documentation (API, Javadoc, etc). It is recommended to enable per package instead of globally.
|-
| style="text-align:center;" |extensions
| style="text-align:center;" |No
| style="text-align:center;" |Yes
| Install extension module packages.
|-
| style="text-align:center;" |headless
| style="text-align:center;" |No
| style="text-align:center;" |
| Build without any graphic frontend.
|-
| style="text-align:center;" |java
| style="text-align:center;" |No
| style="text-align:center;" |No
| Add support for Java.
|-
| style="text-align:center;" |opengl
| style="text-align:center;" |Yes
| style="text-align:center;" |
| Add support for OpenGL (3D graphics).
|-
| style="text-align:center;" |pam
| style="text-align:center;" |Yes
| style="text-align:center;" |Yes
| Add support for PAM (Pluggable Authentication Modules) - DANGEROUS to arbitrarily flip.
|-
| style="text-align:center;" |pulseaudio
| style="text-align:center;" |Yes
| style="text-align:center;" |
| Add support for PulseAudio sound server.
|-
| style="text-align:center;" |python
| style="text-align:center;" |Yes
| style="text-align:center;" |
| Add optional support/bindings for the Python language.
|-
| style="text-align:center;" |python_single_target_python2_7
| style="text-align:center;" |Yes
| style="text-align:center;" |
| Build for Python 2.7 only.
|-
| style="text-align:center;" |python_targets_python2_7
| style="text-align:center;" |Yes
| style="text-align:center;" |
| Build with Python 2.7
|-
| style="text-align:center;" |qt4
| style="text-align:center;" |Yes
| style="text-align:center;" |Yes
| Add support for the Qt GUI/Application Toolkit version 4.x. No GUI when not set.
|-
| style="text-align:center;" |sdk
| style="text-align:center;" |Yes
| style="text-align:center;" |
| Enable building of SDK.
|-
| style="text-align:center;" |vboxwebsrv
| style="text-align:center;" |No
| style="text-align:center;" |No
| Build and install the VirtualBox webservice.
|-
| style="text-align:center;" |vnc
| style="text-align:center;" |No
| style="text-align:center;" |
| Enable VNC (remote desktop viewer) support.
|}


{{fancyimportant|Depending on desktop environment, some USE flags may already be set or unset. Set USE flags as per '''Recommended''' column when unset.}}
== Guest OS Installation ==
{{note|If you're using a windows host use generic x86_64 funtoo stages.}}
=== Install Guest Additions ===
VirtualBox '''Guest Additions''' is a collection of applications, libraries and kernel modules/drivers that are installed in your Guest OS. These provide support for graphics, networking, and other features such as file transfer and Guest access to real physical devices such as a USB flash drive.


== Installation ==
==== Funtoo or Gentoo Linux Guests ====
Following the successful installation of you Funtoo Linux ''Guest OS'' (that is within a Virtual Machine), install the package {{c|app-emulation/virtualbox-guest-additions}}.
{{console|body=
###i## emerge --ask app-emulation/virtualbox-guest-additions
}}


{{fancyimportant|This tutorial deals with installation of source based package.}}
Next, add your Guest OS Users to the group {{c|vboxguest}}. For example, a user ''bob'' is added to {{c|vboxguests}}


<console>
{{console|body=
###i## echo ">=app-emulation/virtualbox-extpack-oracle-4.3.8 PUEL" >> /etc/portage/package.license/virtualbox
###i## gpasswd -a bob vboxguest
###i## emerge app-emulation/virtualbox
}}
</console>


Installation of <code>app-emulation/virtualbox</code> implies <code>app-emulation/virtualbox-extpack-oracle</code>. That is why PUEL license must be enabled.
Now add virtual-box-guest additions to the default runlevel of OpenRC.


== Guest Additions ==
{{console|body=
###i## rc-update add virtualbox-guest-additions default
}}


Make sure that user running X session belongs to <code>vboxguest</code> group. Create group when it does not exist. Add user to the group. That will enable :
Without having to reboot you can now start virtualbox-guest-additions within the Funtoo Guest OS with the command
{{console|body=
###i## rc
}}


*Shared clipboard;
==== Other GNU/Linux Guests ====
*Display resizing;
For other GNU/Linux, please refer to [https://www.virtualbox.org/manual/ch04.html#idp11274368 VirtualBox documentation].
*Seamless mode;
*Drag & Drop.


<console>
==== Microsoft Windows Guests ====
###i## groupadd vboxguest
VirtualBox Guest Additions are installed in a Windows Guest by mounting a virtual CD-ROM image (.iso) within the guest virtual machine.
###i## gpasswd -a ''user'' vboxguest
</console>


=== Windows Guests ===
In your Host OS Funtoo Linux, confirm the version of VirtualBox installed:
For {{c|app-emulation/virtualbox}}
{{console|body=
$##i## emerge --pretend --quiet app-emulation/virtualbox
[##g##ebuild##!g##  ##y##R##!y##  ] ##g##app-emulation/virtualbox-5.0.20##!g##
}}


You must enable <code>additions</code> USE flag when you intend to install Windows as a guest O/S. That will also install the ISO image containing all necessary Windows guest drivrers.
'''For VirtualBox versions 4.x (less than 5.0)'''


=== Linux Guests ===
Under the earlier chapter [[ Package:VirtualBox#Host_OS_Installation|Host OS Installation ]], install {{c|app-emulation/virtualbox}} (or {{c|app-emulation/virtualbox-bin}}) with the USE flag {{c|additions}} enabled. This will provide the ISO necessary for installing Guest Additions within a Microsoft Windows guest.


If you want to run Funtoo GNU/Linux as a guest O/S, emerge <code>app-emulation/virtualbox-guest-additions</code> in the Funtoo GNU/Linux guest O/S. For other GNU/Linux, please refer to [https://www.virtualbox.org/manual/ch04.html#idp11274368 VirtualBox documentation].
'''For VirtualBox versions 5.0 and above'''


== Post Installation ==
From version 5.0 the USE flag {{c|additions}} has been removed from the package app-emulation/virtualbox. The Guest Additions ISO required for a Windows-based Guest OS is now provided in a separate package, {{c|app-emulation/virtualbox-additions}}. Install this manually
{{console|body=
###i## emerge --ask app-emulation/virtualbox-additions
}}


You will not be able to run and use VirtualBox as a regular user if you are not a member of the <code>vboxusers</code> group.
{{warning|The package app-emulation/'''virtualbox-additions''' installs the Guest Additions ISO on your Host OS (Funtoo Linux). This is what you mount in a VM with Windows as a Guest OS. The package app-emulation/'''virtualbox-guest-additions''' is different. This is the Guest Additions that you install ''inside of a VM'' that happens to be a Guest OS of Funtoo Linux or Gentoo Linux.


<console>
The two packages perform different tasks so be sure to install the correct package!}}
###i## gpasswd -a ''user'' vboxusers
</console>


You must re-log so changes take effect.
Mount the Guest Additions ISO {{f|/usr/share/virtualbox/VBoxGuestAdditions.iso}} inside of your Microsoft Windows guest. Within Windows, browse to and install VirtualBox Guest Additions.


=== Loading Modules ===
== Headless ==
To be able to use VRDP you have to install {{c|app-emulation/virtualbox-extpack-oracle.}}
To verify if extpack installed and usable:
{{console|body=
###i## VBoxManage list extpacks
Extension Packs: 1
Pack no. 0:  Oracle VM VirtualBox Extension Pack
Version:      5.2.6
Revision:    120293
Edition:
Description:  USB 2.0 and USB 3.0 Host Controller, Host Webcam, VirtualBox RDP, PXE ROM, Disk Encryption, NVMe.
VRDE Module:  VBoxVRDP
Usable:      true
Why unusable:
}}


Required and optional modules must be loaded before launching VirtualBox. You can do that as root or upon boot.
Create a testvm using this command:
{{console|body=
###i## VBoxManage createvm --name "testvm"
Virtual machine 'testvm' is created.
UUID: 7b19dc85-2991-4e6a-b1e9-e8e6704e75b4
Settings file: '/root/.VirtualBox/Machines/testvm/testvm.vbox'
###i## VBoxManage registervm /root/.VirtualBox/Machines/testvm/testvm.vbox
###i## VBoxManage list vms
"testvm" {7b19dc85-2991-4e6a-b1e9-e8e6704e75b4}
}}


{{fancynote|<code>vboxnetadp</code> and <code>vboxnetflt</code> are optional.}}
Specify the hardware configurations of the VM (ioapic is needed for SMP):
{{console|body=
###i## VBoxManage modifyvm testvm --memory 1024 --cpus 4 --ioapic on --acpi on --boot1 dvd --nic1 bridged --bridgeadapter1 eth0 --ostype Linux_64
}}
{{note|Enabling the I/O APIC is required for 64-bit guest operating systems, especially Windows Vista; it is also required if you want to use more than one virtual CPU in a virtual machine.}}


==== As root ====
Create disk image:
{{console|body=
###i## VBoxManage createmedium --filename ~/VirtualBox\ VMs/testvm/testvm-disk01.vdi --size 10000
0%...10%...20%...30%...40%...50%...60%...70%...80%...90%...100%
Medium created. UUID: 0234cd8e-617a-435b-bed4-9aee99a0f34a
}}


<console>
Resize HDD to 50 GB.
###i## modprobe vboxdrv
{{console|body=
###i## modprobe vboxnetadp
###i## VBoxManage modifymedium ~/VirtualBox\ VMs/testvm/testvm-disk01.vdi --resize 50000
###i## modprobe vboxnetflt
0%...10%...20%...30%...40%...50%...60%...70%...80%...90%...100%
</console>
Medium created. UUID: 0234cd8e-617a-435b-bed4-9aee99a0f34a
}}
 
Add a SCSI controller:
{{console|body=
###i## VBoxManage storagectl testvm --name "SATA Controller" --add sata
}}
 
Attach install CD-ROM iso image and disk image:
{{console|body=
###i## VBoxManage storageattach "testvm" --storagectl "SATA Controller" --port 0 --device 0 --type hdd --medium /root/VirtualBox\ VMs/testvm/testvm-disk01.vdi
###i## VBoxManage storageattach "testvm" --storagectl "SATA Controller" --port 1 --device 0 --type dvddrive --medium /root/iso/systemrescuecd-x86-5.1.0.iso
}}
 
{{console|body=
###i## VBoxHeadless --startvm "testvm" -v on  &
}}


==== Upon boot OpenRC ====
The above command will launch the VM, as well as VRDE remote desktop server. The remote desktop server is needed to access the headless VM's console. By default, the VRDE server is listening on TCP port 3389.


Edit <code>/etc/conf.d/modules</code> :
After install you might want to remove the install CD from the drive like this.
{{console|body=
###i## VBoxManage storageattach "testvm" --storagectl "SATA Controller" --port 1 --device 0 --type dvddrive --medium none
}}


<pre>modules="vboxdrv vboxnetadp vboxnetflt"</pre>


==== Upon boot systemd ====
== Tips and Tricks ==
=== Share a generic virtual machine ===
Virtualbox supports exporting virtual machines to OVA format that can be subsequently loaded to vmware player, virtualbox, KVM/qemu, and microsoft's virtual machine management software.
* in virtualbox manager: select powered off virtual machine to export.
* ctrl + e to open the export virtual machine dialogue.
* review format settings, or just hit next.
* review appliance settings, and finish.


<console>
###i## echo 'vboxdrv' >> /etc/modules-load.d/virtualbox.conf
###i## echo 'vboxnetadp' >> /etc/modules-load.d/virtualbox.conf
###i## echo 'vboxnetflt' >> /etc/modules-load.d/virtualbox.conf
</console>


=== Kernel Driver ===
=== Configure Video within Funtoo Linux Guests ===
{{note|This section is being developed.}}
For Funtoo, Gentoo and other GNU/Linux ''Guest OS'' the [https://ww.wikipedia.org/wiki/X_Window_System X Window System] can be optimized for running within a VirtualBox virtual machine.
First, enable VBoxSVGA on virtual machine (there may be problems with VMSVGA as it needs the vmware driver).


Each time a new kernel is installed, <code>vboxdrv</code> kernel module must be recompiled. To ensure Portage knows about that, look at <code>/var/lib/module-rebuild/moduledb</code>. The following record must be present.
In a Funtoo Linux ''Guest OS'', modify the file {{f|/etc/portage/[[make.conf]]}} to include the following line
{{file|name=/etc/portage/make.conf|body=
VIDEO_CARDS="virtualbox"
}}
Then, reinstalling the xorg-server and xorg-drivers, will let X.Org work in "Guest OS"
{{console|body=
###i## emerge x11-base/xorg-server x11-base/xorg-drivers
}}


<pre>a:1:app-emulation/virtualbox-modules-''version''</pre>
=== Providing USB2, USB3, VRDP and/or PXE Boot ROM to Guest OS ===
{{note|This section is being developed.}}
Accept PUEL licence


Running <code>emerge @module-rebuild</code> will recompile VirtualBox driver after installation of new kernel.
emerge app-emulation/virtualbox-extpack-oracle


It is strongly recommended to install <code>sys-kernel<nowiki>/</nowiki>dkms</code>. This package keeps track of Linux kernel changes. It recompiles <code>vboxdrv</code> if necessary.
== Troubleshooting ==
=== EFI case ===
latest releases of virtualbox have a volatile NVRAM and this makes an EFI guest boot troublesome. To workaround this following steps required:
* remove any CD images (like systemrescuecd) from the VM settings
* start the VM
* wait for the countdown or press Esc immediately to reach the EFI shell
* type <code>edit startup.nsh</code> to open the full-screen editor
* enter <code>"fs0:\EFI\Funtoo Linux [GRUB]\grubx64.efi" </code> (including the double quotes, since the path contains spaces)
* press <code>CTRL-s</code> (maybe twice) to save and confirm saving by pressing Enter
* quit editor by pressing <code>CTRL-q</code>
* type <code>reset</code> to reboot the machine (or kill the VM and boot it using the GUI)
* wait for the countdown or press Enter to immediately run the startup.nsh script
EFI  guests now should properly boot.
reference reports: https://www.virtualbox.org/ticket/14279 and https://bugs.funtoo.org/browse/FL-2640


[[Category:HOWTO]]
An alternative workaround is to rename the grub EFI binary to take advantage of the EFI default boot behavior. During installation, when installing a boot-loader, do these additional steps:
[[Category:Tutorial]]
* Create a folder under <code>/boot/EFI</code> called <code>BOOT</code>
* Copy <code>/boot/EFI/Funtoo Linux [GRUB]/grubx64.efi</code> to <code>/boot/EFI/BOOT/BOOTX64.EFI</code>
[[Category:Ebuilds]]
[[Category:Virtualization]]
[[Category:Virtualization]]
{{EbuildFooter}}

Latest revision as of 14:19, June 7, 2024

VirtualBox

   Tip

We welcome improvements to this page. To edit this page, Create a Funtoo account. Then log in and then click here to edit this page. See our editing guidelines to becoming a wiki-editing pro.

VirtualBox is a free and open source virtualization 'hypervisor' for x86-based machines. VirtualBox can be installed and run on GNU/Linux and other Operating Systems.

The virtual machines provided by VirtualBox can be used to run a number of guest Operating Systems such as GNU/Linux, Windows, and others.

VirtualBox is available for Funtoo Linux on the arch profiles x86-32bit, x86-64bit and pure-64.

VirtualBox Homepage: https://www.virtualbox.org

Glossary of Terms

TermExplanation
Host OS An install of Funtoo Linux on physical hardware. VirtualBox will be installed to and run from here.
Guest OSThe Operating System that is run within a Virtual Machine provided by VirtualBox. The Guest OS could be Funtoo Linux, another GNU/Linux distribution, Windows, etc.
Guest AdditionsGuest Additions is a collection of applications, libraries and kernel modules/drivers that are installed in your Guest OS. These provide support for graphics, networking, and other features such as file transfer and Guest access to real physical devices such as a USB flash drive.

Host OS Installation

VirtualBox can be installed onto your Host OS - Funtoo Linux - using one of two packages: app-emulation/virtualbox or app-emulation/virtualbox-bin. The latter "-bin" package is a binary (precompiled) copy of VirtualBox. Installing this may be preferable on machines with low computing power.

For a typical install, run

root # emerge --ask app-emulation/virtualbox

Assign VirtualBox Users

Normal non-root users will not be able to use VirtualBox immediately after it has been installed. The Users that are to use VirtualBox must first become a member of the group vboxusers. For example, a user alice is added to vboxusers

root # gpasswd -a alice vboxusers

If currently logged in the User added to vboxusers must first log out before the changes will have an effect.

Load VirtualBox Kernel Modules

VirtualBox requires one or more Linux kernel modules to be loaded on the Host OS (Funtoo Linux) in order to function. As of VirtualBox version 5 these are provided by the package app-emulation/virtualbox-modules which is installed automatically (as a dependency) when you install app-emulation/virtualbox.

As root load these modules in a terminal

root # modprobe vboxdrv
root # modprobe vboxnetadp
root # modprobe vboxnetflt

Starting VirtualBox

  • create the loading script:
root #cat > /etc/vbox/vbox.cfg << EOF
INSTALL_DIR=/opt/VirtualBox
export QT_SCREEN_SCALE_FACTORS=1
export QT_SCALE_FACTOR=1
export QT_AUTO_SCREEN_SCALE_FACTOR=0
EOF

VirtualBox can be started from a terminal.

user $ VirtualBox

In a Desktop Environment, VirtualBox may also be run from a menu entry. Look for the names "VirtualBox" or "Oracle xVM VirtualBox" under menu categories "System" and/or "Emulator".

Funtoo Linux (Host OS) kernel updates

The VirtualBox kernel modules are compiled for the kernel present on the Host, Funtoo Linux. Each time that the Host kernel is updated or changed, the VirtualBox kernel modules must also be rebuilt.

As is typical for most kernel changes or updates, please run

root # emerge --ask @module-rebuild

before running VirtualBox under the new kernel.

If you wish to check that the VirtualBox kernel drivers will be rebuilt in this way, please examine the file /var/lib/module-rebuild/moduledb. For example, using the command grep

user $ grep virtualbox /var/lib/module-rebuild/moduledb
a:1:app-emulation/virtualbox-modules-5.0.20

Guest OS Installation

   Note

If you're using a windows host use generic x86_64 funtoo stages.

Install Guest Additions

VirtualBox Guest Additions is a collection of applications, libraries and kernel modules/drivers that are installed in your Guest OS. These provide support for graphics, networking, and other features such as file transfer and Guest access to real physical devices such as a USB flash drive.

Funtoo or Gentoo Linux Guests

Following the successful installation of you Funtoo Linux Guest OS (that is within a Virtual Machine), install the package app-emulation/virtualbox-guest-additions.

root # emerge --ask app-emulation/virtualbox-guest-additions

Next, add your Guest OS Users to the group vboxguest. For example, a user bob is added to vboxguests

root # gpasswd -a bob vboxguest

Now add virtual-box-guest additions to the default runlevel of OpenRC.

root # rc-update add virtualbox-guest-additions default

Without having to reboot you can now start virtualbox-guest-additions within the Funtoo Guest OS with the command

root # rc

Other GNU/Linux Guests

For other GNU/Linux, please refer to VirtualBox documentation.

Microsoft Windows Guests

VirtualBox Guest Additions are installed in a Windows Guest by mounting a virtual CD-ROM image (.iso) within the guest virtual machine.

In your Host OS Funtoo Linux, confirm the version of VirtualBox installed: For app-emulation/virtualbox

user $ emerge --pretend --quiet app-emulation/virtualbox
[ebuild   R   ] app-emulation/virtualbox-5.0.20

For VirtualBox versions 4.x (less than 5.0)

Under the earlier chapter Host OS Installation , install app-emulation/virtualbox (or app-emulation/virtualbox-bin) with the USE flag additions enabled. This will provide the ISO necessary for installing Guest Additions within a Microsoft Windows guest.

For VirtualBox versions 5.0 and above

From version 5.0 the USE flag additions has been removed from the package app-emulation/virtualbox. The Guest Additions ISO required for a Windows-based Guest OS is now provided in a separate package, app-emulation/virtualbox-additions. Install this manually

root # emerge --ask app-emulation/virtualbox-additions
   Warning

The package app-emulation/virtualbox-additions installs the Guest Additions ISO on your Host OS (Funtoo Linux). This is what you mount in a VM with Windows as a Guest OS. The package app-emulation/virtualbox-guest-additions is different. This is the Guest Additions that you install inside of a VM that happens to be a Guest OS of Funtoo Linux or Gentoo Linux.

The two packages perform different tasks so be sure to install the correct package!

Mount the Guest Additions ISO /usr/share/virtualbox/VBoxGuestAdditions.iso inside of your Microsoft Windows guest. Within Windows, browse to and install VirtualBox Guest Additions.

Headless

To be able to use VRDP you have to install app-emulation/virtualbox-extpack-oracle. To verify if extpack installed and usable:

root # VBoxManage list extpacks
Extension Packs: 1
Pack no. 0:   Oracle VM VirtualBox Extension Pack
Version:      5.2.6
Revision:     120293
Edition:
Description:  USB 2.0 and USB 3.0 Host Controller, Host Webcam, VirtualBox RDP, PXE ROM, Disk Encryption, NVMe.
VRDE Module:  VBoxVRDP
Usable:       true
Why unusable:

Create a testvm using this command:

root # VBoxManage createvm --name "testvm"
Virtual machine 'testvm' is created.
UUID: 7b19dc85-2991-4e6a-b1e9-e8e6704e75b4
Settings file: '/root/.VirtualBox/Machines/testvm/testvm.vbox'
root # VBoxManage registervm /root/.VirtualBox/Machines/testvm/testvm.vbox
root # VBoxManage list vms
"testvm" {7b19dc85-2991-4e6a-b1e9-e8e6704e75b4}

Specify the hardware configurations of the VM (ioapic is needed for SMP):

root # VBoxManage modifyvm testvm --memory 1024 --cpus 4 --ioapic on --acpi on --boot1 dvd --nic1 bridged --bridgeadapter1 eth0 --ostype Linux_64
   Note

Enabling the I/O APIC is required for 64-bit guest operating systems, especially Windows Vista; it is also required if you want to use more than one virtual CPU in a virtual machine.

Create disk image:

root # VBoxManage createmedium --filename ~/VirtualBox\ VMs/testvm/testvm-disk01.vdi --size 10000
0%...10%...20%...30%...40%...50%...60%...70%...80%...90%...100%
Medium created. UUID: 0234cd8e-617a-435b-bed4-9aee99a0f34a

Resize HDD to 50 GB.

root # VBoxManage modifymedium ~/VirtualBox\ VMs/testvm/testvm-disk01.vdi --resize 50000
0%...10%...20%...30%...40%...50%...60%...70%...80%...90%...100%
Medium created. UUID: 0234cd8e-617a-435b-bed4-9aee99a0f34a

Add a SCSI controller:

root # VBoxManage storagectl testvm --name "SATA Controller" --add sata

Attach install CD-ROM iso image and disk image:

root # VBoxManage storageattach "testvm" --storagectl "SATA Controller" --port 0 --device 0 --type hdd --medium /root/VirtualBox\ VMs/testvm/testvm-disk01.vdi
root # VBoxManage storageattach "testvm" --storagectl "SATA Controller" --port 1 --device 0 --type dvddrive --medium /root/iso/systemrescuecd-x86-5.1.0.iso
root # VBoxHeadless --startvm "testvm" -v on  &

The above command will launch the VM, as well as VRDE remote desktop server. The remote desktop server is needed to access the headless VM's console. By default, the VRDE server is listening on TCP port 3389.

After install you might want to remove the install CD from the drive like this.

root # VBoxManage storageattach "testvm" --storagectl "SATA Controller" --port 1 --device 0 --type dvddrive --medium none


Tips and Tricks

Share a generic virtual machine

Virtualbox supports exporting virtual machines to OVA format that can be subsequently loaded to vmware player, virtualbox, KVM/qemu, and microsoft's virtual machine management software.

  • in virtualbox manager: select powered off virtual machine to export.
  • ctrl + e to open the export virtual machine dialogue.
  • review format settings, or just hit next.
  • review appliance settings, and finish.


Configure Video within Funtoo Linux Guests

   Note

This section is being developed.

For Funtoo, Gentoo and other GNU/Linux Guest OS the X Window System can be optimized for running within a VirtualBox virtual machine. First, enable VBoxSVGA on virtual machine (there may be problems with VMSVGA as it needs the vmware driver).

In a Funtoo Linux Guest OS, modify the file /etc/portage/make.conf to include the following line

   /etc/portage/make.conf
VIDEO_CARDS="virtualbox"

Then, reinstalling the xorg-server and xorg-drivers, will let X.Org work in "Guest OS"

root # emerge x11-base/xorg-server x11-base/xorg-drivers

Providing USB2, USB3, VRDP and/or PXE Boot ROM to Guest OS

   Note

This section is being developed.

Accept PUEL licence

emerge app-emulation/virtualbox-extpack-oracle

Troubleshooting

EFI case

latest releases of virtualbox have a volatile NVRAM and this makes an EFI guest boot troublesome. To workaround this following steps required:

  • remove any CD images (like systemrescuecd) from the VM settings
  • start the VM
  • wait for the countdown or press Esc immediately to reach the EFI shell
  • type edit startup.nsh to open the full-screen editor
  • enter "fs0:\EFI\Funtoo Linux [GRUB]\grubx64.efi" (including the double quotes, since the path contains spaces)
  • press CTRL-s (maybe twice) to save and confirm saving by pressing Enter
  • quit editor by pressing CTRL-q
  • type reset to reboot the machine (or kill the VM and boot it using the GUI)
  • wait for the countdown or press Enter to immediately run the startup.nsh script

EFI guests now should properly boot. reference reports: https://www.virtualbox.org/ticket/14279 and https://bugs.funtoo.org/browse/FL-2640

An alternative workaround is to rename the grub EFI binary to take advantage of the EFI default boot behavior. During installation, when installing a boot-loader, do these additional steps:

  • Create a folder under /boot/EFI called BOOT
  • Copy /boot/EFI/Funtoo Linux [GRUB]/grubx64.efi to /boot/EFI/BOOT/BOOTX64.EFI