How to Setup Folder Sharing with VirutalBox Guests

virtualbox-thumbHaving a virtual machine installed on a personal computer offers many uses.  One use is the ability to try a new operating system before it is released, such as Windows 7.

Once you’ve installed a virtual operating system, you might want to access files that are stored on the host operating system.  VirtualBox offers a feature called ‘Shared Folders’ which will allow you to share files between the host and guest operating systems.

Linux Host with Windows Guest

Steps performed in host (Linux)

  1. Verify that the guest virtual machine has been shut down.
  2. Open the terminal from Applications > System Tools > Terminal
  3. Enter the following, substituting the virtual machine name, shared folder name, and the path to files on the host.
  4. VBoxManage sharedfolder add “virtual machine name here” -name “shared folder name” -hostpath “/path/to/files/here

  5. Start the guest operating system.

Steps performed in guest (Windows)

  1. Start the guest operating system from the host.
  2. Install Guest Additions from Devices > Install Guest AdditionsNote: You will need to restart.
  3. Open the command prompt from Start > Run… > cmd.
  4. Enter the following into the command prompt, substituting the shared folder name entered in step 3 above.
  5. net use p: \\vboxsvr\shared folder name /PERSISTENT:YES

  6. Adding the /PERSISTENT:YES to the command will mount the share at every boot.
  7. You can also change the drive letter from p: to any other you wish.

Windows Host with Linux Guest

Steps performed in guest (Linux)

  1. Start the guest operating system from the host.
  2. Before Guest Additions can be installed, some dependencies need to be installed using the command below.
  3. sudo yum install kernel-headers kernel-devel gcc

  4. After the dependencies have been installed, you can install Guest Additions from Devices > Install Guest Additions.
  5. Open the terminal and enter the following line
  6. sudo cd /media/VBOXADDITIONS_(VirtualBox Version Number)

    Once the guest additions have been installed, you will need to restart the guest OS.

  7. When the guest has restarted, open Shared Folders from Devices > Shared Folders… from the guest window.
  8. Click the Add New Shared Folder icon on the right of the window, or press the Insert button on your keyboard.
  9. At the Add Share window, select Other… from the Folder Path drop down and select the path of the folder on the host that you wish to share with the virtual guest.
  10. In the Folder Name enter a name of the shared folder, such as MyShare.
  11. Click the Make Permanent checkbox if you wish to keep the changes and click Ok to close the dialog.
  12. Open the terminal and enter the following command to mount the shared folder.
  13. sudo mount -t vboxsf sharename mountpoint
    Eg. sudo mount -t vboxsf MyShare /home/dustin/Desktop/Shared

  14. The above command will not keep the shared folder mounted after restarting the system.  To mount when starting the system, you will need to edit your fstab as shown below.
  15. sudo nano /etc/fstab
    sharedname mountpoint vboxsf defaults 0 0
    eg. MyShare /home/dustin/Desktop/Shared vboxsf defaults 0 0

  16. Your shared folder will now be mounted at boot.

Once the above steps are completed, you will now be able to access files on your host operating system from your VirtualBox guest operating system.


Posted

in

, , , ,

by

Comments

One response to “How to Setup Folder Sharing with VirutalBox Guests”

  1. […] This post was mentioned on Twitter by Techerator, pbvinge. pbvinge said: RT @techerator New Article: How to Setup Folder Sharing with VirutalBox Guests http://bit.ly/Zqw9l […]

Leave a Reply