[root tip] [How To] VirtualBox - Installation - USB - Shared Folder

Difficulty: ★★☆☆☆

Installation, USB and Shared folders

It is recommended to read the VirtualBox article on the Wiki or the VirtualBox End-user documentation.

Host Packages and Installation

Packages to be installed on a host system

  • VirtualBox
  • VirtualBox Host Modules

The following components are optional - it depends on your use-case

  • VirtualBox Guest Additions ISO (non Arch(-based) Linux or Windows)
  • Oracle VirtualBox Extension Pack (provides optional functionality)

System Firmware

Before you install - reboot to your system and ensure you have enabled virtual extensions in your systems firmware.

$ systemctl reboot --firmware-setup

Installation

Your current active kernel is found using the mhwd-kernel command

$ mhwd-kernel -li

Install virtualbox with the required kernel modules matching the output from your system.

$ pamac install virtualbox linux$VERSION-virtualbox-host-modules

You need remember to install kernel modules for every kernel installed on which you intend to use VirtualBox.

host modules vs. dkms

If you choose to make the host modules available using dkms - remember to install the headers for every kernel on your system.

Load kernel modules

Prior to using VirtualBox kernel modules must be loaded. Either restart your system or load it manually.

The command to (re)load VirtualBox kernel modules on Manjaro is

$ sudo vboxreload

If you fail to load the kernel modules VirtualBox will open a window prompting you to run either

  • /sbin/rcvbox
  • /sbin/vboxconfig

These commands are for other operating systems and does not exist on Manjaro.

Basic VM configuration

For the amount of RAM need - look at the size of the ISO you intend to boot from.
If the ISO is 3GB you will need minimum 4GB RAM

The chosen default display type for any Linux is VMSVGA and this will be good for most distributions including Manjaro.

General

  • Advanced
    • Shared Clipboard (handy)
    • Drag’n’Drop (don’t work)
  • System
    • Motherboard
      • Base Memory 4 GB
      • Untick Floppy
      • Tick Enable EFI
      • Hardware Clock UTC
        • Linux guest - ticked
        • Windows guest - unticked
  • Processor and Disk
    • 2 processors
    • 30G virtual disk

Display

  • VMSVGA
    • optional select 3D
  • 128MB

MANJARO GUEST

installation

Graphic drivers are included with the kernel and Manjaro installer will use mhwd to install the kernel modules.

Install the guest utilities

$ sudo pacman -Syu virtualbox-guest-utils

Configuration

In the running guest - add the user to vboxsf group. This group membership is required to be able to access folders shared using the VirtualBox shared folder utility. The environment variable $USER translates to the current logged in user.

$ sudo gpasswd -a $USER vboxsf

Enable the vboxservice. The service loads the required modules when run.

$ sudo systemctl enable --now vboxservice

LINUX Shared folders

Shared folders requires extra configuration of host and guest. What needs to be done in the guest is a little different depending on the guest operation system. The following works for Manjaro.

Transient folders only persist in this VM session. Your Vbox VMM session runs under your credentials so it is your credentials that are used for access control from the guest VM to the shared folders. If you are running guest applications that you don’t trust then don’t use shared folders
forum.virtualbox.org

Follow the link to read more about shared folders in the VirtualBox manual.

Host Configuration

  • On the host locate the Settings section in VirtualBox GUI
  • Shared Folders tab
  • Add a shared folder
  • Select the Automount option

:information_source: Set the folders to Read-only if you plan to use Windows and want to browse insecure websites and other insecure activities. Doing so will prevent an eventual malware/ransomware from spreading to your host.

Guest mounting

Ensure your guest system user is member of vboxsf group.

$ groups
sys network power lp wheel $USER
$ sudo gpasswd -a $USER vboxsf

Log out or restart the guest to activate the group membership.

Previously on Arch based distributions the shared folder feature could be a hit or miss and thus we have had various tips on how to use shared folders - the obsolete tips has been removed.

