I use VirtualBox to run Ubuntu as my LAMP stack for development. Configuring a proper LAMP stack on Mac is a pain in the ass and never worth the hassle. I used to use MAMP, which was fine, but it doesn’t work with modern versions of openssl, so it doesn’t work with Paypal and shit like that (older version of TLS have been retired).
I do my development on my Mac and then I share the drive where my code resides with the VirtualBox Ubuntu guest. But if you try to setup up share on the Vbox host to be called “Documents,” for example, and you want to mount it on your guest as “Documents,” it will fail. I have no idea way. It may actually be that the share name on the host can’t be the same as the folder you’re sharing. I’m not sure, I didn’t test that.
So this will not work if the host machine share folder is also named Documents.
sudo mount -t vboxsf -o uid=1000,gid=1000 Documents /media/Documents
You have to name your share something different, like MyDocs, or you get “device not found.”
But this will work.
sudo mount -t vboxsf -o uid=1000,gid=1000 MyDocs /media/Documents
Also note that on the guest, you have to have the Virtual Box guest extensions install to be able to mount vboxsf drives.
And if you want it to mount on boot, you need to put this in fstab.
MyDocs /media/Documents vboxsf rw,uid=1000,gid=1000 0 0
Now you may have an issue with this auto mounting on boot because the share might not be there when Ubuntu needs it to be there on boot.
One option is to add “vboxsf” to you /etc/modules file. That forces the vboxsf stuff to load earlier during boot. That totally worked for me.
The other option, which also worked for me, and seems a bit less hackish, is to add the _netdev options to the fstab line so it looks like this.
MyDocs /media/Documents vboxsf rw,uid=1000,gid=1000,_netdev 0 0
Also don’t check Auto-mount when you create the share on the VirtualBox host, it mounts the drive in /media/sf_MyDocs and it makes it all owned by root.vboxsf. I don’t like that, but it can work for some people. If you mount it yourself in Ubuntu, you have more control.
So there you have it. Now you should be able to mount your shared drive on your VirtualBox Ubuntu guest on boot.
Don’t forget those guest extensions on the guest machine.
sudo apt-get install virtualbox-guest-utils virtualbox-guest-additions-iso