Share VirtualBox folders in reverse? Guest-Host?

72

19

I'm familiar with the process of installing Guest Additions and sharing host folders with the guest, but is there a way to do the reverse?

I have an XP host and Ubuntu 10.10 guest, with VBox 4.0.2.

In other words, I'd like for the host to have direct access to (at least some of the) files inside the .vdi file.

Nate Parsons

Posted 2011-02-04T20:53:04.197

Reputation: 1 425

2It is possible to mount a vdi as a hard disk. Is this interesting for you ? (not possible while the guest is running) – harrymc – 2011-02-12T20:37:04.237

Answers

45

There is no way to do this with the Guest extensions, however, setup normal Ubuntu file sharing on your guest and you can access the files using the virtual network between the host and the guest. The OSE version of VirtualBox doesn't have shared folders, and this is the recommended sharing method for VirtualBox as described here. How-To Geek has a tutorial here on how to do it with Ubuntu specifically, and it applies to everything outside of home folders as well.

The network driver is smart enough not to send the traffic over the wire, but will still be used to communicate with the guest. I have a few virtual machines I run and use like this, both on Mac and Windows.

BinaryMisfit

Posted 2011-02-04T20:53:04.197

Reputation: 19 955

in this case, since a Windows box is involved, samba might be a good choice - but if you're connecting mac and linux or linux and linux, use nfs - steps at https://serverfault.com/questions/716350/mount-nfs-volume-on-ubuntu-linux-server-from-macos-client

– Ben Creasy – 2017-08-14T05:37:36.630

The same method, just using another protocol could be to use something like Dokan SSHFS. Depending on the use case and the configuration it may be more secure and better performing while allowing exploration (with proper rights) of the whole filesystem. – Lloeki – 2011-06-17T07:17:54.427

Here is a great tutorial on how to make this work with a Linux Guest and Windows Host using samba: http://superuser.com/questions/258026/using-samba-to-share-a-folder-from-a-linux-guest-with-a-windows-host-in-virtualb

– bjtilley – 2014-03-14T21:05:33.557

9

By default, the virtual machine has a NAT connection to the local network, meaning it doesn't have a "real" IP address of its own. If you instead set up a bridged connection, you can use regular file sharing methods from the virtual PC, e.g. Windows file sharing (including SAMBA under Linux/Unix/etc.) or NFS. Of course the VM would have to be running.

It's also possible to mount a VDI as a drive under the host OS, I don't know the details of how to do that on an XP host, and I believe you would have to shut down (rather than suspend) the guest OS to avoid hard drive corruption.

CarlF

Posted 2011-02-04T20:53:04.197

Reputation: 8 576

Depending on how you configured the Guest VM's network adapter, this is the best solution. The way Virtual Box shares a host's folder is by turning it into a network share. You can go the other way with it. Share the guest VM's folder and connect to it as a network share. Beware though, if you setup the Guest's Network adapter as internal only, or NAT, then this is trickier. Best that you set the Network adapter as "bridged," that way they are in the same subnet. – surfasb – 2011-02-13T02:20:27.927

1you can setup multiple interfaces, Have one as NAT and the other as HOST-ONLY. You can even fix the address on the host-only side to always have the same address for file sharing – nhed – 2013-03-21T12:50:25.210

2

There is a tricky solution:

  1. In Windows, install cygwin
  2. Use the same user names in both Windows and Linux
  3. In Windows, create directory $HOME/shared and make it a shared folder in VBox
  4. On your Linux create directories ~/shared and ~/shared_local and run: sudo /sbin/mount.vboxsf -o gid=1000,uid=1000 shared ~/shared
  5. Use rsync to synchronize your data in ~/shared with ~/shared_local.

You can use the same bash scripts in both Linux and Windows. You can access any data in your ~/shared from Windows and from Linux using the same path.

psihodelia

Posted 2011-02-04T20:53:04.197

Reputation: 747

0

This can be done. What you need to do is add an extra network card as host-only network and restart guest machine. During restart it'll prompt to install new network interface, answer yes to that. Once booted the guest machine can be accessed from the host using the IP of the guest. I suggest setting a static IP, 192.168.50.10, for example for the guest. Share out samba and you should be able to talk to it from the host machine. I did it and it's awesome.

Chung Tran

Posted 2011-02-04T20:53:04.197

Reputation: 1