One of the reasons for using virtual machines is to have a sandboxed instance of an OS separated from your host. This way, you can test things without affecting your host operating system. However, there are cases where you need some of the files in your host system to be in the virtual machine. Both VMware and VirtualBox support sharing files between host and client.
Share Files with VMware Client
For this tutorial, we are using the free version of VMware Workstation 16 Player and have already set up a Windows 10 client.
Share with USB Drive
1. Right-click on your virtual machine and choose “Virtual Machine Settings” from the menu that pops up.
2. While in the Hardware tab, move to the “USB Controller” settings page.
3. If your VM doesn’t already have a USB Controller, use the “+ Add” button to give it one. Ensure USB Compatibility is set to “USB 3.1” to take advantage of the better speeds of newer USB flash drives.
4. Enable “Automatically connect new USB devices” and leave the other two options disabled.
5. Plug a USB drive into your host PC. Check the “USB Devices” menu for your active guest in VMWare Player. You’ll see a list of all USB devices that are connected to your PC.
6. Locate your USB drive and choose “Connect (Disconnect from host).”
You can now copy files back and forth between host and client computer this way.
Enable Folder Sharing
1. In the Settings page, move to the Options tab and select “Shared Folders.”
2. Change “Folder Sharing” option to “Always enabled.”
3. Iif your guest OS is Windows, you can also enable “Map as a network drive in Windows guests.”
4. Click on “+ Add” under the currently empty folder list. Enter a name for your shared folder and click on Browse to find and select the actual folder that will be shared between the host and client OS.
5. Leave Attributes as Enabled.
6. Ensure Read-only is disabled if you want both OSs to have full read/write access to your folder’s contents.
7. Click OK to save your settings and attach the folder to the VM.
After booting the guest, run your file manager, and you’ll find your folder under Shared Folders.
Enable Clipboard Sharing
VMWare Player comes with the shared clipboard functionality. You only have to install VMware Tools on the guest OS to enable it.
1. Boot up your guest OS. Choose “Virtual Machine -> Install VMware Tools …” If it’s not available, VMware Player will suggest downloading the latest available version. Accept and follow any steps it presents to download VMware Tools on your host PC.
2. Once VMware Tools is installed, reboot the guest OS.
3. After your VM’s next boot, you’ll be able to copy something on your host PC and paste it into the guest OS, or vice versa. You can also drag and drop files between them.
Share Files with VirtualBox Client
For what we can do with VMware, we can do the same things with VirtualBox. But before you do that, make sure you install VirtualBox Guest Additions on your guest OS first:
1. Choose “Devices -> Insert Guest Additions CD image …”
2. Normally, you’ll see the Setup wizard appear automatically. If not, manually run the setup executable you’ll find in the optical disc that will appear in your client OS.
3. Follow the wizard’s steps to install them in the client.
4. Reboot the client machine.
Now, right-click on your VM and choose Settings or select it from the list on the left and click the Settings button at the top of VirtualBox’s window.
Enable Clipboard Sharing
On the first General tab, make sure “Shared Clipboard” is set to Bidirectional if you want to share the content of the clipboard both from your host to your guest PC and vice-versa. With this setting enabled, you can drag and drop files from your Host to guest PC and vice versa.
Enable USB Sharing
If you prefer using a USB flash drive as a go-between from your host and client OS:
1. While in your VM’s settings, move to the USB tab.
2. Check that “Enable USB Controller” is active.
3. Save your settings and start the VM.
4. While the VM is active, find your flash drive in “Devices -> USB.” Choose it for it to detach from your host PC and attach to the guest OS.
5. You can copy and move files to and from it, then detach it from the VM to access its contents on the host PC. Rinse and repeat.
Enable Folder Sharing
To use shared folders in VirtualBox clients, open your VM’s settings:
1. Move to the “Shared Folders” tab.
2. Click on the icon with the Plus sign to add a new shared folder.
3. Choose the path of the actual folder that will be shared in Folder Path.
4. Enter a name for it in Folder Name.
5. Make sure Read-only is disabled if you want both host and client to have read and write access to its contents.
6. Enable Auto-mount if it’s not active so that you won’t have to mount the folder manually each time in the client OS.
7. In the Mount point field, enter either a letter if you’re using a Windows client or a folder name if you’re using a Linux client, under which the OS will try to mount your folder.
8. You’ll find your shared folder presented in the client OS as a Network Drive.
As virtualization technology become mature, it is also becoming easier to share files between the host and client.