88

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
  • 1,625

7 Answers7

52

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
  • 20,879
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
  • 8,872
2

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.

1

If you mean while the guest is running, then you could use:

  • Samba (as already mentioned)
  • an SFTP share such as SFTP Drive
    • Remember SFTP is a subset of SSH, whereas FTPS is a subset of FTP. This means as long as you can connect using SSH then you can connect using SFTP and get the same file/folder permissions on the guest as the user you used to log on.
SharpC
  • 623
1

you can do this by configuring Samba on the guest Linux machine

to be able to access the VM from outside the host you must change the virtual machine networking from NAT to the "bridged"

===== FOR DEVELOPMENT ONLY === Do not do this in production!!! ====

Samba Configuration

Configure Samba service on the guest so that Guest FS will be accessible on the windows network like yet another computer to write / read files from

Install Samba on the guest

shell command sudo apt-get samba

  1. Edit the /etc/samba/smb.conf

Do it as root (sudo) !!

add at the end of the file

[root]
path = /
browseable = yes
guest ok = yes
guest only = yes
read only = no
force user = root
force create mode = 0777
force directory mode = 0777

Now, set a username and password for the Samba share. This command has to be run with root privilege.

shell command sudo smbpasswd -a <username>

- use the same that you use in the guest - it more convenient

it will ask you to set a password. set the same as password for convenience and from Windows you can now access ///root and read/write the whole Linux filesystem

can be the IP of the guest get it with shell command ip a

or host name

shell command hostname

can be changed here \etc\hostname

1

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.

0

You can extract all shared directories and data into separate vdi file and mount it as a usual drive or directory in the host. Particulary for the Windows you can use, for example, ImDisk toolkit for that. The rest is the same, just mount the host drive in the Guest as a VirtualBox Shared Folder.

The thing has one big plus, when you still use it as an usual drive instead of a network drive, where the network setup is initially required. For example, you can redirect all traffic from a virtual machine to a VPN without losing access to the shared drive.

Update:

As author said the ImDisk does not fit to mount entire disk with multiple partitions and recommended to use the Arsenal Image Mounter:

https://github.com/LTRData/ImDisk/issues/13#issuecomment-1188952131

That is about 15 years old information. Lots of things have happened since. In most cases nowadays I recommend people to use Arsenal Image Mounter instead when mounting forensics image formats and virtual machine image formats in Windows. That will give you a full disk emulation with partition tables and everything.

GUI application that also installs necessary drivers etc: arsenalrecon.com/downloads Command line tools: ArsenalRecon/Arsenal-Image-Mounter@master/Command%20line%20applications

You can mount vdi images like this: aim_cli /filename=image.vdi /provider=DiscUtils /background

You will get a device number in the console output, something like device 000000. Use that to dismount later: aim_cli /dismount=00000

To mount on XP or mount a particular partition from a virtual disk file like vdi, you can still try ImDisk and read the old links:

Mount VDI as logical drive on host : forums.virtualbox.org/viewtopic.php?t=4748
Mounting .vdi file on host : forums.virtualbox.org/viewtopic.php?t=52
VirtualBox and forensics tools : http://forensicir.blogspot.com/2008/01/virtualbox-and-forensics-tools.html

Andry
  • 116