VirtualBox shared folders: Difference between revisions

From Alpine Linux
(+ permanent shares 3.17)
m (→‎3.7 and previous: Used pkg template and removed hyperlink to obsolete package from obsolete version.)
 
(5 intermediate revisions by 4 users not shown)
Line 1: Line 1:
{{todo|Need to update this article. I think the virtualbox-guest-modules-virt package has been obsoleted by linux-virt on 3.11 and later}}
== 3.11 and newer ==
Enable the Community repo in /etc/apk/repositories then:


== 3.8 and newer ==
Create a mount point and install libraries
{{Cmd|mkdir -p /mnt/shared
apk add virtualbox-guest-additions linux-virt
reboot}}
Then mount the folder
{{Cmd|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:
As of 3.8 release, simply enable the Community repo in /etc/apk/repositories then run:
{{Cmd|apk add virtualbox-guest-additions virtualbox-guest-modules-virt}}  
{{Cmd|apk add virtualbox-guest-additions virtualbox-guest-modules-virt}}  
Line 11: Line 21:
To set up a permanent share, enable vboxsf module and mount at startup.
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.
Change ''vbox_shared'' to your foldername in Virtualbox dialog, maybe adjust the path /mnt/outside twice to your needs.
{{Cmd|echo vboxf > /etc/modules-load.d/vboxsf.conf
{{Cmd|echo vboxsf > /etc/modules-load.d/vboxsf.conf
rc-update add local default
rc-update add local default
mkdir /mnt/outside
mkdir /mnt/outside
Line 20: Line 30:
== 3.7 and previous ==
== 3.7 and previous ==


Install [https://pkgs.alpinelinux.org/package/edge/community/x86/virtualbox-guest-additions virtualbox-guest-additions] and [https://pkgs.alpinelinux.org/package/edge/community/x86/virtualbox-guest-modules-virthardened virtualbox-guest-modules-virthardened] at first:
Install {{pkg|virtualbox-guest-additions}} and virtualbox-guest-modules-virthardened at first:


{{Cmd|apk add virtualbox-guest-additions virtualbox-guest-modules-virthardened}}
{{Cmd|apk add virtualbox-guest-additions virtualbox-guest-modules-virthardened}}
Line 34: Line 44:
If the error occurs, make sure your alpine version is greater than v3.6 and alpine community repo is enabled:
If the error occurs, make sure your alpine version is greater than v3.6 and alpine community repo is enabled:


{{Cmd|echo "http://dl-cdn.alpinelinux.org/alpine/edge/community" >> /etc/apk/repositories}}
{{Cmd|echo "<nowiki>https://dl-cdn.alpinelinux.org/alpine/edge/community</nowiki>" >> /etc/apk/repositories}}


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

Latest revision as of 15:14, 25 August 2023

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.