完美解决vmware上Ubuntu22.04共享文件夹问题,亲测有效
可以看到已经修改成功【其中除了hgfs的其他文件夹的所有者是UserName,是之前在超级用户权限下用chmod -hR UserName /mnt修改导致的,但是改不了hgfs文件夹的所有者】【注意】上面命令中的 uid 和 gid 需要根据 ubuntu 用户 uid 来决定,在home目录输入id 命令即可查询。VMshare是自己设置的文件夹名称,/mnt/hgfs挂载点,fuse.vmh
一、如果你在此之前安装过官方的vmtool或者旧版本的open-vm-tools最好先卸载干净
1 sudo vmware-uninstall-tools.pl
2 sudo apt-get remove open-vm-tools
3 sudo apt-get remove --auto-remove open-vm-tools
4 sudo apt-get purge open-vm-tools
5 sudo apt-get purge --auto-remove open-vm-tools
二、设置共享文件夹
三、安装open-vm-tools
1 sudo apt install open-vm-tools*
四、挂载文件夹
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 命令即可查询。
- UserName@UserName:~$ id
- uid=1000(UserName) gid=1000(UserName) 组=1000(UserName),4(adm),24(cdrom),27(sudo),30(dip),46(plugdev),116(lpadmin),126(sambashare)
- username
如果出现下面错误
- UserName@UserName:/mnt$ sudo /usr/bin/vmhgfs-fuse .host:/ /mnt/hgfs -o allow_other -o uid=1000 -o gid=1000 -o umask=022
- fuse: mountpoint is not empty
- 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
- UserName@UserName:/mnt$ ll
- 总用量 25
- drwxrwxrwx 6 UserName root 4096 6月 9 10:17 ./
- drwxr-xr-x 25 root root 4096 6月 11 11:04 ../
- drwxrwxrwx 2 UserName root 4096 6月 9 10:17 cdr/
- drwxr-xr-x 2 UserName root 4096 6月 9 10:13 cdrom/
- drwxr-xr-x 2 UserName root 4096 6月 9 10:12 chrom/
- drwxr-xr-x 1 UserName UserName 4192 6月 18 11:11 hgfs/
可以看到已经修改成功【其中除了hgfs的其他文件夹的所有者是UserName,是之前在超级用户权限下用chmod -hR UserName /mnt修改导致的,但是改不了hgfs文件夹的所有者】
对比修改之前的
- drwxrwxrwx 6 UserName root 4096 6月 9 10:17 ./
- drwxr-xr-x 25 root root 4096 6月 11 11:04 ../
- drwxrwxrwx 2 UserName root 4096 6月 9 10:17 cdr/
- drwxr-xr-x 2 UserName root 4096 6月 9 10:13 cdrom/
- drwxr-xr-x 2 UserName root 4096 6月 9 10:12 chrom/
- dr-xr-xr-x 1 root root 4192 6月 18 10:48 hgfs/
可以看到已经成功修改了hgfs的权限
重启发现权限又变回去,需要设置开机自动挂载
sudo vim /etc/fstab //打开配置文件
设置开机自动挂载
.host:/ /mnt/hgfs fuse.vmhgfs-fuse allow_other,uid=1000,gid=1000,umask=022 0 0
重启发现开机就权限就是username了
参考资料:
更多推荐
所有评论(0)