VirtualBox/SharedFolders


Introduction

This explains how to share files and folders (directories) between host and guest. (Files are shared over a network, in other words, you access remote files. For virtual machines, the network between host and guest is virtual since they are on the same real machine. But the steps you take are similar to setting up file sharing over real networks.)

Required: Virtualbox Guest Additions

Before sharing folders, you must install Guest Additions. For instructions on how to do this, see Guest Additions.

Creating a shared folder

  • Create a folder on the Host computer (ubuntu) that you would like to share, for example ~/share

  • Boot the Guest operating system in VirtualBox.

  • Select Devices -> Shared Folders...

  • Choose the 'Add' button.
  • Select ~/share

  • Optionally select the 'Make permanent' option

Prepare the folder

Linux

With a shared folder named share, as above, the folder can be mounted as the directory ~/host with the command

sudo mount -t vboxsf -o uid=$UID,gid=$(id -g) share ~/host

Windows

On the Windows Guest, run

net use x: \\vboxsvr\share

Now anything placed in this folder should be visible from the host in the ~/share folder.

Troubleshooting

This can be done more generically with the following:

sharename="whatever.you.want.to.call.it"; 
sudo mkdir /mnt/$sharename
sudo chmod 777 /mnt/$sharename
sudo mount -t vboxsf -o uid=1000,gid=1000 $sharename /mnt/$sharename
ln -s /mnt/$sharename $HOME/Desktop/$sharename

For the above command if you get the following error:

mount: unknown filesystem type 'vboxsf'

Then just change the vboxsf to vboxfs

If you want to have it mount automatically upon each boot, put the mount command in /etc/rc.local Debian distros (e.g. Ubuntu 10.04 and later) HOWTO Use Shared Folders

See Section 4.4 "Folder Sharing" in the VirtualBox documentation.

Note: if you want to mount the directory as owned and writable only by root, omit the  -o uid=1000,gid=1000  option to the mount command

/sbin/mount.vboxsf: mounting failed with the error: Protocol error

The above error could be one of the following.

The name was not valid

Make sure you specified the right name on the bash commands. If the guest machine is expecting "share" (as we did in the Prepare Host section) and you wrote

sharename="donotshare"
sudo mkdir /mnt/$sharename 
sudo chmod 777 /mnt/$sharename 
sudo mount -t vboxsf -o uid=1000,gid=1000 $sharename /mnt/$sharename 
ln -s /mnt/$sharename $HOME/Desktop/$sharename

it will not work.

Ubuntu 10.04 host

Note: Running on Ubuntu 10.04 host and Mint 14 as virtual system, the system would not accept a ~/share. It complained that it was not an absolute address. I entered /home/jim/share and it worked fine.

e. g.

  • Create a folder on the Host computer (ubuntu) that you would like to share, for example ~/share

  • Boot the Guest operating system in VirtualBox.

  • Select Devices -> Shared Folders...

  • Choose the 'Add' button.
  • Select '/home/<user>/share' for Folder Path

  • Select 'share' for Folder Name
  • Optionally select the 'Make permanent' option
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值