VMFS Recovery™
Recover data from damaged or formatted VMFS disks or VMDK files
Recover data from damaged or formatted VMFS disks or VMDK files
Last updated: Apr 23, 2024

VirtualBox Shared Folder Guide

VirtualBox users understand the importance of creating a shared folder to ease file access between a guest VM and the host files – and vice versa. Shared folders make file transfer easy between host devices and guest machines. Setting up this shared folder is not a difficult task, but you have to be careful with the steps, and yes, if you can, do a full backup before proceeding.

A VirtualBox shared folder means you can access host files from a guest VM or access VM files from a host device. It’s all similar to Windows networked computers – where you have multiple PCs connected over a network and can access the files on each from any of the networked computers. But in this case, no networking of any sort is needed. How do you get this done?

Whether it’s on Windows or Linux OS, you must first install the Guest Additions software before you can set up shared folders. Here are the steps:

Launch the guest machine and go to Device 🡺 Insert Guest Additions CD Image 🡺 click Run in the prompt 🡺 enter your sudo passwords 🡺and wait for the installation to run 🡺 Reboot the VM.

Creating and Accessing Shared Folders

To get started, you need to be running Windows Server 2000 or later, Linux, or Oracle Solaris. Also, you need guest machines to set up shared folders. A shared folder stays on the host machine and then shares access to guest additions. In a Windows environment, shared folders are deployed as pseudo-network redirectors, while on Linux and Oracle, they are deployed as a virtual file system.

Note: Oracle VM VirtualBox integrates experimental support for Mac OS X and OS/2 guests.

1. Setting Up the Shared Folder on Windows

Create a new folder on the guest and also on the host PC. After that, install the VirtualBox Guest Additions software on the PC, and then proceed with the steps below:

  • Right-click on the new folder and click on Properties, then toggle to the Sharing tab.
  • On the sharing tab, click on the Share button 🡺 click the dropdown arrow and select Everyone 🡺 click the Add button.
  • After adding Everyone to the network, change the permission to Read/Write, then click Share.
  • Head on to the Windows guest machine (VM), and go to Devices 🡺 Insert Guest Additions CD image. When the next prompt comes up, select the first option to run the VirtualBox Windows Additions software; after the installation, reboot the machine.
  • Go back to Devices 🡺 Shared Folders 🡺 Shared Folders Settings 🡺 add the new folder path to use as a shared folder with the host.
  • Choose a name for the shared folder name and check the box beside Auto-mount and Make Permanent.
  • After this is done, open File Explorer and go to Networks 🡺 turn on Network Discovery and File Sharing.

With network discovery turned on, go back to Networks and refresh, so you can now see the shared folder.

2. How to Set Up a Shared VirtualBox Folder on a Linux VM

On the host machine, create a new folder and configure it to be viewable within your network. The steps are explained below:

  • Create a new folder on the host system and name it Shared Folder. You may create another sub-folder inside the Shared Folder to see if the files are truly accessible by the guest VM and host.
  • Launch your Linux VM and create a folder, which would serve as the mount point. If you wish to use commands to create the new folder, the command is: sudo mkdir (Current/Directory/Folder_Name). Remember to replace the placeholder words.
  • Now that you have made new folders on the host and guest VM, launch the Linux terminal (ensure your Linux system has the latest packages and dependencies installed).
  • Go to your guest machine 🡺 Device 🡺 Insert Guest Additions CD image (If the toolbar is hidden, hold CTRL + Home and it’ll appear).
  • You should get a prompt to run the Virtual Box Guest Additions software, click Run and enter your password.
  • After the installation, go to VirtualBox 🡺 Settings 🡺 Shared Folders 🡺 click the Add folder icon at the top right 🡺 enter the Folder Path, Name, and Mount Point 🡺 click OK.
    • Note: The folder Path must be that of the folder you want to use as a shared folder on the host machine, in this case, we set the folder earlier to be “Shared Folder.”
    • The “Folder Name” is where to enter a unique name you the share folder to bear.
    • “Mount Point” is the path to the folder you want to use shared folder in the guest machine).
    • Read-Only: To set the shared folder as read-only.
    • Auto-Mount: If you want to mount the folder immediately.
    • Make Permanent: If you want the shared folder to be automatically mounted after each reboot.
  • To make the shared folder permanent, check the Auto-mount and Make Permanent features.
  • Return to the system configuration menu to confirm your shared folder is active; if it’s active, you will see “Shared Folders: 1”
  • Back to your guest machine, you will notice that the shared folder mounted in your home directory is locked and inaccessible; to unlock the folder, you need to add the user profile to the vboxsf group – the admin profile of the shared folders. Here’s how to do that using Linux Terminal.
    • sudo adduser (username) vboxsf
    • sudo reboot

Once the machine reboots, try accessing the folder, and this time, it should be accessible.

Creating a Permanently Shared Folder in VirtualBox

