VirtualBox shared folders

From Alpine Linux

3.11 and newer

Enable the Community repo in /etc/apk/repositories then:

Create a mount point and install libraries

mkdir -p /mnt/shared apk add virtualbox-guest-additions linux-virt reboot

Then mount the folder

modprobe -a vboxsf mount -t vboxsf vbox_shared /mnt/shared

vbox_shared is the 'Folder Name' you decided in the virtualbox gui

3.8 - 3.10

As of 3.8 release, simply enable the Community repo in /etc/apk/repositories then run:

apk add virtualbox-guest-additions virtualbox-guest-modules-virt

Reboot system

modprobe -a vboxsf mount -t vboxsf vbox_shared /mnt/outside

Permanent shares

To set up a permanent share, enable vboxsf module and mount at startup. Change vbox_shared to your foldername in Virtualbox dialog, maybe adjust the path /mnt/outside twice to your needs.

echo vboxsf > /etc/modules-load.d/vboxsf.conf rc-update add local default mkdir /mnt/outside echo mount -t vboxsf vbox_shared /mnt/outside > /etc/local.d/outside.start chmod +x /etc/local.d/outside.start

Reboot system

3.7 and previous

Install virtualbox-guest-additions and virtualbox-guest-modules-virthardened at first:

apk add virtualbox-guest-additions virtualbox-guest-modules-virthardened

The following error may occur:

ERROR: unsatisfiable constraints: virtualbox-guest-additions (missing): required by: world[virtualbox-guest-additions] virtualbox-guest-modules-virthardened (missing): required by: world[virtualbox-guest-modules-virthardened]

If the error occurs, make sure your alpine version is greater than v3.6 and alpine community repo is enabled:

echo "https://dl-cdn.alpinelinux.org/alpine/edge/community" >> /etc/apk/repositories

Update respository indexes from all remote repositories, then install guest modules and reboot:

apk update apk add virtualbox-guest-additions virtualbox-guest-modules-virthardened reboot

Goto Device > Shared Folders > Shared Folder Settings ... add a directory mapping like this:

Mount it to alpine:

mkdir /mnt/outside mount -t vboxsf vbox_shared /mnt/outside

which vbox_shared is your folder name and /mnt/outside is the mounting point.

After this step the following error may occur:

mount: mounting vbox_shared on /mnt/outside failed: No such device

If the error occurs, run command below:

modprobe -a vboxsf mount -t vboxsf vbox_shared /mnt/outside

And you will see /tmp/vbox_shared and /mnt/outside are connected.


P.S. Alpine will raise error "Invalid argument" if virtualbox-guest-additions is not installed when mounting drive.

VirtualBox will raise error "Guest Additions unavailable" if virtualbox-guest-modules-virthardened is not installed when adding shared path.