Sunday, August 4, 2013

How I shared MAC OS X folder to Ubuntu Guest OS in Virtual Box

Here is How I installed VirtualBox CD in Ubuntu Server from command line.

I have presented here the steps through which I was able to 
Step 0: Download and install Virtual Box Guest Additions for enabling shared folder and some other tasks.

Step 1: Create new CD/DVD controller if not present. This option is generally not needed if you have not changed anything after install. You can skip to step 2.
  1. Click the Virtualbox session and click settings
  2. Click Storage
  3. Click Controller: Ide Controller under Storage Tree
  4. There are small icons of cd and Hard disk with plus (+) sign
  5. Click on the + sign with cd to add CD/DVD image
  6. On the prompt, click Leave Empty. You can optionally mount VirtualBoxGuestAdditions.iso image on the prompt. But for now you can safely click leave empty
  7. Now click ok and close
Step 2: Install Guest Additions
  1. Start the VirtualBox Session with Ubuntu Server
  2. On the top menu, click Devices > Install Guest Additions. This will add the VirtualBoxGuestAdditions.iso cd to the cd drive.
  3. Find this cd image in the guest Ubuntu server OS. It might be present in
    /dev/cdrom or /dev/disk/by-label/VBOXADDITIONS_x.x.x.x
    where x are any numbers which represent the VirtualBox  version.
Step 3: Mount the cdrom to a folder
  1. Make a new folder where you want to mount the cd. e.g.
    sudo mkdir -p /mnt/cdrom
  2. Type following command to mount the cd to that folder
    sudo mount /dev/disk/by-label/VBOXADDITIONS_x.x.x.x /mnt/cdrom
  3. Now the image is mounted to folder /mnt/cdrom
Step 4: Browse the CD and run the installation script
  1. Browse the cd by going to /mnt/cdrom
    cd /mnt/cdrom
  2. Run the shell script related to the version of linux or windows you are in. for x86 Ubuntu you can run
    sudo ./

Here is how I shared MAC OS X folder with Ubuntu Guest OS in VirtualBox

Step 5: Define shared folder
  1. Click Devices on the menu
  2. Click Shared Folders ...
  3. Click + sign
  4. Click Folder Path > Other
  5. Browse the folder and click Choose
  6. Give it a share name e.g.  hostshare
Step 6: Mount the shared folder
  1. Find your userid by typing id in the command prompt of guest
    uid:0(root) gid:0(root) groups:0(root).
    You need uid of the user account for you to be able to write to the mounted folder. Here uid is 0 for root. It might be different for your case.
  2. Mount the share by following command
    sudo mount -t <type> -o <share name> <path where it is to be mounted> e.g.
    sudo mount -t vboxsf -o uid=0 hostshare /mnt/share
    The /mnt/share folder must be present before above command is executed.
  3. Now you can browse the files in that folder.
  4. Optionally you can mount it automatically by adding following line to the file /etc/fstab
    <sharename> <mount folder> vboxsf uid=0,gid=0 0 0 (with your uid and gid) e.g.
    hostshare /mnt/share vboxsf uid=0,gid=0 0 0
    The values of uid and gid can be found by executing the id command as described above.

The methods described above can be used to share MAC OS X file and folder with any Linux/Unix distributions.

No comments:

Post a Comment