VirtualBox and Shared Folders

September 9, 2011

I’ve just spent a whole day working this out, so I absolutely have to share this with anyone who cares. Here’s my environment:

  • Windows 7 SP1 Host
  • VirtualBox 4.1.2
  • Ubuntu 10 x86 Guest
  • Ubuntu 11 x64 Guest

I hit two things during this install: that a shared folder couldn’t be read by the Ubuntu user; and the VM crashed when I shut it down after adding the Guest Addons. I worked out both issues, and for the benefit of all am going to write them down in my blog.

Shared Folder Cannot be Read

After following all the docs I could find about setting up a shared folder, I realised it was doing what it was supposed to but there was a permissions problem. When I tried to view the /media/sf_sharedDiskName directory (which is where Virtual Box mounts the shared folder from the host) I got an error saying I didn’t have permission to read that folder. I needed to add the vboxsf group to my user’s groups, and reboot and that did the trick. Here’s the procedure to add a shared drive:

  1. Add the shared drive using the VirtualBox UI (either with VM started or stopped).
  2. Start up the VM if it isn’t running and add the vboxsf group to your user. Do this using the System > Administration > Users and Groups dialog. Click Manage Groups and look for the vboxsf group. Select it and click Properties and add your user to this group.
  3. Restart the VM.

Voila it works! So easy when you know how!

VM Crashed When Shutdown/Restarted

The other issue I had was the VM crashing when I shut it down or turned it off. The crash happened almost immediately on issuing the shutdown/restart command. I worked out that I had 3D Acceleration checked in the VM Settings and this was the culprit. You won’t see this crash until you install the Guest Addons, then the crashes will begin on shutdown. So, to fix this, turn off 3D acceleration.