lavabit / robox

The tools needed to robotically create/configure/provision a large number of operating systems, for a variety of hypervisors, using packer.
626 stars 139 forks source link

Vagrant generic/alpine310: odd mount behaviour #154

Closed bristol-d closed 4 years ago

bristol-d commented 4 years ago

Hello,

I'm using vagrant with the following config file:

Vagrant.configure("2") do |config|
  config.vm.box = "generic/alpine310"
  config.vm.synced_folder ".", "/vagrant"
end

I'm trying to mount the shared folder for the user vagrant (uid=1000, gid=1000), but it mounts as root by default. Setting the options owner/group in the vagrantfile, or even mount_options: ["uid=1000", "gid=1000"] as suggested on the vagrant website doesn't help either.

Experimenting on the box, after umounting the shared folder again, mount -t vboxsf -o uid=1000 -o gid=1000 vagrant /vagrant doesn't work as expected (ignores the uid and gid option), but /sbin/mount.vboxsf -o uid=1000 -o gid=1000 vagrant /vagrant works and mounts the folder for the user.

Any idea what this could be? I know it's a busybox based distribution so maybe its mount command doesn't know about passing the uid/gid options on properly?

ladar commented 4 years ago

@bristol-d I think you're correct. This is an issue with the Busybox mount command not passing the option through to the mount.vboxsf command. In the short term, you can workaround the issue by adding the command you provided to the Vagrantfile provisioning step, rather than relying on the mount_options.

In the long term, I'd suggest opening a bug report with the vagrant project. It took a fair bit of lobbying, but Hashicorp finally merged an Alpine specific guest plugin into the Vagrant code base. Perhaps this plugin can be improved, so it can handle setting up shared folder mounts properly.

Alternatively, if there is something we can embed inside the box image itself, to make this work, please let me know and/or submit a pull request.

ladar commented 4 years ago

@bristol-d if the util-linux package has been installed, (apk add util-linux) do shared folders work properly for you?

bristol-d commented 4 years ago

Util-linux doesn't fix it sadly - I'm guessing it's a similar problem to this busybox bug that's been open since 2015.

For my own setup, I've managed to work around with the following lines in the vagrantfile:

config.vm.provision :shell, run: 'always', inline: <<-SHELL
    umount /vagrant
    /sbin/mount.vboxsf -o uid=1000 -o gid=1000 vagrant /vagrant
SHELL