How To Transfer Files To Virtual Machine

Tech News

Virtual Machines are great options for using other Operating Systems inside your usual ones. The Virtual Machines work separately from your system, so they can’t access your files directly.

However, If you need to work on both your host computer and the guest OS, you likely need to transfer files between them. But there’s no need to worry yet. The fact that you can’t directly access the files doesn’t mean that there’s no way to transfer files between the systems. 

In this article, you can find multiple methods to transfer files to a Virtual Machine.

How To Transfer Files To Virtual Machine

Below are some ways to transfer files to a Virtual Machine. They provide different options for the file transfer, so read carefully and pick one according to your need:

Transfer from USB External Storage

Using a USB drive is likely the first method users think of when they want to transfer files to a Virtual Machine. It is possible, but depending on the different VM software, you need to take a few additional steps first.

On VMware Workstation

You need to enable USB controllers on VMware Workstation to use such devices. To do so,

  1. On VMware, go to VM > Settings > Hardware > USB Controller.
  2. Set USB Compatibility to the highest USB standard and enable all options.vmware-usb-controller
  3. Click Ok.

Now, your VM can detect a USB device when the VM is active.

But your normal system stops detecting it at the same time. So, to copy files from your PC, unplug the USB device, minimize the VM, and reinsert the USB.

Similarly, to paste the files to the VM, unplug the USB device, maximize the VM, and reinsert the USB so that the VM detects it.

You can also reverse this process to transfer files from the VM to the host PC. Also, make sure to safely remove the USB device from all active VMs and the host computer before disconnecting it.

On Oracle VirtualBox

You need to have the VirtualBox Extension Pack to get support for USB devices. So make sure to install it first. Then, follow the steps below to enable access to USB devices on your Virtual Machine:

  1. Insert the USB drive to the PC with the VirtualBox VM.
  2. Open VirtualBox and install the Extension Pack if you haven’t already done so. To do so,
    • Go to File > Preferences > Extensions and click + (plus).
    • Navigate to the Extension pack, select it and click Open.
    • Click Install and follow the on-screen instructions.
  3. After installing the Extension pack, right-click on your VM and select Settings > USB.
  4. Enable all USB Controllers.
  5. Click + (plus) and then navigate to the USB drive.

The device will be available whenever you launch the Virtual Machine, so you can directly use it to transfer files.

On Microsoft Hyper-V

Hyper-V has an enhanced session mode that allows redirection of local drives from your PC to a VM. You can only use this mode to not only transfer files directly from your local drive but also to enable the detection of a PnP USB device. Here are the necessary steps:

  1. Shut down any active Virtual Machine and open Hyper-V Manager.
  2. Right-click on your PC name and choose Hyper-V Settings.
  3. Go to Server > Enhanced Session Mode Policy.
  4. Check Allow enhanced session mode and click Apply.
  5. Go to User > Enhanced Session Mode.
  6. Tick Use enhanced session mode, and click Apply.
  7. Go to your Hyper-V Virtual Machines list.
  8. Right-click on the VM you want and select Start.
  9. After it starts running, right-click again and select Edit Session Settings.
  10. Click Show Options and go to Local Resources > More.hyper-v-local-resources
  11. Expand Drives and tick on the local drive you want to share.
  12. To enable USB detection, expand Other supported Plug and Play (PnP) devices and check Devices that I plug in later.
  13. Click Ok, and then go to the Display tab.
  14. Tick Save my settings for future connections to this virtual machine and click Connect.

The local drive you selected will always be available on the VM. And any USB you connect will show on the VM. So you can transfer files using these drives.

Copy Using Shared Clipboard

Another way to transfer files is to copy them from your host computer and paste them into the guest VM. You need to set up a shared clipboard to use this method. Most VMs also allow drag-and-drop to copy files. You can find the necessary steps to set up the shared clipboard and enable both options on different VM stations below.

On VMware Workstation

  1. Download VMware tools, and on VMware, go to VM > Install VMware Tools to install them.
  2. After installing VMware tools, go to VM > Settings > Options.
  3. Click Guest Isolation and tick both Enable drag and drop and Enable copy paste.vmware-copy-paste
  4. Click Ok.

