[Wiki][VirtualBox] Installation, USB devices and Shared folders

virtualbox

#1

HOST Installation and preparation

Packages to be installed

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

Install VirtualBox, host modules and guest iso

Your kernel is found using the uname command

$ uname -r
4.19.0-1-MANJARO

Another way to get the version directly usable in an install command is this excellent snippet by @tbg

echo linux$(uname -r| grep -o -E '[0-9]+' | head -n 2 | sed 'N;s/\n//')

The correct packages can then be installed using this command line

pamac install virtualbox linux$(uname -r| grep -o -E '[0-9]+' | head -n 2 | sed 'N;s/\n//')-virtualbox-host-modules virtualbox-guest-iso

Install extension pack

The extension pack is in AUR repo.

pamac build virtualbox-ext-oracle

Preparation

Your host user must be member of the group vboxusers

sudo gpasswd -a $USER vboxusers

Log off to make the change registered.


USB devices

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.

You may need to configure your USB to USB-3 if you have such controller. This is done in the USB Settings menu item.

:no_entry: Don’t transfer your mouse or keyboard.
:no_entry: Don’t add filters for your USB devices.


Shared folders

Shared folders require a litte more configuration to work both on the host and in the guest. What needs to be done in the guest is a little different depending on the guest operation system.

VirtualBox HOST

Setup the shared folder(s)

On the host locate the Settings section in VirtualBox GUI.

Make the folders Permanent and Automount.

: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 from spreading to your host.

VirtualBox GUEST requirements

  • guest utilities

Start the guest

Continue with the appropriate guest section

MANJARO GUEST

Packages to be installed

  • VirtualBox kernel modules
  • VirtualBox guest utilities

The kernel modules and utilities is installed from the official repos. We will use the same snippet as above to ensure we have modules for the current running kernel

pamac install virtualbox-guest-utils linux$(uname -r| grep -o -E '[0-9]+' | head -n 2 | sed 'N;s/\n//')-virtualbox-guest-modules

OTHER LINUX GUEST

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…

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

./runasroot.sh

LINUX GUEST Configuration

In the running guest - add the guest user to the group vboxsf.

sudo gpasswd -a $USER vboxsf

Enable vboxservice

sudo systemctl enable --now vboxservice

Mounting the shared folders

On guest system you need to create the mount folder manually

sudo mkdir /media

After reboot your shared folders is now available on the guest in the path

/media/sf_$your_shared_folder_name

Mount in guest user’s home

If you prefer your folders mounted in the guest users home folder you can do so by means of this script. Run the script on the guest after login.

Linux guest script for shared folders

Create folders to mimic your shared folder names.

Create a file in your home folder:

touch ~/vboxmount.sh
chmod +x ~/vboxmount.sh

Edit the file and add the following content and save it.

#!/bin/sh
#-----------------------------------------------------------------------------
# Discover VirtualBox shared folders and mount them if it makes sense
# Folders with the same name must exist in the $USER home folder
#-----------------------------------------------------------------------------

if  !  type  VBoxControl  > /dev/null;  then
  echo  "VirtualBox Guest Additions NOT found"  > /dev/stderr
  exit 1
fi

MY_UID="$(id -u)"
MY_GID="$(id -g)"

( set -x;  sudo  VBoxControl  sharedfolder  list; )  |  \
grep      '^ *[0-9][0-9]* *- *'                      |  \
sed  -e 's/^ *[0-9][0-9]* *- *//'                    |  \
while  read  SHARED_FOLDER
do
  MOUNT_POINT="$HOME/$SHARED_FOLDER"
  if  [ -d "$MOUNT_POINT" ];  then
    MOUNTED="$(mount  |  grep  "$MOUNT_POINT")"
    if  [ "$MOUNTED" ];  then
      echo  "Already mounted :  $MOUNTED"
    else
      (
        set -x
        sudo  mount  -t vboxsf  -o "nosuid,uid=$MY_UID,gid=$MY_GID"  "$SHARED_FOLDER"  "$MOUNT_POINT"
      )
    fi
  fi
done

WINDOWS GUEST Configuration

Start the Windows guest.

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

Install the guest additions and install additions to the Windows system.

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


VirtualBox: Drag and Drop Windows 10 to Manjaro
Virtualbox with Archlinux on Manjaro
Virtualbox shared folders bug?
[SOLVED] Virtualbox - USB <no devices available>
Manjaro as a Virtualbox Guest: additions from ISO or packages?
Help with configuring Oracle Virtualbox in Mate
Widespread VirtualBox Shared Folders breakage with [Stable Update] 2019-01-17
Virtual Box; Host: Windows 10 Guest: Manjaro 18
Virtualbox not automounting shared folder in guest (Manjaro KDE v18.0.2)
Failed to start kernel module
Question about dual-booting
[SOLVED] My wlp2s0 device is missing
Oracle VM Virtual Box and USB [Solved]
Virtulbox - Host W10 / Guest Manjaro KDE - Share Folders
Virtulbox - Host W10 / Guest Manjaro KDE - Share Folders
Error in VirtualBox
Widespread VirtualBox Shared Folders breakage with [Stable Update] 2019-01-17
#4

Thank you so much. Was very useful.