Alpine VirtualBox Guest Additions doesn't allow for writing to shared folder (guest -> host)
Background: I built an Alpine Vagrant box based on https://github.com/rgl/alpine-vagrant, using the following code in the customize/run.sh after adding the edge repositories to /etc/apk/repositories:
apk update
apk add virtualbox-guest-additions virtualbox-guest-modules-virthardened
echo vboxguest >> /etc/modules
echo vboxsf >> /etc/modules
# Add ${BASE_USER} to the vboxsf group (needed for changing ownership of shared folders)
sed -i -r "s/vboxsf:x:([0-9]+):/vboxsf:x:\1:${BASE_USER}/" /etc/group
As a comparison, I used the official ubuntu/trusty64 Vagrant box to verify that the host configuration isn’t the source of the issue. Here are the two Vagrantfiles:
mc@loki:~/lab/ubuntubox$ cat Vagrantfile
Vagrant.configure("2") do |config|
config.vm.box = "ubuntu/trusty64"
config.vm.synced_folder ".", "/host"
end
mc@loki:~/lab/alpinebox$ cat Vagrantfile
Vagrant.configure("2") do |config|
config.vm.box = "alpinebox"
config.vm.synced_folder ".", "/host"
end
First, some verification that the vbox* modules have been loaded in each box:
mc@loki:~/lab/ubuntubox$ vagrant ssh -c "dmesg | grep vbox"
[ 4.553067] vboxvideo: module verification failed: signature and/or required key missing - tainting kernel
[ 4.553091] vboxvideo: Unknown symbol drm_open (err 0)
[ 4.553095] vboxvideo: Unknown symbol drm_poll (err 0)
[ 4.553098] vboxvideo: Unknown symbol drm_pci_init (err 0)
[ 4.553104] vboxvideo: Unknown symbol drm_ioctl (err 0)
[ 4.553107] vboxvideo: Unknown symbol drm_mmap (err 0)
[ 4.553110] vboxvideo: Unknown symbol drm_pci_exit (err 0)
[ 4.553112] vboxvideo: Unknown symbol drm_release (err 0)
[ 4.725681] vboxguest: misc device minor 57, IRQ 20, I/O port d020, MMIO at 00000000f0400000 (size 0x400000)
[ 4.725685] vboxguest: Successfully loaded version 4.3.36_Ubuntu (interface 0x00010004)
[ 11.263651] vboxvideo: Unknown symbol drm_open (err 0)
[ 11.263659] vboxvideo: Unknown symbol drm_poll (err 0)
[ 11.263665] vboxvideo: Unknown symbol drm_pci_init (err 0)
[ 11.263672] vboxvideo: Unknown symbol drm_ioctl (err 0)
[ 11.263677] vboxvideo: Unknown symbol drm_mmap (err 0)
[ 11.263681] vboxvideo: Unknown symbol drm_pci_exit (err 0)
[ 11.263686] vboxvideo: Unknown symbol drm_release (err 0)
[ 11.892856] vboxsf: Successfully loaded version 4.3.36_Ubuntu (interface 0x00010004)
Connection to 127.0.0.1 closed.
mc@loki:~/lab/alpinebox$ vagrant ssh -c "dmesg | grep vbox"
[ 5.926766] vboxguest: loading out-of-tree module taints kernel.
[ 5.930999] vboxguest: misc device minor 59, IRQ 20, I/O port d020, MMIO at 00000000f0400000 (size 0x400000)
[ 5.931000] vboxguest: Successfully loaded version 5.1.30 (interface 0x00010004)
[ 9.141127] vboxsf: Successfully loaded version 5.1.30 (interface 0x00010004)
Connection to 127.0.0.1 closed.
According to the VBox documentation, it’s necessary that the guest user is in the vboxsf group - that doesn’t seem to be needed in the ubuntu case though:
mc@loki:~/lab/ubuntubox$ vagrant ssh -c "id"
uid=1000(vagrant) gid=1000(vagrant) groups=1000(vagrant)
Connection to 127.0.0.1 closed.
mc@loki:~/lab/alpinebox$ vagrant ssh -c "id"
uid=1000(alpine) gid=1000(alpine) groups=10(wheel),101(docker),102(vboxsf),1000(alpine)
Connection to 127.0.0.1 closed.
On to the actual “write to host from guest” test case:
mc@loki:~/lab/ubuntubox$ vagrant ssh -c "touch /host/hello_from_guest"
Connection to 127.0.0.1 closed.
# No error
mc@loki:~/lab/alpinebox$ vagrant ssh -c "touch /host/hello_from_guest"
touch: /host/hello_from_guest: Permission denied
Connection to 127.0.0.1 closed.
I have tried all options suggested on https://www.vagrantup.com/docs/synced-folders/basic\_usage.html:
$ for file in Vagrantfile*; do echo -e "\n$file:"; cat $file; done
Vagrantfile.synced_folder:
Vagrant.configure("2") do |config|
config.vm.box = "alpinebox"
config.vm.synced_folder ".", "/host"
end
Vagrantfile.synced_folder_owner_group:
Vagrant.configure("2") do |config|
config.vm.box = "alpinebox"
config.vm.synced_folder ".", "/host", owner: "alpine", group: "alpine"
end
Vagrantfile.synced_folder_owner_group_uid1000gid1000:
Vagrant.configure("2") do |config|
config.vm.box = "alpinebox"
config.vm.synced_folder ".", "/host", owner: "alpine", group: "alpine", mount_options: ["uid=1000", "gid=1000"]
end
Vagrantfile.synced_folder_mount_options_dmode775fmode664:
Vagrant.configure("2") do |config|
config.vm.box = "alpinebox"
config.vm.synced_folder ".", "/host", owner: "alpine", group: "alpine", mount_options: ["dmode=775,fmode=664"]
end
..but without success, i.e., the alpine guest is not able to write to the folder mounted on the host.
Have I missed something, or is this a bug in the virtualbox-guest-additions / virtualbox-guest-modules-virthardened package?
And for clarity:
mc@loki:~/lab/alpinebox$ vagrant ssh -c "cat /etc/alpine-release"
3.7.0
Connection to 127.0.0.1 closed.
(from redmine: issue id 8629, created on 2018-03-08)