VirtualBox shared folders

From Alpine Linux

3.8 and newer

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

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 "http://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.