Accessing Mac OS X harddrive from Ubuntu in VirtualBox via shared folders
I installed Ubuntu in a VirtualBox machine on OS X (pretty easy and straightforward), but to access a Mac harddrive from Ubuntu was slightly more complicated.
I. Install Guest Additions
Firstly, it is necessary to install the VirtualBox’s Guest Additions to the host system:
-
Choose in the VitualBox’s menu:
Devices->Install Guest Additions…
It mounts a new ISO for the host system. -
A new CD appears in Ubuntu (or mount it). Run as root the
VBoxLinuxAdditions-x86.runinstallation script (because it is an Intel based Mac) in a Terminal window:cd /media/cdrom sudo VBoxLinuxAdditions-x86.run
- Probably you will be asked to restart Ubuntu.
Installing the Guest Additions has many advantages such as adopting screen resolution (your window size is the system resolution, i.e. no scrollbars), easy mouse mode (no need to press the left command button to release the mouse cursor) and, what we are looking for, shared folders.
II. Create Shared Folder
The goal is to access a shared folder, what is an easier way than to use sshd or Samba.
-
Choose in the VitualBox’s menu:
Devices->Shared Folders... - Click on the Add new shared folder button.
-
Choose a Folder Path - a folder on your Mac harddrive, e.g.
/Users/ondrej/Pictures.
Choose a Folder Name - a name that identifies this shared folder in Ubuntu (as a host system), e.g.pictures.
Select Make Permanent - if you would like to persist this shared folder definition.
Click on OK. - Click OK to close the list of shared folders.
III. Mount Shared Folder
Mount the created shared folder into a folder with permissions for your user. Let’s open a Terminal window on Ubuntu and:
- Create a folder where will be the shared folder mounted. (Skip this step if have already a folder for this.)
mkdir DIR
e.g.
mkdir share
- Get your user
uid.id
The result will be something like:
uid=1000(ondrej)gid=1000(ondrej)groups=4(adm),20(dialout),24(cdrom), 46(plugdev),112(lpadmin),119(admin),120(sambashare),1000(ondrej)
so uid of my user is 1000.
- Mount the shared folder
SHARED_FOLDER_NAMEinto folderMOUNTED_FOLDERwith ownership for user with uidUSER_IDas root:sudo mount -t vboxsf -o uid=USER_ID SHARED_FOLDER_NAME MOUNTED_FOLDER
e.g.
sudo mount -t vboxsf -o uid=1000 pictures share
- The mounted folder
MOUNTED_FOLDER(e.g.share) contains files from the shared folder on your Mac harddrive.
Enjoy :)










