将共享文件夹(vbox)挂载为另一个用户 [英] Mount shared folder (vbox) as another user

查看:409
本文介绍了将共享文件夹(vbox)挂载为另一个用户的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

很抱歉在这里提出这个问题,但是我尝试了serverfault,但是4天没有得到任何答复.

I'm sorry to ask this in here, but I tried serverfault and didn't get any answer for 4 days.

此处的相关问题: https://serverfault.com/questions/394197/mount-shared-folder-vbox-as-other-user

问题:

每次尝试启动ubuntu(10.04)时,我都试图挂载vbox共享文件夹.

I'm trying to mount my vbox shared folder every time my ubuntu (10.04) starts.

因此,我在/etc/init上添加了一个条目:

So, I added an entry on /etc/init with this:

description     "mount vboxsf Desktop"

start on startup

task
exec mount -t vboxsf Desktop /var/www/shared

似乎可以正常工作,除了所有文件均由"root"拥有,而且我没有在该文件夹上写的权限(chmod和chown都不起作用).

Seems to work, except by the fact that all the files are owned by "root", and I don't have permission to write on the folder (neither chmod nor chown seems to be working).

那么,如何使该共享文件夹下的所有文件归www-data用户/组所有?

So, how can I make all the files under this shared folder to be owned by www-data user/group?

ps .:我拥有一个自动共享文件夹的主要原因是,我可以从GUEST www文件夹上的主机中创建/编辑文件.

ps.: The main reason for me to have an automatic shared folder, is so I can create/edit files from the HOST on the GUEST www folder.

如果您对此有个更好的主意,则可以随意共享.而不是共享文件夹.

If you have a better idea for that, instead of sharing the folder, fell free to say.

推荐答案

好吧,当我遇到另一个与共享文件夹有关的问题时,我最终遇到了这个stackoverflow问题:

Well, while I was having another issue related with my shared folder, I ended up getting to this stackoverflow question: Shared folder in VirtualBox for Apache

它以两种方式帮助了我,似乎我需要的是uid和gid选项.

It helped me in 2 ways, and seems that what I need are those uid and gid options.

因此,要以另一个用户身份挂载共享文件夹,我将运行:

So, to mount a shared folder as another user, I would run:

mount -t vboxsf SHARE_NAME /some/dir -o uid=48,gid=48

另外,要查看您的 www-data gid uid 是什么,只需运行id www-data.

Also, to see what are your www-data's gid and uid, just run id www-data.

如果您还需要更改已安装文件的权限,只需在选项中添加"dmode",如下所示:

If you also need to change the permissions on the mounted files, just add "dmode" to the options, as:

sudo mount -t vboxsf SHARE_NAME-o rw,dmode=777,gid=GROUP_ID,uid=USER_ID /path/on/guest

可用的选项是(在mount的帮助下):

The available options are (from mount's help):

rw         mount read write (default)
ro         mount read only
uid       =<arg> default file owner user id
gid       =<arg> default file owner group id
ttl       =<arg> time to live for dentry
iocharset =<arg> i/o charset (default utf8)
convertcp =<arg> convert share name from given charset to utf8
dmode     =<arg> mode of all directories
fmode     =<arg> mode of all regular files
umask     =<arg> umask of directories and regular files
dmask     =<arg> umask of directories
fmask     =<arg> umask of regular files

如果您需要它在系统初始化期间运行,只需在/etc/init/SOMETHING.conf中创建一个文件,如下所示:

And if you need it to run during the system init, just create a file on /etc/init/SOMETHING.conf, with something like this:

description     "SOME DESCRIPTION"

start on startup

task
exec mount -t vboxsf YOUR_SHARE_NAME /path/on/guest -o uid=1000,gid=33

这篇关于将共享文件夹(vbox)挂载为另一个用户的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