[HowTo] VirtualBox - Installation, USB, Shared folders

VirtualBox - Installation, USB, Shared folders

Topics Covered

  1. 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. Linux Guest Configuration
  9. Linux Shared Folders
  10. Troubleshooting Screen Issues
  11. Windows Guest Configuration

1. 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 -li
linux52

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

$ pamac install virtualbox linux52-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.

$ sudo vboxreload

2. Basic Host configuration

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

  • VBoxSVGA
  • 128MB
  • Enable 3D

4. VirtualBox extensions

The extension pack is a proprietary set of extensions providing useful functionality to VirtualBox like USB2 and USB3 passthrough. The extension pack's PKGBUILD is provided from AUR so we use Pamac to build and install it.

$ pamac build virtualbox-ext-oracle

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 and the library needed to share folders, clipboard etc.

No other packages needs to be installed. Skip to the guest configuration section below. (Note: drag'n drop does not work)

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. LINUX 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 - required for screen sizes and shared folders

$ 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.
  • 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/ransomware from spreading to your host.

Guest mounting

On most Linux guests 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

Guest mounting script

If you prefer your folders mounted in the guest user's home folder you can do so by means of this script.

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

Run the script on the guest after login.

10. Trouble shooting 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.

Fullscreen

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

  • graphics driver - VBoxSVGA
  • 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
  1. Your guest is Ubuntu
    • Ensure you have the latest available drivers installed in the guest.
    • Ensure you have enabled the vboxservice
  2. 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.

18 Likes
Virtualbox shared folders bug?
VirtualBox: Drag and Drop Windows 10 to Manjaro
Virtualbox with Archlinux on Manjaro
[SOLVED] Virtualbox - USB <no devices available>
Manjaro as a Virtualbox Guest: additions from ISO or packages?
Virtualbox not automounting shared folder in guest (Manjaro KDE v18.0.2)
Help with configuring Oracle Virtualbox in Mate
Virtualbox won't work. No /sbin/vboxconfig file
Manjaro under VirtualBox right guest addins
Manjaro on Virtualbox: screen size stuck at 800*600
Widespread VirtualBox Shared Folders breakage with [Stable Update] 2019-01-17
Widespread VirtualBox Shared Folders breakage with [Stable Update] 2019-01-17
no option for 1920x1080 in virtualbox manjaro gnome
[solved] Virtualbox: 3D acceleration will be removed with version 6.1.0
Question about dual-booting
Failed to start kernel module
Virtulbox - Host W10 / Guest Manjaro KDE - Share Folders
Virtulbox - Host W10 / Guest Manjaro KDE - Share Folders
[SOLVED] My wlp2s0 device is missing
Virtualbox fullscreen issue and more
Oracle VM Virtual Box and USB [Solved]
Virtual Box; Host: Windows 10 Guest: Manjaro 18
[solved] Virtualbox shared folder is empty (mount failed)
How to resolve VirtualBox "Kernel Driver Not Installed" using desktop environment....
Network fails in VirtualBox.
virtualbox usb support
Virtualbox guest additions on Ubuntu host and Manjaro guest
Manjaro Wiki on VirtualBox Guest Additions - Resolution/Mouse Issues
How to install VirtualBox
How to install virtualbox?
Virtualbox - USB <no devices available>
Unable to install VirtualBox guest additions
Manjaro freezing in virtual box Windows 7 host
Cannot install VirtualBox on Manjaro 18 xfce SOLVED
Persistent Storage on USB - How to Save Settings
GNOME Boxes - Accsess host filesystem via samba
VirtualBox - Kernel driver not installed (rc=-1908)
virtualbox won't start the VMs
Help me install Virtualbox
Installed Manjaro in VirtualBox with guest additions, no fullscreen.
Error in VirtualBox

Thank you so much. Was very useful.

Just wanted to note that I had the same issues at @Lorthirk in their thread about Guest Additions.

I don't know what the problem is but I followed the tutorial twice and still couldn't get full guest functionality on a Manjaro KDE install.

And similar to @Lorthirk I used the Guest Additions ISO successfully.

The tutorial is on using VirtualBox on Manjaro host.

Should your reply to this HowTo be understood that installing the virtualbox-guest-utils could not provide the needed funtionality but using the Guest Additions ISO did provide the functionality?

If this is the correct understanding it seems the guest utils package maybe missing something?

Since the virtualbox-guest-utils is package imported from the Arch repositories the $KERNEL-virtualbox-guest-modules maybe missing something?

mhwd-kernel is better IMHO.

$ mhwd-kernel -li
Currently running: 5.1.0-1-MANJARO (linux51)
The following kernels are installed in your system:
   * linux419
   * linux50
   * linux51
2 Likes

Yes, that was my post's intention. Sorry for not being clear!

I spent some more time testing and have been unable to successfully install the guest additions through virtualbox-guest-utils and the appropriate kernel modules.

I tried two different computers (both Manjaro hosts) with both the Xfce and KDE ISOs.

Mainly, I thought it was weird that something so (seemingly) straightforward was giving users a problem. Also I often recommend people try out Manjaro in a VM and obviously want it to work well for them! :grinning:

I couldn't find any mention of the issue on the Arch forum, so maybe there is just a user error somewhere.

Forum kindly sponsored by Bytemark