Virtual machines allow you to run a different operating system in an isolated environment, and using a virtual machine can considerably improve your productivity. Because virtual machines, by nature, are isolated, you cannot directly access files on your host PC.
Copying text or files from the host PC to the guest, or vice-versa is often a major sticking point for virtual machine users. Although it may seem complicated, the actual process is quite straightforward. Let’s look at the different methods for transferring files between your virtual machine guest operating system and host PC using VirtualBox or VMware.
How To Transfer Files From Virtual Machine To Host
A virtual machine is a software environment that emulates the hardware required to install an operating system (OS). In very general terms, this lets you install an operating system on an existing OS, much like an app.
You won’t be surprised by the options for sharing data between a host PC any guest operating system running in a virtual machine. Here are the three main options to share data between a virtual machine and a host PC:
- Drag and Drop (Copy and Paste)
- USB drive
- Shared Folder
Each of these methods is ideally suited for a specific type of data and expected use. For example, copy and paste is best for sharing text and small files, such as copying code from a browser on your host PC into a terminal session in the guest OS.
Below, we’ll look at sharing data using these three methods on virtual machines running on Oracle VirtualBox and VMware Workstation Player
Drag and Drop & Shared Clipboard
The simplest option to transfer files between your host PC and a virtual machine is to set up a shared clipboard and/or drag and drop. This will allow you to use a common clipboard, meaning you will be free to copy/paste text/images and files between the virtual machine and your host PC.
Shared Clipboard in VirtualBox
If you’re using Oracle VirtualBox, then you can set up a Shared Clipboard and Drag’n’Drop in just a few quick steps:
- Select your virtual machine, right-click and select Settings.
- In the window that pops up, click on General and then click on the Advanced tab.
- You should now see the Shared Clipboard and Drag’n’Drop dropdown options.
You can choose from Host to Guest, Guest to Host, and Bidirectional. There’s also the default option, Disabled. Select Bidirectional in both drop-down boxes to enable two-way file sharing.
How to Copy and Paste Data in VMware
Similar to the VirtualBox functionality, you can also set up a shared clipboard or enable drag and drop in VMware. But you might need first to install the VMware Tools package, which brings additional features.
- Within VMware, navigate to VM > Install VMware Tools. If you haven’t already downloaded VMware Tools, instructions for doing so will be given.
- You can then enable copy and paste in VM > Settings > Options. Select Guest Isolation, then Enable copy and paste and Enable drag and drop, confirm with OK.
Sharing data between the guest and host operating systems in this way is best suited for smaller files. You might also share text strings, URLs, that sort of thing. Steer clear of large files, though—you have other options for those.
Using a USB stick to transfer data between two physical machines is a time-honored tradition. Although not ideal, a USB stick can transfer files between the host PC and virtual machine. Let’s look at how you can use a USB drive to share data between a virtual machine and your host PC.
Transfer Files From Host To VirtualBox Using A USB stick
To be able to access USB devices from within VirtualBox, you’ll need to enable USB access. For this, you need to download the VirtualBox Extension Pack
Once you have downloaded the extension pack:
- Insert the USB device you wish to use
- Launch VirtualBox and click File > Preferences, then Extensions and click +. Browse to the downloaded Extension Pack, click Open, then when prompted, Install.
- Follow the prompts to complete the process. You can then check to confirm USB is enabled in Settings > USB.
- You now need to enable the added USB support. In the main VirtualBox window, right-click the VM you want to use and select Settings > USB.
- Click + then browse for the USB device. It will be available when you launch the VM. Additional drives can be added in the same way.
How To Transfer Files To VMWare With A USB Stick
With VMware, when a USB device is connected and the VM is the active window, the device is detected. However, it will not be detected by the host PC in this scenario. For this to happen, remove the drive, minimize the VM, then reconnect.
It’s simple but can get messy if you forget which operating system the USB stick is connected to.
This option is best for large files. Of course, you’re limited by the capacity of the USB device, so keep that in mind. Whatever VM software you use, safe ejection of USB devices is recommended on both host and guest virtual machines.
Create a Shared Folder
Your third option is to set up a network share on your host PC that the guest VM can access. This means designating a portion of your PC’s hard disk drive as accessible over the local network. With this setup, the VM can then connect to the network and access the drive.
Although physically all on the same computer, this adds higher capacity to your virtual machine data sharing.
Create a Shared Folder in VirtualBox
You should have already downloaded VirtualBox Guest Additions. This should be installed via Devices > Install Guest Additions, where you should browse for the appropriate EXE file. Follow the steps to the end, choosing the default options, then Finish.
Launch VirtualBox and open Devices > Shared Folders > Shared Folders Settings. Click +, then in Folder Path, click the arrow and select Other. Browse (the host OS) for the folder you’re using as a share, highlight it, then Select Folder.
In the Add Share window, give the share a name (keeping the same name in the guest OS as the host OS is wise). Check Auto-mount and Make permanent, then OK.
From the guest OS, you’ll find the share set up in the usual location for network shares. For example, in Windows 10, this will be under Network Locations in Windows Explorer.
Share a Network Drive in VMWare
The process of creating a shared folder on VMWare is quite straightforward:
- Within VMWare Workstation, choose your virtual machine and click on Player > Manage > Virtual Machine Settings
- Click on Options > Shared Folders. You can then choose a sharing option under Folder Sharing
- Click on Add to set up your shared folder and follow the on-screen instructions in the Add Shared Folder Wizard.
- You can then type the Host path to the directory you want to share and name your folder.
- Once you click Next, you decide the folder access (Read-only or Enable this share, the latter allows both host and the virtual machine complete access to the shared folder).
- Click on Finish to create your shared folder.
Linux users can view the shared folder under the /mnt/hgfs directory.
While this is the most complicated option to set up, you will be able to share larger files effortlessly. These might include installers, disk image files, and hi-res videos.
Transfer Files From VM To Host
Not everyone needs to use a virtual machine, but those of us who do almost always need to share data. If you’re not copying files from the host to the guest OS, there’s reason to copy data from the VM. This is typically when you’re about to destroy the VM and want to back up your data.
Learning how to share data between a VM and host OS will help super-charge your VM use.