The current state of VirtualBox shared folders is pretty good as a share (without a defined mountpoint) is mounted at

/media/sf_sharename

It is possible to mount the folders manually should it be necessary

$ sudo VBoxControl sharedfolder list --automount

The folders can be accessed using /media/sf_sharename

VirtualBox extensions

The extension pack is a proprietary set of extensions providing extra functionality to VirtualBox like USB2 and USB3 passthrough.

:information_source: To use this extended functionality your host user must be member of the group vboxusers.

The variable $USER below translates to - on the host - the current logged in username.

$ sudo gpasswd -a $USER vboxusers

Log off to register the change.

Functionality provided by the extension pack

  • Oracle Cloud Infrastructure integration
  • USB 2.0 and USB 3.0 Host Controller
  • Host Webcam
  • VirtualBox RDP
  • PXE ROM
  • Disk Encryption
  • NVMe

You only need this if you are going to use the above functionality provided and it is not required for VirtualBox to function.

As noted by VirtualBox it important you are using the extension pack matching your installed version of VirtualBox

Please install the same version extension pack as your installed version of VirtualBox.
Downloads – Oracle VM VirtualBox

As suggested in a comment below (thank you @j77h) - check your version - as of 2024-03-12T23:00:00Z

 $ vboxmanage --version
7.0.14r161095

Install using AUR

The extension pack’s PKGBUILD is provided from AUR so we use Pamac to build and install it. Remember to match your VirtualBox version

$ pamac search virtualbox-ext-oracle

Locate the needed extension pack

$ pamac build virtualbox-ext-<your-decision>

If you cannot locate the correct version then download the extension using below link.

Download from VirtualBox

Download the extensions package from below link - remember to match your VirtualBox version.

Sometimes the stable branch of Manjaro is not in line with AUR - in this case you need locate the matching extension pack manually.

The extension .vbox-extpack is a registered mime extension so just open the file and VirtualBox will install the extension pack. Provide your password when asked.

Using USB passthroug

Advanced configuration requires the extension pack to be installed. You can configure USB passthrough for USB-2 and USB-3. You need to configure your guest system to use USB-3 if you have such controller. This is done in the USB Settings menu item. Do not attach any devices on this tab unless you are doing something advanced.

Attach a device

Access the DevicesUSB menu in VirtualBox Machine Window or USB menu item in the status bar. Select the USB device to mount in the virtual machine.
:warning: USB devices

  • To prevent data corruption on USB devices always sync and unmount USB devices safely.
  • Do not transfer your mouse or keyboard.
  • Do not add filters for your USB devices.

OTHER GUEST installation

Manjaro host installation

Sync the package virtualbox-guest-iso

sudo pacman -Syu virtualbox-guest-iso

For best results, Linux as well as Windows guests needs the guest utilities installed. Prefer to use the ISO image provided as other Linux distributions might not have the most recent version of the utilities.

When you have installed the packages continue with Linux Guest Configuration or Windows Guest Configuration.

LINUX GUEST Configuration

From the Devices menu of the VirtualBox Guest Window choose Insert Guest Additions CD Image…

:information_source: On some Linux systems it is required to open a terminal and execute the installer from CLI. Open a file manager, browse to the mounted ISO, use the file manager to launch a terminal then start the installer.

$ ./runasroot.sh

WINDOWS GUEST Configuration

From the Devices menu of the VirtualBox Guest Window choose Insert Guest Additions CD Image…

Insert the guest additions and run the installer in your Windows system.

Restart the guest to make the shared folders available using the Windows Explorer.

Troubleshooting screen issues

If you get issues setting the guest screen resolution, pay attention to the graphics driver selected for the virtual machine.

Opaque windows

Open Kvantum Manager, select Configure Active Theme and navigate to Compositing & General Look.

Either activate the Disable composite effects or activate Translucent windows. Chosing the latter option please ensure VirtualBox and VirtualBoxVM is included in the list of Opaque apps.

Fullscreen

