我正在尝试使用共享文件夹机制在 vagrant 中挂载数据磁盘,该机制运行良好,只是该目录默认由 vagrant
所有,并且 tomcat6
可以不要写信给它。所以我想我可以使用以下方法在 vagrantfile 中设置磁盘的所有者:
config.vm.synced_folder "data/", "/data", owner: "tomcat6", group: "tomcat6"
但是 tomcat6
用户尚不存在,因为 tomcat 配方尚未运行,因此 vagrant 失败并显示:
Failed to mount folders in Linux guest. This is usually because
the "vboxsf" file system is not available. Please verify that
the guest additions are properly installed in the guest and
can work properly. The command attempted was:
mount -t vboxsf -o uid=`id -u tomcat6`,gid=`getent group tomcat6 | cut -d: -f3` data /data
mount -t vboxsf -o uid=`id -u tomcat6`,gid=`id -g tomcat6` data /data
The error output from the last command was:
stdin: is not a tty
id: tomcat6: no such user
id: tomcat6: no such user
uid= requires an argument (i.e. uid==<arg>)
现在我可以通过以世界写权限安装/data 来解决这个问题,但这对我来说似乎“错误”(即使在测试机器上)。
那么有什么方法可以让 vagrant 在我挂载磁盘之前为我创建一个新用户,或者让 Chef 稍后为我提供一个共享磁盘?
最佳答案
您可以切换到 nfs
同步提供程序,因为它支持具有未知 UID 的远程文件。请参阅https://docs.vagrantup.com/v2/synced-folders/nfs.html了解详情。
关于linux - 如何为vagrant中尚不存在的用户挂载目录,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/34439262/