To create a permanently shared folder in VirtualBox, you'll need to follow a series of steps to set up the shared folder in the VirtualBox settings and then configure it within your guest operating system. Here’s a detailed guide on how to do it:

Step 1: Install Guest Additions

Before you set up shared folders, ensure that Guest Additions is installed on your guest operating system. This software enhances the performance and usability of the guest OS in VirtualBox.

  1. 1. Start your virtual machine.
  2. 2. Once the guest OS is running, click on the "Devices" menu in the VirtualBox window toolbar.
  3. 3. Select "Insert Guest Additions CD image..."
  4. 4. Inside the guest, run the setup for Guest Additions which mounts as a virtual CD. Follow the on-screen instructions to install.

Step 2: Set Up the Shared Folder

  1. 1. Shut down your guest operating system.
  2. 2. In the VirtualBox Manager, select your virtual machine, then click "Settings".
  3. 3. Go to the "Shared Folders" section.
  4. 4. Click on the "Adds new shared folder" icon on the right side (the folder icon with a plus on it).
  5. 5. In the Folder Path, choose the folder on your host machine that you want to share. You can also use the "Other..." option to browse to the folder.
  6. 6. In the Folder Name field, enter a name for the shared folder as it will appear in your guest OS.
  7. 7. Check "Auto-mount" and "Make Permanent" if you want the folder to automatically be available and remain permanent.
  8. 8. Click "OK" to close the settings and again "OK" to exit the settings menu.

Step 3: Access the Shared Folder in Guest OS

The steps to access the shared folder can vary slightly depending on whether your guest OS is Windows, Linux, or another operating system:

For Windows Guests:

  • The shared folder should appear automatically in your network locations as a network drive if "Auto-mount" was enabled. If it doesn’t, you can manually map it as a network drive:
    1. 1. Open 'This PC' or 'Computer'.
    2. 2. Click on ‘Computer’ from the menu, then ‘Map network drive’.
    3. 3. Choose a drive letter and for the folder path, enter \\vboxsrv\ replacing with the name you assigned earlier.
    4. 4. Click "Finish" and if prompted, confirm any dialogs.

For Linux Guests:

  • If "Auto-mount" is enabled, your shared folder usually appears under /media/sf_. To access it with write permissions, you might need to add your user to the 'vboxsf' group:
    1. 1. Open a terminal.
    2. 2. Run sudo adduser your_username vboxsf, replacing your_username with your actual username.
    3. 3. Log out and log back in for the group change to take effect.

These steps will help you successfully create and access a permanently shared folder in VirtualBox, enhancing the functionality and integration between your host and guest operating systems.

Accessing Shared Folders in VirtualBox

Accessing shared folders in VirtualBox after setting them up involves different methods depending on the guest operating system. Additionally, configuring auto-mount settings through the VirtualBox Manager can streamline the process, allowing the shared folder to be automatically available every time you start your virtual machine. Here’s a more detailed explanation of how to access and manage shared folders across different guest operating systems:

Windows Guests

Automatically Mounted

If "Auto-mount" is enabled in the VirtualBox settings, Windows guest systems typically make the shared folder available in the Network Locations. It can also appear as a network drive automatically.

Manually Mapping Network Drive

If the folder does not auto-mount, or if you prefer to set it up manually:

  1. 1. Open 'This PC' or 'Computer'.
  2. 2. Click on the ‘Computer’ tab, then select ‘Map network drive’.
  3. 3. Choose a drive letter.
  4. 4. For the folder path, enter \\vboxsrv\, replacing with the name you assigned in the VirtualBox shared folder settings.
  5. 5. Click "Finish." If prompted, confirm any dialogs to complete the network drive mapping.

Linux Guests

Automatically Mounted

Linux guests will typically mount auto-mounted shared folders under the /media/ directory, usually appearing as /media/sf_. Here, sf_ stands for "shared folder," and is the name you specified.

Permissions

For full access, including write permissions, your user account in the guest OS may need to be added to the 'vboxsf' group. This can be done using the following commands:

bash
sudo adduser your_username vboxsf

Replace your_username with your actual username in the guest OS. You will need to log out and then log back in to apply these changes.

Configuring Auto-Mount through VirtualBox Manager

To ensure that your shared folder is automatically mounted every time you start your virtual machine, follow these steps:

  1. 1. Shut down your guest operating system.
  2. 2. Open VirtualBox and select the virtual machine.
  3. 3. Go to "Settings" > "Shared Folders".
  4. 4. Click on the folder with a plus icon to add a new shared folder or select an existing one to modify.
  5. 5. In the configuration dialog, set the "Folder Path" to the folder on your host that you wish to share.
  6. 6. Enter a "Folder Name" that will be used by the guest OS to reference the folder.
  7. 7. Ensure that "Auto-mount" is checked. This option tells VirtualBox to automatically mount the shared folder when the guest OS starts.
  8. 8. Optionally, you can also select "Make Permanent" to ensure the shared folder remains available across multiple sessions.
  9. 9. Click "OK" to save the settings and exit.

