您的位置:首页 > 其它

virtualbox下ubuntu共享文件夹自动挂载

2017-12-07 22:19 603 查看
1.若想删除挂载,可执行命令

umount -f /mnt/share
2.若想开机自动挂载,可以在 /etc/fstab 文件末添加一项
sharing /mnt/share vboxsf defaults 0 0


sharing /mnt/share vboxsf rw,gid=100,uid=1000,auto 0 0
3.为了方便,可以在桌面上新建一个文件,内容为:

#!/bin/sh sudo mount -t vboxsf sharing /mnt/share

以上资料是从网上摘录的,对于“开机自动挂载”模块,我试了好多遍都以失败告终,大部分网络资料都是说在 /etc/fstab 文件中追加
VirtualBox虚拟机文件夹共享挂载命令 “ sharing /mnt/share vboxsf defaults 0 0 ”,其实是错误的,

因为系统调用fstab的时候,Virtualbox的共享目录的模块还没有加载,所以每次加载都会失败,最终的解决方案如下:
在文件 /etc/rc.local 中(用root用户)追加如下命令

mount -t vboxsf sharing /mnt/share

最后重启系统,大功告成!!!

另外,在 VirtualBox 4.x 版本中,已有一个“自动挂载”功能,如下图所示:



再使用命令 mount ,得如下挂载信息:

[jianbao@localhost ~]$ mount
/dev/sda1 on / type ext3 (rw)
proc on /proc type proc (rw)
sysfs on /sys type sysfs (rw)
devpts on /dev/pts type devpts (rw,gid=5,mode=620)
tmpfs on /dev/shm type tmpfs (rw,rootcontext="system_u:object_r:tmpfs_t:s0")
/dev/sda2 on /home type ext3 (rw)
sharing on /mnt/share type vboxsf (uid=1000,gid=100,rw)
none on /proc/sys/fs/binfmt_misc type binfmt_misc (rw)
sunrpc on /var/lib/nfs/rpc_pipefs type rpc_pipefs (rw)
htdocs on /media/sf_htdocs type vboxsf (gid=501,rw)
sharing on /media/sf_sharing type vboxsf (gid=501,rw)

它自动把这些共享文件夹挂载到 /media/ ,目录下了,我想要说的是,这个挂载目录不是我想要的,

所以我没采用VirtualBox的自动挂载功能(因为挂载目录自己不可控)。
http://blog.csdn.net/u013394556/article/details/49894999
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: