How to share a folder in VirtualBox with a Windows host and a Linux guest

1.8k 0

VirtualBox is an open-source, cross-platform virtualization software that allows you to run multiple guest operating systems (virtual machines) simultaneously.

That makes it a very good option when needing a test or development environment with a similar setup to a production VPS, for example.

But once we have the virtual machine setup and running it is very common that we need to exchange files between our host system and the guest one.

If we want to do this in a faster way than accessing via FTP or setting up a Samba server, VirtualBox gives us the chance to easily setup as many shared folders as we need between the two systems.

Let’s see how to do it having a Windows 10 or 11 as a host machine and a Linux Debian 11 as a guest system.

Install VirtualBox Guest Additions on Debian 11 Linux

  • Open the VirtualBox GUI Manager.
  • Select the Debian VM and go to Settings > Storage.
  • Select the CD-ROM device under Controller: IDE entrance.
  • Click the CD icon and select Choose a disk file.
  • Browse to C:\Program files\Oracle\VirtualBox\ and select the VBoxGuestAdditions.iso file.
  • Start the Debian guest virtual machine.
  • Log in to the guest machine as root or sudo user.
  • Open the Debian guest terminal, create a new directory , and mount the ISO file:
sudo mkdir -p /mnt/cdrom
sudo mount /dev/cdrom /mnt/cdrom
  • Navigate to the directory and execute the VBoxLinuxAdditions.run script to install the Guest Additions.
  • Once the installation is finished, power off the virtual machine.

Setup the shared directory between Windows and Debian

  • Go to the VirtualBox GUI Manager.
  • Select the Debian VM and go to Settings > Shared folders.
  • Press the icon to add a new shared folder.
  • In the Folder path field browse to select the folder you want to share.
  • Write a Folder name to identify it from the linux system.
  • Check the Auto-mount checkbox if you want the linux system to mount it automatically.
  • Check the Make permanent checkbox if you want the shared folder to persist after rebooting the VM.
  • In the Mount point field white the absolute path you want to locate the shared folder in your linux system.
  • Start the Debian guest virtual machine and check the location of the setup shared folder.
  • If you can not access to the shared folder, check there is not mispelling error in the VM settings window. You can also try to mount the shared folder manually by executing with root or sudo user:
sudo mount -t vboxsf <Name-of-the-shared-folder> <path-to-the-directory-to-mount-to>

That’s it! Now you have a very easy and fast way to share files between the Windows host and the Linux guest system.

Carlos Pérez

Digital manager, tech lead, product designer, full stack engineer, web and app developer, SEO, digital marketing, automation and AI expert.

Leave a Reply

Your email address will not be published. Required fields are marked *