On Oracle VirtualBox

  1. On VirtualBox, right-click on your VM and select Settings.
  2. Click on General and go to the Advanced tab.
  3. Set the Snapshot folder to any folder you want.
  4. Set both Shared Clipboard and Drag’n’Drop to Bidirectional and click Ok.

On Microsoft Hyper-V

You can directly copy and paste files from a local drive or a PnP device using the enhanced session mode on Hyper-V. But if you want to use the drag-and-drop method to copy files from these drives, you also need to enable Guest Services. To enable the services,

  1. On Hyper-V Manager, go to Management > Integration Services for your VM.
  2. Check Guest services.

Create Shared Folder

You can also create a shared folder to easily transfer files to your Virtual Machine.

The shared folder will appear on your VM OS under the network location. Any files you transfer here will be available on your VM as well as your host PC.

On VMware Workstation

Follow the instructions below to create a shared folder on WMware Workstation:

  1. First, install VMware Tools. To do so, go to Player > Manage > Install VMware Tools on your VM session.
  2. After that, select Player > Manage > Virtual Machine Settings.
  3. Go to the Options tab and click Shared Folders.
  4. Check Always enabled and click Add. You can also tick Map as a network drive in Windows guests for more convenient access.vmware-shared-folder
  5. Specify the Host path and the Name. Then, click Next.
  6. Tick Enable this share and click Finish.

On Oracle VirtualBox

Here’s how you can create a shared folder on Oracle VirtualBox:

  1. Run your VM session and install Guest Additions by going to Devices > Insert Guest Additions CD image and following the on-screen instructions.
  2. After installing Guest Additions, go to Machine > Settings > Shared Folders.
  3. Click + (plus) and specify the given options.
  4. Make sure to check Auto-mount and then Make permanent if you want to make the Shared folder available every time.
  5. Click Ok.

On Microsoft Hyper-V

To create a shared folder on Hyper-V, you need to Share a folder from your host machine and then map a network drive to the folder. First, follow these instructions to share a folder,

  1. Create a folder on your host system to share with the guest OS.
  2. Right-click on it and select Properties.
  3. Go to the Sharing tab and click Share.
  4. Click Share again and select the network discovery option according to your choice.
  5. Make a note of the Network Path and click Ok.

Then, open the Hyper-V VM and map a network drive to the Network Path using the steps below:

On Windows

  1. Open File Explorer and right-click on This PC.
  2. Select Map network drive or More options > Map network drive.
  3. Set Drive to an unused drive letter and enter the Network Path on the Folder.
  4. Click Finish.

On Mac

  1. Go to the Apple menu > System Preferences > Users & Groups.
  2. Select Login Items and click + (plus) on the right side.
  3. Find your network drive under Shared and click Add.

Mounting Virtual Disk

You can also transfer files from HDD or SSD to a VM by mounting a virtual disk with the files. The Virtual disk contains all the contents of the physical disk and acts as the hard disk of the VM. So, it will directly access the files within.

First, you must create a VHD (Virtual Hard Disk), VDI (Virtual Disk Image), or VMDK (Virtual Machine Disk) image file of the physical disk depending on the VM software you are using. Then, you need to mount it to the Virtual Machine. The file will then appear as a local disk drive (or many if the file contains more partitions).

You can directly copy it to other locations inside the VM. After you are done, unmount the virtual drive.

Transfer Through Cloud Storage

You can also transfer files to a Virtual Machine OS through cloud storage. First, upload the files to Google Drive, OneDrive, iCloud, or any cloud service. Then, download it from the VM’s web browser or cloud app.

You can also use backup software to transfer files to VM in a similar way.

Using Command-line Interface on Hyper-V

Hyper-V also offers a method to use the PowerShell CLI to transfer files to a Virtual Machine. You need to enable Guest services to use this method. So, first,

  1. On Hyper-V Manager, go to Management > Integration Services.
  2. Check Guest services.
  3. Then, enter the following command on PowerShell to transfer a file:
    Copy-VMFile “<VM Name>” –SourcePath “<Host Machine File Path>” –DestinationPath “<Destination Path in VM>” –CreateFullPath –FileSourceHost
    powershell transfer hyper v

Sharing is caring!

Facebook Comments

Leave a Reply