VBox Debian/Ubuntu - Automatically mount shared folder

1

1

I've searched some tutorials and posts - how to automatically mount shared folder in Virtual Box (using version 5.0.24) for Debian (using version 8.0 ). I think that Ubuntu's process is the same.

I've setup my fstab and also added vboxsf into modules, but folder still didn't shared or I was still getting errors. I was also thinking of using rc.local way, but this is not the right way to setup your automatically shared folder on system boot.

After this, I decided to write my own answer on this question - How to make your shared folder automatically mounted on system boot up?

jmeinlschmidt

Posted 2016-07-12T00:10:10.550

Reputation: 111

Answers

0

Host setup

First make sure you've installed Guest Additions on your virtual machine. If you didn't see this. Go to Virtual Box, your virtual machine and click Settings.

enter image description here

Create a folder within host (using Windows 7) or choose one. Remember the Folder name we will use it when setting up our shared folder in guest (Debian / Ubuntu).

1. Auto mount using VBox

Wait! Auto-mount?

I see "Auto-mount" option there! This option will make your shared folder mounted automatically on guest boot. This is what we want! BUT.

Checking auto-mount will mount your shared folder into /media/<your folder name> in your guest.

TIP: Type df command into console to see where is your shared folder mounted.

If you are fully satisfied with this way. You're done. You don't have to read this post further.


2. Auto mount to custom location

Mount your shared folder into custom location. Such as www folder of your Apache or nginx web server etc.

Always rember to disable Auto-mount option in VBox settings. Do not forget.

enter image description here

Launch your virtual machine. Remember to create folder in guest before mounting.

Adding mount command into rc.local could cause problems. Better to not do it. Use fstab instead.

Add module

Go to sudo nano /etc/modules And add this to the end of the file

vboxsf
vboxvfs
vboxadd

Add command to fstab

Go to sudo nano /etc/fstab And add this line to the end of the file <your folder name> <your custom path to the folder> vboxsf default 0 0


Now you can reboot your virtual machine to see changes.

If you have any suggestions, please leave a comment or edit my answer!

jmeinlschmidt

Posted 2016-07-12T00:10:10.550

Reputation: 111

0

To mount a shared folder using the vboxsf filesystem provided with Guest Additions, we first need to make sure some prerequisites are met as follows:

  • Make sure that Guest Additions are properly installed on the guest VM. Then reboot the VM.
  • Users in a guest Ubuntu must be in the group vboxsf to be able to access shares. Then reboot the VM a second time.

If you are using a recent release of Virtual Box, you can automatically mount the shared folder on creation.

After a reboot of the guest, this shared folder will be mounted to the guest directory /media//sf_ accessible to all users who had been made member of the group vboxsf.

Key parameter is *Name*

Important: But if it fails, then you need to mount manually using the command below:

sudo mount -t vboxsf Public /media/sf_Public

Note that the name of the shared folder depends on the key parameter inside the picture above, which I have chosen the name to be "Public".

In the picture, the host folder is /tmp. But this may not be a good idea since this folder will be automatically deleted by the system upon shutdown.

Joshua Kan

Posted 2016-07-12T00:10:10.550

Reputation: 111