How to Share and Mount a Folder from Windows in Linux Mint Using VirtualBox

How to Share and Mount a Folder from Windows in Linux Mint Using VirtualBox

VirtualBox is a powerful tool that allows users to run a virtual machine (VM) on their host operating system. It supports multiple guest operating systems, including Linux Mint. A common requirement is to share files between the host (Windows) and the guest (Linux Mint). This guide will explain, step by step, how to share and mount a folder from Windows to Linux Mint using VirtualBox. We’ll go over everything from creating the shared folder to mounting it in Linux Mint.

1. Install VirtualBox Guest Additions

Before you can share a folder between your Windows host and Linux Mint guest, you need to install the VirtualBox Guest Additions. This package adds important functionalities like better display resolutions, mouse integration, and folder sharing.

Steps:

  1. Start the Linux Mint virtual machine: Open VirtualBox and start your Linux Mint VM.
  2. Insert Guest Additions CD Image: Go to the VirtualBox window, click on Devices > Insert Guest Additions CD Image. This will load a virtual CD into your Linux Mint VM.
  3. Open the Terminal: Once the Guest Additions image is loaded, open the Terminal in Linux Mint (press Ctrl + Alt + T).
  4. Mount the CD: In the terminal, mount the Guest Additions CD by typing:
sudo mount /dev/cdrom /media/cdrom

5. Run the Installer: Navigate to the mounted CD directory and run the installer script with the following commands:

cd /media/cdrom
sudo ./VBoxLinuxAdditions.run

This will install the VirtualBox Guest Additions. If all goes well, you’ll receive a success message.

6. Reboot the VM: After installation, reboot the Linux Mint VM by typing:

sudo reboot

Now that the Guest Additions are installed, you are ready to share folders between the Windows host and Linux Mint guest.

2. Create a Shared Folder on Windows

To share a folder from your Windows host, you first need to decide which folder you want to share.

Steps:

  1. Create or choose a folder: On your Windows machine, create a folder or use an existing one that you want to share. For instance, you can create a folder called SharedFolder on your C: drive.
  2. Open VirtualBox settings: Shut down your Linux Mint VM if it is running, then go to VirtualBox Manager, right-click your Linux Mint VM, and click on Settings.
  3. Navigate to Shared Folders: In the settings menu, go to Shared Folders on the left-hand side.
  4. Add a new shared folder:
    • Click on the + icon on the right side of the window to add a new shared folder.
    • In the Folder Path field, browse and select the folder you created or chose earlier (C:\SharedFolder).
    • In the Folder Name field, give it a name (e.g., SharedFolder).
    • Check the options Auto-mount and Make Permanent.
  5. Save the settings: Click OK to save your settings. The folder is now shared between the host (Windows) and guest (Linux Mint).

3. Mount the Shared Folder in Linux Mint

Although you’ve shared the folder in VirtualBox settings, you still need to mount it in Linux Mint so you can access its contents.

Steps:

  1. Start Linux Mint: Start your Linux Mint VM from VirtualBox again.
  2. Check for shared folder: You can check if the shared folder has been automatically mounted by navigating to the /media directory in Linux Mint. Open a terminal and type:
ls /media

If you see the folder name (SharedFolder) here, it means the folder has been successfully auto-mounted.

Manually mount the folder (if auto-mounting didn’t work):

  • First, create a directory where you want to mount the shared folder. For example, create a directory called winshare inside your home directory:
mkdir ~/winshare

Next, mount the shared folder to this directory. Assuming you named the shared folder SharedFolder in VirtualBox, use the following command to mount it:

sudo mount -t vboxsf SharedFolder ~/winshare

This command mounts the Windows shared folder (SharedFolder) to the ~/winshare directory in Linux Mint. You should now be able to see and interact with the files inside the shared folder.

4. Verify the mount: After mounting, you can verify it by listing the contents of the winshare directory:

ls ~/winshare

  1. If the folder contains files from your Windows shared folder, the setup has been successful.

4. Configure Auto-mounting (Optional)

To avoid having to manually mount the folder each time you start the Linux Mint VM, you can configure it to mount automatically.

Steps:

  1. Edit fstab: The fstab file is used to configure file system mounts. You can add an entry for your shared folder in this file to make it mount at startup.
  2. Open fstab in an editor: Open the fstab file with a text editor using the following command:
sudo nano /etc/fstab

3. Add a new line for the shared folder: Add the following line to the end of the file:

SharedFolder  /home/yourusername/winshare  vboxsf  defaults  0  0

Be sure to replace yourusername with your actual username and SharedFolder with the name you gave your shared folder in VirtualBox.

Save the file: Press Ctrl + X to exit, then Y to save the changes, and Enter to confirm the file name.

Reboot the VM: Reboot your Linux Mint VM:

sudo reboot

After rebooting, the shared folder should be automatically mounted to the specified directory.

5. Troubleshooting Common Issues

Sometimes, things don’t work as expected. Below are some common issues and their solutions:

Folder not mounting automatically

  • Ensure that you’ve selected the Auto-mount option in VirtualBox settings.
  • Check that VirtualBox Guest Additions are correctly installed.

Permission Denied Errors

  • Check if your user has access to the vboxsf group. If not, add your user to the group:
sudo usermod -aG vboxsf yourusername

  • Replace yourusername with your actual username. Then log out and log back in for the changes to take effect.

Shared Folder not appearing

  • Make sure you’ve selected the correct folder in VirtualBox settings and that the path is correct.
  • Check if the folder is listed under /media or try manually mounting it.

Conclusion

Sharing a folder between Windows and Linux Mint using VirtualBox is a useful feature that simplifies file management across platforms. By following these steps, you can easily share files between your host and guest operating systems. Ensure you have VirtualBox Guest Additions installed, correctly configure the shared folder, and use appropriate mounting techniques in Linux Mint. With this setup, you’ll have seamless access to your shared data.

Fedya Serafiev

Fedya Serafiev

Fedya Serafiev owns the website linuxcodelab.eu. He finds satisfaction in helping people solve even the most complex technical problems. His current goal is to write easy-to-follow articles so that such problems do not arise at all.

Thank you for reading the article! If you found the information useful, you can donate using the buttons below: