3 Ways to Transfer Files Between a Virtual Machine and PC on VMware and VirtualBox
- Virtual machines allow you to run a different operating system in isolation, but you can't directly access files on your host PC. But transferring files between them is straightforward.
- You can transfer files from a VM to a local machine using methods like drag and drop, USB drives, and shared folders. Each method has its own advantages and is suited for different types of data.
- Whether you're using VirtualBox or VMware, you can easily transfer files between your host PC and virtual machine. It's important to learn how to do this to effectively use virtual machines and back up your data.
Virtual machines (VM) allow you to run a different operating system in an isolated environment. Since virtual machines, by nature, are isolated, you cannot directly access files on your host PC.
Copying files from VM to a local machine from the host PC, or vice-versa, is often a major sticking point for virtual machine users. While it might seem complicated, if you want to move files from VM to the host again, you don't need to jump through different hoops, as the process is relatively 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 Copy Files From a VM to a Local Machine
A virtual machine is a software environment that emulates the hardware required to install an operating system (OS). Generally, this lets you install an operating system on an existing OS, much like an app.
The options for sharing data between a host PC and guest operating system running in a virtual machine are what you might expect:
- Drag and drop (also known as 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.
Many users don't know how to transfer files from VirtualBox to host; even if they do know, they don't exercise the option since they feel it's unsafe. It's worth mentioning that VirtualBox is 100% safe and has no security risks attached to its use.
Let's look at sharing data using these three methods on virtual machines running on Oracle VirtualBox and VMware Workstation Player.
1. Drag & Drop and 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.
How to Transfer Files From Virtualbox to Host Using Shared Clipboard Option
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, which prevents your attempts to copy files to VirtualBox.
Select Bidirectional in both drop-down boxes to enable two-way file sharing.
How to Copy Files to VMware Using Drag and Drop
Similar to the VirtualBox functionality, you can also set up a shared clipboard or enable drag and drop in VMware. But you might need to install the VMware Tools package, which brings additional features.
- With VMware running, navigate to VM > Install VMware Tools. Instructions will be available during installation if you haven't already downloaded VMware Tools.
- Enable copy and paste in VM > Settings > Options.
- Select Guest Isolation.
- Here, 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, and that sort of thing. Steer clear of large files, though you have other options.
2. Copy Files from VM to the Local Machine On a USB Stick
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 the virtual machine. Let's use a USB drive to share data between a virtual machine and your host PC.
Transfer Files From the Host to VirtualBox Using a USB stick
You'll need to enable USB access to USB devices from within VirtualBox. 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.
- Right-click the VM you plan to use and select Settings > USB.
- Click +, then browse for the USB device, which will be available when you launch the VM. Additional drives can be added in the same way.
You can then use the USB device to copy files to VirtualBox.
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 messy if you forget which operating system the USB stick is connected to.
This option is best if you want to copy large files from VM to host with VMware. 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 host and guest virtual machines.
3. Create a Shared Folder to Transfer Files from Host to VM
Your third option for copying files from the host to the guest PC is to set up a network share. This means designating a portion of your PC's hard disk drive as accessible over the local network. With this setup, the VM can connect to the network and access the drive.
Although physically on the same computer, this increases your virtual machine data-sharing capacity.
How to Transfer Files from VirtualBox to Host Using a Shared Folder
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, then:
- Open Devices > Shared Folders > Shared Folders Settings.
- Click +, then in Folder Path, click the arrow and select Other.
- Browse for the folder you plan to share, and click Select Folder.
- In Add Share, give the share a name you can use in both operating systems.
- 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.
If you can't transfer files between VirtualBox and the host PC, you can consider a few notable virtual machine options that are close alternatives to Oracle's VirtualBox.
Share a Network Drive in VMware
The process of creating a shared folder on VMware is 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 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 on 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 can share larger files effortlessly. These might include installers, disk image files, and hi-res videos.
Transfer Files Between Virtual Machine and Host
Whether using VirtualBox or VMware, sharing data between your physical PC and a virtual machine is surprisingly simple. If you're not copying files from the host to the guest OS, there's a 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.