Virtual machines are isolated containers, so the guest operating system in the virtual machine doesn’t have access to your computer’s file system. You’ll have to set up shared folders in a program like VirtualBox or VMware to share files.
To help the guest operating system understand what’s going on, virtual machine programs present these shared folders as network file shares. The guest operating system accesses a folder on your PC like it would a shared folder on a network.
VirtualBox’s Shared Folders feature works with both Windows and Linux guest operating systems. To use this it, you’ll need VirtualBox’s Guest Additions installed in the guest virtual machine. Click the Devices > Insert Guest Additions CD image option while a virtual machine is running and run the installer from the virtual disc to install it.
Next, click the Machine > Settings option in a virtual machine’s window and select Shared Folders. Here you can see any shared folders you’ve set up. There are two types of shared folders — Machine Folders are permanent folders that will be shared until you remove them, while Transient Folders are temporary and will be removed when the virtual machine restarts or shuts down.
Click the Add button or right-click in the list and select Add Shared Folder to add a new shared folder. The folder path is the location of the shared folder on your host operating system, while the name is how it will appear inside the guest operating system.
By default, the virtual machine has full read-write access to the shared folder. Enable the Read-only checkbox if you want the virtual machine to only be able to read files from the shared folder.
The Auto-mount checkbox makes the guest operating system attempt to automatically mount the folder when it boots. The Make Permanent checkbox makes the shared folder a Machine Folder — by default, it’s a transient folder.
You should see the shared folders appear as network file shares if you’re using a Windows guest operating system. Open Windows Explorer or File Explorer, select Network, and look under the VBOXSRV computer.
You can also mount these folders with the appropriate commands. Hover over the list of shared folders in the virtual machine’s settings window if you ever need to double-check the commands you’ll need.
Use the following command on Windows, replacing NAME with the name of the share:
net use x: \\vboxsvr\NAME
Use the following command on Linux, replacing NAME with the name of the share and /mnt/folder with the path to a folder. You’ll need to create this folder first if it doesn’t exist:
mount -t vboxsf NAME /mnt/folder
VMware’s Shared Folders work with both Windows and Linux operating systems, too. You’ll need VMware Tools installed in your virtual machine to use this feature. Select the option in your virtual machine’s menu to install VMware Tools or update your virtual machine’s VMware Tools to the latest version.
Next, open your virtual machine’s settings window. For example, in VMware Player, click Player > Manage > Virtual Machine Settings. Click the Options tab, select Shared Folders, and enable the feature.
Add folders you want to share here. They’ll appear in the virtual machine with the name you provide. By default, the virtual machine will have full read-write access to the folder. Check the Read-only box in the wizard to prevent the virtual machine from writing to the folder.
The shared folders will then appear as a network file share in your Windows guest operating system. Look under the vmware-host computer.
Check the “Map as a network drive in Windows guests” option to speed things up. Instead of digging through the network file shares, your shared folders will get their own drive letter and appear in the Computer window. This just uses the “map network drive” feature in Windows.
On a Linux guest system, you should find VMware Shared Folders under /mnt/hgfs in the root directory.
If you have multiple virtual machines, you’ll need to set up file sharing separately for each one. Be careful when using shared folders — if your virtual machine becomes compromised, the malware could escape your virtual machine by infecting files in your shared folders.