Patrick Ward words, code, and music

Sharing Folders and Adding VirtualBox Guest Additions to Ubuntu on Mac OS X

I decided to try out VirtualBox and run some instances of Ubuntu while I work on a client Magento site. However, I had some difficulty understanding how to share a folder within the Mac environment.

I was tripped up while locating the “VBoxGuestAdditions.iso” file. I couldn’t find it anywhere! Until, I realized that it resided within the application package of the “VirtualBox” application under the “/Applications” folder.

Specifically, it’s located in /Applications/VirtualBox/Contents/MacOS/VBoxGuestAdditions.iso

However, that location is not accessible from within the open dialog box that VBox provides while adding a CD to the CDRom drive (i.e. you can’t choose “Show Package Contents” to get inside the applcation folder). So, I copied the iso file over to the Desktop as a temporary stopgap. Once, I had that figured out, adding the “Guest Additions” and sharing the folder was fairly simple.

  • Open the “Settings –> Storage” for the VM you’re setting Guest Additions up for.
  • Select the empty CDROM IDE controller
  • Add the “VBoxGuestAdditions.iso” on the desktop to the CDROM
  • Mount the cdrom from within the Ubuntu guest VM:
mount /dev/cdrom /mnt
  • From within the guest VM run the additions script for the Linux environment:
cd /mnt
sudo ./VBoxLinuxAdditions.run
  • Reboot the guest OS
sudo reboot
  • Add your user and any other users that will need access (e.g. www-data) to the vboxsf group:
usermod -a -G vboxsf <username>
usermod -a -G vboxsf www-data
  • Back in VirtualBox on the host (my Mac in this case):
    1. Open “Settings –> Shared Folders” for the guest VM
    2. Add the host folder you want to share (giving it a shared name for the VM)
    3. Make sure to check both “Auto-mount” and “Make Permanent” to ensure the shared folder is available between sessions
    4. Logout of the guest OS or reboot
  • The shared folders on a Linux system (such as my Ubuntu VM) are available in the /media folder when mounted and are prepended with sf_ by default.
/media/sf_<shared-name>

For example, I named my share “magento-1.7” in the VBox shared folders settings.

Therefore, the share on the Ubuntu guest OS was available in /media/sf_magento-1.7