linux - 如何为vagrant中尚不存在的用户挂载目录

标签 linux permissions vagrant chef-infra

我正在尝试使用共享文件夹机制在 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/

相关文章:

linux - ubuntu 和 ubuntu docker 镜像有什么区别?

linux - 命令行魔法

linux - 在 curl 获取的 2 个文件之间添加一个新行

java - requestPermissions() 没有调用 onRequestPermissionsResult()

django - Wagtail 页面中字段的权限

eclipse - Push 不允许使用 git-receive-pack

Haskell 编译器在编译修改后的 Alonzo 程序时失败

c++ - 这个开关 block 是如何执行的?

linux - Vagrant + Composer + Windows/nfs/git 错误

linux - Linux 上的 Vagrant synced_folder NFS 权限问题