By configuring auto-mount, you eliminate the need to manually mount the shared folder each time you run the virtual machine, simplifying the process of accessing shared data. This setting is particularly useful for users who frequently use VirtualBox for tasks that require regular file sharing between the host and the guest operating systems.

Using the Shared Folders Feature

Using shared folders in VirtualBox efficiently involves adhering to some best practices to ensure security, maintain performance, and effectively manage data. Here are some detailed guidelines to follow when using shared folders in VirtualBox:

Security Practices

  • Limit Shared Data: Only share the folders necessary for your tasks in the guest operating system. Avoid sharing your entire home directory or sensitive folders to minimize the risk of accidental exposure or malicious access if the guest system is compromised.
  • Use Read-Only when Appropriate: If the guest system does not need to modify the contents of the shared folder, configure the shared folder as read-only. This prevents any changes in the guest OS from affecting the original files on the host system.
  • Regularly Update Guest Additions: Keep the VirtualBox Guest Additions updated to ensure compatibility and security, as older versions may contain vulnerabilities that can be exploited.
  • Network Configuration: Consider the network settings of your virtual machine. Utilize internal networking or host-only networks if the shared folders contain sensitive information that should not be accessible outside the host machine.

Performance Optimization

  • Selective Syncing: Instead of continuously working directly out of a shared folder, which can slow down performance due to real-time syncing, consider copying files to the local storage of the guest OS for active work, and sync them back when done.
  • Avoid Large Files: Large file operations over shared folders can significantly degrade performance. Use alternative methods like network transfers or external drives for transferring large files if performance becomes an issue.
  • Optimize File Watching: For development environments, excessive file watching over shared folders (like with some Node.js projects) can lead to high CPU usage. Tools like NFS or rsync can be used to mitigate some of these issues by reducing the overhead of real-time file watching.

Backup and Data Management

  • Regular Backups: Maintain regular backups of important files shared between the host and guest systems. Even though VirtualBox is generally stable, having backups is crucial, especially when dealing with critical data.
  • Version Control Systems: Use version control systems such as Git for any development work done within shared folders. This not only serves as an additional layer of backup but also helps in managing changes and collaboration.
  • Use Snapshot Features: Take advantage of VirtualBox's snapshot feature to preserve the state of the virtual machine at different points in time. This can be particularly useful before making significant changes in the guest OS.

Synchronization Tools

  • Rsync for Linux: For Linux guests, rsync is an efficient tool for synchronizing files between the host and guest filesystems. It can be configured to sync only the changed parts of files, reducing the data transfer load.
  • RoboCopy for Windows: In Windows guests, RoboCopy (Robust File Copy) is a powerful tool for file replication. It is highly configurable and can be set up to mirror directories between the host and guest.

Conclusion

Setting up and utilizing shared folders in VirtualBox can significantly enhance the efficiency and convenience of managing files across different operating systems on the same machine. By properly configuring shared folders, users can ensure seamless data exchange between host and guest environments, which is particularly beneficial for tasks like software development, testing, and data analysis.

The key to effectively using shared folders lies in following best practices that prioritize security, performance, and data management. By restricting shared data to only what is necessary, employing read-only access when appropriate, and keeping system components up to date, users can safeguard their environments against potential security threats. Additionally, optimizing performance by managing how and when data is synchronized between systems can help maintain a smooth operational flow, avoiding the pitfalls of slow file access or high resource consumption.

FAQ

  • How do I share files from my computer to VirtualBox?

    To quickly transfer a few files, you can use the drag and drop feature. Start by opening your running guest machine and navigating to the top bar. Click on "Devices" followed by "Drag and Drop," and ensure that "Bidirectional" is selected. This setting allows you to seamlessly drag files into and out of your virtual machine.

  • How do I give permission to a shared folder in VirtualBox?

    Begin by creating a new folder. After the folder is created, right-click on it and navigate to Properties > Sharing. Click on the "Share" button, select "Everyone" from the list, and then click on "Add". Once "Everyone" is added, adjust the permission level to Read/Write. Finally, click "Share" to apply these settings, allowing everyone within the network to access and modify the folder.

  • What is mount point in VirtualBox shared folder?

    Mount point - This is the folder within the guest operating system where the shared folder will be mounted. If this folder does not already exist, it will be created. Selecting "Make Permanent" ensures that the shared folder is classified as a "Machine Folder" in the VirtualBox Manager under the "Shared Folders" view. This setting ensures the folder will automatically mount each time the virtual machine is restarted.

  • How do I make a shared folder permanent in VirtualBox?

    While the guest is operational, the 'Make Permanent' option can be used for Guest Additions Shared Folders. This feature ensures that a specific shared folder consistently remains in the guest's list of shared folders.

Related articles

FREE DOWNLOADVer 4.21, WinBUY NOWFrom $699

Please rate this article.