设为首页 收藏本站
查看: 1353|回复: 0

[经验分享] (4)ubuntu8访问windows共享目录1——VirtualBox Folder Sharing

[复制链接]

尚未签到

发表于 2015-10-12 11:58:28 | 显示全部楼层 |阅读模式
  本博客(http://blog.iyunv.com/livelylittlefish)贴出作者(三二一、小鱼)相关研究、学习内容所做的笔记,欢迎广大朋友指正!
  
  ubuntu8访问windows共享目录1——VirtualBox Folder Sharing
  
  ubuntu系统访问Windows系统的共享目录有多中方式,此文主要是利用VirtualBox Folder Sharing的功能实现共享。
  

  • 设置共享文件夹
ubuntu8虚拟机运行的窗口中,设备 --> 分配数据空间 菜单,添加一个共享文件夹,如下图。该例中,共享名称为linuxstudy

DSC0000.jpg


  • 挂载该共享文件夹
sudo mkdir /mnt/programming
sudo mount -t vboxsf linuxstudy /mnt/programming
其中"linuxstudy"是之前创建的共享文件夹的名称
若共享文件夹的名称与加载点名称相同,“mount -t vboxsf”命令不成功,但“mount.vboxsf”命令可以正确执行。

若要自动加载,不每次都手动加载,需在/etc/fstab中添加如下一项
Linuxstudy /mnt/programming vboxsf rw,gid=100,uid=1000,auto 0 0


  • 删除共享
sudo umount -f /mnt/programming




    root@yu28:/mnt# mount -t vboxsf linuxstudy /mnt/linuxstudy/
    /sbin/mount.vboxsf: mounting failed with the error: Protocol error
    root@yu28:/mnt# mount.vboxsf linuxstudy /mnt/linuxstudy/
    root@yu28:/mnt#
    root@yu28:/mnt# ls
    linuxstudy  programming
    root@yu28:/mnt# cd linuxstudy/
    root@yu28:/mnt/linuxstudy# ls
    aaaa.txt           procon              ProducerConsumer.txt  rwlock2.c    rwlock31.txt  rwlock3.c       testcallback
    figure             ProducerConsumer    rwlock                rwlock2.txt  rwlock32.txt  rwlocktest      testcallback.c
    foldersharing.jpg  ProducerConsumer.c  rwlock1               rwlock3      rwlock33.txt  rwlocktest.cpp
    root@yu28:/mnt/linuxstudy# umount -f  /mnt/linuxstudy/
    umount2: Device or resource busy
    umount: /mnt/linuxstudy/: device is busy.
            (In some cases useful info about processes that use
             the device is found by lsof(8) or fuser(1))
    root@yu28:/mnt/linuxstudy# cd ..
    root@yu28:/mnt# ls
    linuxstudy  programming
    root@yu28:/mnt# umount -f  /mnt/linuxstudy/
    root@yu28:/mnt#
    root@yu28:/mnt# ls
    linuxstudy  programming
    root@yu28:/mnt# cd linuxstudy/
    root@yu28:/mnt/linuxstudy# ls
    root@yu28:/mnt/linuxstudy#


reference:

4.6. Folder sharing

Shared folders allow you to access files of your host system from within the guest system, much like ordinary shares on Windows networks would -- except that shared folders do not need a networking setup. Shared folders must physically reside on the host and are then shared with the guest; sharing is accomplished using a special service on the host and a file system driver for the guest, both of which are provided by VirtualBox.

In order to use this feature, the VirtualBox Guest Additions have to be installed. Note however that Shared Folders are only supported with Windows (2000 or newer) guests and Linux guests.

To share a host folder with a virtual machine in VirtualBox, you must specify the path of that folder and choose for it a "share name" that the guest can use to access it. Hence, first create the shared folder on the host; then, within the guest, connect to it.

There are several ways in which shared folders can be set up for a particular virtual machine:

In the graphical user interface of a running virtual machine, you can select "Shared folders" from the "Devices" menu, or click on the folder icon on the status bar in the bottom right corner of the virtual machine window.

If a virtual machine is not currently running, you can configure shared folders in each virtual machine's "Settings" dialog.

From the command line, you can create shared folders using the the VBoxManage command line interface; see Chapter 8, VBoxManage reference. The command is as follows:

VBoxManage sharedfolder add "VM name" -name "sharename"  -hostpath "C:/test"

There are two types of shares:

VM shares which are only available to the VM for which they have been defined;

transient VM shares, which can be added and removed at runtime and do not persist after a VM has stopped; for these, add the -transient option to the above command line.

Shared folders have read/write access to the files at the host path by default. To restrict the guest to have read-only access, create a read-only shared folder. This can either be achieved using the GUI or by appending the parameter -readonly when creating the shared folder with VBoxManage.

Then, you can mount the shared folder from inside a VM the same way as you would mount an ordinary network share:


  • In a Windows guest, starting with VirtualBox 1.5.0, shared folders are browseable and are therefore visible in Windows Explorer. So, to attach the host's shared folder to your Windows guest, open Windows Explorer and look for it under "My Networking Places" -> "Entire Network" -> "VirtualBox Shared Folders". By right-clicking on a shared folder and selecting "Map network drive" from the menu that pops up, you can assign a drive letter to that shared folder.

Alternatively, on the Windows command line, use the following:
net use x: //vboxsvr/sharename


While vboxsvr is a fixed name (note that vboxsrv would also work), replace "x:" with the drive letter that you want to use for the share, and sharename with the share name specified with VBoxManage.


  • In a Linux guest, use the following command:

mount -t vboxsf [-o OPTIONS] sharename mountpoint

Replace sharename with the share name specified with VBoxManage, and mountpoint with the path where you want the share to be mounted (e.g. /mnt/share). The usual mount rules apply, that is, create this directory first if it does not exist yet.

Beyond the standard options supplied by the mount command, the following are available:
iocharset CHARSET

to set the character set used for I/O operations (utf8 by default) and
convertcp CHARSET
to specify the character set used for the shared folder name (utf8 by default).
The generic mount options (documented in the mount manual page) apply also. Especially useful are the options uid, gid and mode, as they allow access by normal users (in read/write mode, depending on the settings) even if root has mounted the filesystem.


             版权声明:本文为博主原创文章,未经博主允许不得转载。

运维网声明 1、欢迎大家加入本站运维交流群:群②:261659950 群⑤:202807635 群⑦870801961 群⑧679858003
2、本站所有主题由该帖子作者发表,该帖子作者与运维网享有帖子相关版权
3、所有作品的著作权均归原作者享有,请您和我们一样尊重他人的著作权等合法权益。如果您对作品感到满意,请购买正版
4、禁止制作、复制、发布和传播具有反动、淫秽、色情、暴力、凶杀等内容的信息,一经发现立即删除。若您因此触犯法律,一切后果自负,我们对此不承担任何责任
5、所有资源均系网友上传或者通过网络收集,我们仅提供一个展示、介绍、观摩学习的平台,我们不对其内容的准确性、可靠性、正当性、安全性、合法性等负责,亦不承担任何法律责任
6、所有作品仅供您个人学习、研究或欣赏,不得用于商业或者其他用途,否则,一切后果均由您自己承担,我们对此不承担任何法律责任
7、如涉及侵犯版权等问题,请您及时通知我们,我们将立即采取措施予以解决
8、联系人Email:admin@iyunv.com 网址:www.yunweiku.com

所有资源均系网友上传或者通过网络收集,我们仅提供一个展示、介绍、观摩学习的平台,我们不对其承担任何法律责任,如涉及侵犯版权等问题,请您及时通知我们,我们将立即处理,联系人Email:kefu@iyunv.com,QQ:1061981298 本贴地址:https://www.yunweiku.com/thread-125831-1-1.html 上篇帖子: centos 安装 virtualbox 下篇帖子: virtualbox中硬盘复制导致找不到eth0的解决办法
您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

扫码加入运维网微信交流群X

扫码加入运维网微信交流群

扫描二维码加入运维网微信交流群,最新一手资源尽在官方微信交流群!快快加入我们吧...

扫描微信二维码查看详情

客服E-mail:kefu@iyunv.com 客服QQ:1061981298


QQ群⑦:运维网交流群⑦ QQ群⑧:运维网交流群⑧ k8s群:运维网kubernetes交流群


提醒:禁止发布任何违反国家法律、法规的言论与图片等内容;本站内容均来自个人观点与网络等信息,非本站认同之观点.


本站大部分资源是网友从网上搜集分享而来,其版权均归原作者及其网站所有,我们尊重他人的合法权益,如有内容侵犯您的合法权益,请及时与我们联系进行核实删除!



合作伙伴: 青云cloud

快速回复 返回顶部 返回列表