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

Difficulty: ★★☆☆☆

VirtualBox - Installation, USB, Shared folders

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

Topics Covered


  1. Host Packages and Installation
  2. Basic Host Configuration
  3. Basic VM Configuration
  4. Oracle VirtualBox Extensions
  5. Advanced VM Configuration
  6. Manjaro Guest Installation
  7. Other Linux Guest Installation
  8. Manjaro Guest Configuration
  9. Linux Shared Folders
  10. Troubleshooting Screen Issues
  11. Windows Guest Configuration
  12. Display issues

1. Host Packages and Installation


Packages to be installed

  • VirtualBox
  • VirtualBox Host Modules
  • VirtualBox Guest Additions ISO
  • Oracle VirtualBox Extension Pack

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 (@sueridgepipe note)

$ mhwd-kernel -li

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

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

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

Load kernel modules

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

VirtualBox might come with a window prompting you to run either

  • /sbin/rcvbox
  • /sbin/vboxconfig

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

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

$ sudo vboxreload

2. Basic Host configuration


:information_source: Your host user must be member of the group vboxusers. The variable $USER below translates to your current logged in username.

$ sudo gpasswd -a $USER vboxusers

Log off to register the change.

3. Basic VM configuration

General

Advanced

  • Shared Clipboard (handy)
  • Drag’n’Drop (don’t work)

System

Motherboard

  • Base Memory 2 to 4 GB
  • Untick Floppy
  • Tick Enable EFI
  • Hardware Clock UTC
    • Linux guest - ticked
    • Windows guest - unticked

Processor

  • 2 processors

Display

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

Use either

  • VMSVGA
    • optional select 3D
  • 128MB

Or

  • VBoxSVGA
  • 128MB

Using VBoxSVGA or VMSVGA is a choice. VBoxSVGA will make VirtualBox complain on invalid settings but using VMSVGA your VM will not resize to adapt to changes in window size.

If you want to be sure Manjaro guest will resize correct you must choose the VBoxSVGA display type and ignore the warning.

Selecting VBoxSVGA and 3D will reset your graphics to VMSVGA and 3D.

:manjaro: You can cheat VBox to use VboxSVGA and 3D

  • Initially create the VM using VMSVGA and 3D
  • Select the VM in VBoxManager
  • In the Display section click VMSVGA and change it to VBoxSVGA
  • Start the VM

4. VirtualBox extensions


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

Functionality provided is

  • 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.

$ vboxmanage --version
6.1.14r140239

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.

5. Advanced Guest Configuration


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.

6. MANJARO GUEST installation


Before installation ensure you are using VBoxSVGA graphics.

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

Install the guest utilities

$ sudo pacman -Syu virtualbox-guest-utils

7. OTHER LINUX GUEST installation


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.

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

8. MANJARO GUEST Configuration


In the running guest - add the user to vboxsf group. 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

9. 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.

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

After reboot you will need to mount the folders - please verify the folder /media exist - otherwise create it - but usually VirtualBox creates the folder.

$ sudo mkdir /media

Then use VBoxControl to mount the folders

$ sudo VBoxControl sharedfolder list --automount

The folders can be accessed using /media/sf_sharename

10. Troubleshooting screen issues


If you get issues setting the guest screen resolution, pay attention to the graphics driver selected for the virtual machine as noted by @Teek here and @sueridgepipe here.

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.

11. 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.

12. VirtualBox display issues


13 Likes
Virtualbox Kernel Driver
VirtualBox shared folder not automounting
Keyboard not working - Manjaro guest VirtualBox install
Unable to install module vboxhost/6.1.14_OSE for kernel 5.4.64-1-MANJARO: Missing kernel headers
VirtualBox VMs no longer can handle USB3?
Manjaro-Cinnamon Vmware - sudo apt install ubuntustudio-installer - What is the proper method?
“Failed to start VirtualBox Linux kernel module…” Error on boot (continued)
Virtualbox nightmare
VMWare free vs VBox for windows 10
Virtual Machine Manager Connection Failure
Can't load vanilla arch iso in virtualbox
VirtualBox fullscreen menu becomes totally transparent (but clickable)
Virtual Box cant find any phyisical sata drives
Virtualbox nightmare
[root tip] [How To] Legally use Windows in a Virtual Machine
Manjaro suddenly not booting
VirtualBox doesn't see USB devices
Virtualbox USB Devices Aren't Recognized?
(rc=-1912) The VirtualBox kernel modules do not match this version of VirtualBox
Trying to Run Virtual Box on Manjaro
Virtualbox can access host usb device after add the current user to vboxuser group how to fix it?
Can't copy and paste between windows 10 in vmware and manjaro
Virtualbox is not detecting my usb drives! Even with the extension pack installed!
Oracle Virtual Box critical error NS_ERROR_FAILURE (0x80004005)
Oracle VM error while starting my first VM
VirtualBox error in the last update
Bug in Matcha theme (Xfce, Kvantum) related to VirtualBox and solution
VirtualBox segfaulting against libX11.so.6 - how to debug?
Run Vm stored on Windows partition
Virtual box not working showing errors instead on trying to start virtual environment
VirtualBox: Correct Version ExtensionPack?
Manjaro in VirtualBox- how to mount the shared folder with host without using root
My install lags a lot
VBoxSVGA invalid settings
First steps guides
[Stable Update] 2021-02-28 - Kernels, Plasma 5.21.1, Frameworks 5.79, Firefox, Thunderbird, Python
Virtualbox Kali error
Virtualbox Kernel Driver
Installing virtual box to MATE 20.01 -module vboxdrv not found
Virtualbox, unable to browse or mount install disk
Manjaro-Manjaro Virtualbox Can't Use Bidirectional Drag-n-Drop?
Advice on running a Windows VM?
Can't connect USB in vm
RE: [root tip] VirtualBox - Installation - USB - Shared Folder
How to set up stable VMs via VirtualBox? (Manjaro host)
Kernel driver not installed (rc=-1908) virtualbox linux
Virtualbox does not start Windows VM anymore, kernel issue?
To install guest in Virtualbox
Issue with virtual machine
VirtualBox Error

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

2 Likes

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