首页 > 系统服务 > 详细

解决VMware中共享文件夹hgfs的权限问题

时间:2020-09-28 17:40:05      阅读:165      评论:0      收藏:0      [点我收藏+]

参考https://jarviswwong.com/ubuntu-vmware-hgfs-permissions-problem.html

问题:在VMware中的Ubuntu共享了目录发现/mnt/hgfs 一直都是root权限,而且hgfs没有写的权限 导致很多问题

网上试了很多方法发现都是无效的

比如:

  1. chmod 777 -R
  2. chown username:group /mnt/hgfs
  3. usermod -aG vboxsf username
  4. sudo chown username:username hgfs -R
  5. sudo chmod 777 ./hgfs

都是无效的

解决方法

看到https://jarviswwong.com/ubuntu-vmware-hgfs-permissions-problem.html之后解决了问题

1.如果之前已经挂载 hgfs,先取消挂载

sudo umount /mnt/hgfs

2.重新用以下命令挂载即可

sudo /usr/bin/vmhgfs-fuse .host:/ /mnt/hgfs -o allow_other -o uid=1000 -o gid=1000 -o umask=022

【注意】上面命令中的 uid 和 gid 需要根据 ubuntu 用户 uid 来决定,在home目录输入id 命令即可查询。

  1. UserName@UserName:~$ id
  2. uid=1000(UserName) gid=1000(UserName) 组=1000(UserName),4(adm),24(cdrom),27(sudo),30(dip),46(plugdev),116(lpadmin),126(sambashare)
  3. username

如果出现下面错误

  1. UserName@UserName:/mnt$ sudo /usr/bin/vmhgfs-fuse .host:/ /mnt/hgfs -o allow_other -o uid=1000 -o gid=1000 -o umask=022
  2. fuse: mountpoint is not empty
  3. fuse: if you are sure this is safe, use the ‘nonempty‘ mount option

把命令改为

sudo /usr/bin/vmhgfs-fuse .host:/ /mnt/hgfs -o nonempty -o allow_other -o uid=1000 -o gid=1000 -o umask=022

即可成功

3.查看权限ll或ls -l

  1. UserName@UserName:/mnt$ ll
  2. 总用量 25
  3. drwxrwxrwx 6 UserName root 4096 6月 9 10:17 ./
  4. drwxr-xr-x 25 root root 4096 6月 11 11:04 ../
  5. drwxrwxrwx 2 UserName root 4096 6月 9 10:17 cdr/
  6. drwxr-xr-x 2 UserName root 4096 6月 9 10:13 cdrom/
  7. drwxr-xr-x 2 UserName root 4096 6月 9 10:12 chrom/
  8. drwxr-xr-x 1 UserName UserName 4192 6月 18 11:11 hgfs/

可以看到已经修改成功【其中除了hgfs的其他文件夹的所有者是UserName,是之前在超级用户权限下用chmod -hR UserName /mnt修改导致的,但是改不了hgfs文件夹的所有者】

对比修改之前的

  1. drwxrwxrwx 6 UserName root 4096 6月 9 10:17 ./
  2. drwxr-xr-x 25 root root 4096 6月 11 11:04 ../
  3. drwxrwxrwx 2 UserName root 4096 6月 9 10:17 cdr/
  4. drwxr-xr-x 2 UserName root 4096 6月 9 10:13 cdrom/
  5. drwxr-xr-x 2 UserName root 4096 6月 9 10:12 chrom/
  6. dr-xr-xr-x 1 root root 4192 6月 18 10:48 hgfs/
  7.  

可以看到已经成功修改了hgfs的权限

重启发现权限又变回去,需要设置开机自动挂载

sudo vim /etc/fstab //打开配置文件

 设置开机自动挂载

.host:/ /mnt/hgfs             fuse.vmhgfs-fuse   allow_other,uid=1000,gid=1000,umask=022   0 0

重启发现开机就权限就是username了

解决VMware中共享文件夹hgfs的权限问题

原文:https://www.cnblogs.com/lidabo/p/13745888.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!