Shared folders in VirtualBox allow file transfer between the host and guest operating systems without the need for external storage or networking. This feature integrates the two environments, making it easy to exchange data and access host files from within the virtual machine. Shared folders are important in scenarios where files need to be frequently accessed from both the host and guest systems.

To enable shared folders, VirtualBox relies on Guest Additions, a set of drivers and utilities that ensure the guest operating system can support shared folders and other advanced features. Installing Guest Additions is necessary to configure shared folders, as they won’t work without it. Verify that the Guest Additions are installed on the virtual machine before proceeding.

After creating a folder on the host machine, it can be configured in VirtualBox to be shared with the guest. The folder can be set to automatically mount, and permissions such as read-only or read/write access can be defined. These options control how the guest operating system interacts with the folder and allow for seamless file-sharing.

Ensure that Guest Additions are installed on the virtual machine before proceeding. The VM must be powered off for configuration.

Steps to add shared folders to VirtualBox VM:

  1. Create a folder on the host operating system to be used as the shared folder.
  2. Open VirtualBox and select the virtual machine you wish to configure.
  3. Power off the virtual machine if it is running.
  4. Right-click the virtual machine, then select Settings.
  5. In the Settings window, select Shared Folders from the left-hand menu.
  6. Click the Add Folder icon (a folder with a green plus sign).
  7. In the Folder Path dropdown, choose Other and select the folder you created on the host system.
  8. Enter a Folder Name for the shared folder as it will appear in the guest operating system.
  9. Set the Read-only option if the guest should not modify the files in the shared folder.
  10. Enable the Auto-mount option to mount the shared folder automatically when the virtual machine starts.
  11. Check the Make Permanent option to ensure the shared folder remains available across reboots of the virtual machine.
  12. Click OK to apply the changes and exit the settings.
  13. Start the virtual machine to activate the shared folder configuration.

CLI method to add shared folders in VirtualBox:

You can add shared folders to a virtual machine using the command line interface with VBoxManage. Below is a step-by-step guide to configure a shared folder for a VirtualBox VM:

  1. List available virtual machines. This will display all virtual machines currently registered in VirtualBox.
    VBoxManage list vms
    "YourVMName" {a-unique-uuid}
    "AnotherVM" {another-unique-uuid}
  2. Add the shared folder to the virtual machine. Use this command to add a shared folder to a specific virtual machine.
    VBoxManage sharedfolder add "YourVMName" --name "SharedFolderName" --hostpath "/path/to/shared/folder" --automount
    VBoxManage: shared folder "SharedFolderName" added successfully
  3. Set read-only access (if needed). If you want the shared folder to be read-only, use the following option:
    VBoxManage sharedfolder add "YourVMName" --name "SharedFolderName" --hostpath "/path/to/shared/folder" --automount --readonly
    VBoxManage: shared folder "SharedFolderName" added successfully
  4. List all shared folders for a virtual machine. This will display all shared folders currently configured for the VM.
    VBoxManage showvminfo "YourVMName" --machinereadable | grep SharedFolder
    SharedFolderName="SharedFolderName" SharedFolderHostPath="/path/to/shared/folder"
Discuss the article:

Comment anonymously. Login not required.