Changing to fullscreen using the hotkeys - default Right Ctrlf depends on

  • graphics driver - VBoxSVGA
  • Manjaro guest needs vboxservice enabled and running
    The resize of the screen sometimes takes 5-10 seconds to adapt but if it don’t adapt - use the hotkey to switch back and forth one (1) time.

Blurred - Distorted - Unreadable dialogs on Windows

If you use Windows and you have unreadable/blank dialogs - disable 3D/2D in the virtual machine graphics section.

If your virtual machine display does not resize correct

  1. Your guest is Manjaro
    • Ensure your graphics driver is VBoxSVGA before installing Manjaro
    • Ensure you have enabled the vboxservice
  2. Your guest is Ubuntu
    • Ensure you have the latest available drivers installed in the guest.
  3. Your guest is Windows
    • Try reinstalling the guest utils using the ISO image provided.

The following is not consistent but may depend on your graphics driver.

  • If you click on the vm window’s maximize button or drag using the lower right corner, the vm may not recieve notification on the change in window size. You can expand the window by dragging a border in either direction to have the vm resize correct. Your window size will remembered so you don’t have to do it every time.

VirtualBox display issues

14 Likes

Should it be mhwd-kernel -li in the Installation part?

1 Like

May I suggest another point to add to this section?

The version of the extension pack in the AUR is sometimes ahead of the version of virtualbox in Manjaro, so it’s best to check before installing.
I do it with these commands:
vboxmanage --version
pikaur -S virtualbox-ext-oracle

Example:

[xxx]$ vboxmanage --version
6.1.14r140239
[xxx]$ pikaur -S virtualbox-ext-oracle
...
 virtualbox-ext-oracle                6.1.8-1       -> 6.1.14-1
:: Proceed with installation? [Y/n]

EDIT: since I first wrote this post, linux-aarhus added this to his post:

$ pamac search virtualbox-ext-oracle
virtualbox-ext-oracle-manjaro ...

Notice “virtualbox-ext-oracle-manjaro”.

Then I discovered that pikaur and yay can search too, eg :
$ pikaur -Ss virtualbox-ext-oracle
also brings up “virtualbox-ext-oracle-manjaro

If ‘virtualbox-ext-oracle-manjaro’ always has the right version,
then if you use it, the rest of this post is redundant.


While Manjaro was on 6.12, Arch and AUR were on 6.14,
so I did not install virtualbox-ext-oracle from AUR.
I did install it, this way:
Got the 6.12 ext pack from
https://www.virtualbox.org/wiki/Download_Old_Builds
then install it via
sudo vboxmanage extpack install --replace <name>.vbox-extpack

Actually, I did not myself use that command either, so i can’t guarantee that it works.
I found it only today, in https://forum.manjaro.org/t/unable-to-install-module-vboxhost-6-1-14-ose-for-kernel-5-4-64-1-manjaro-missing-kernel-headers/24504/4]

What I did use was the GUI, like this:
Open the GUI with sudo:
sudo /usr/lib/virtualbox/VirtualBox
then go into file > preferences > extensions, and it’s obvious what to do there.
Close that GUI, then open it the usual way (without sudo) before you try to use it.

1 Like

Thank You, that (the root tip) worked well: It is clear and easy to apply. Great!

A post was split to a new topic: Vmware player on Manjaro

Thank you for this tutorial.
I did not find any description here or in Manjaro-Wiki about bridged or host-only networking, as mentioned in the Arch-Wiki. Could you please advice how to do this or add it to your tutorial?

Manjaro has no intention of replicating what is available using the Arch Wiki.

Some questions has been asked multitude times and thus an article has been created to avoid answering the same question again and again.

Network connections for the virtual machine is usually not an issue but bridged networking is mentioned in the wiki article as a possibility when you need direct access to the hosts external network environment.

host-only networking is an advanced use case and you are encouraged to read up on it using the virtualbox documentation mentioned above or consult the Arch wiki.

A post was split to a new topic: BSOD’s on Windows 10 guest