Sunday, February 22, 2009

How to Access Shared Files from a Ubuntu Linux Guest Install in VirtualBox

Synopsis


This walkthrough describes how to access host-machine shared files from a guest installation of Ubuntu

This should work with other Linux distributions, but was designed for use with Ubuntu, specifically v6.10

Assumptions/Prerequesits


  • Virtualbox (newest version) is installed <--tested on 2.1.0

  • guest OS is a linux distribution, already installed <-- tested on ubuntu 6.10


Steps


The ubuntu guest OS should not be running
  1. In the VirtualBox interface, click on the Ubuntu installation and click Settings



  2. Under the Shared Folders option, ensure that the folders you want to share from the host computer are selected and named appropriately (the names will be referenced later)



  3. Start the virtual Ubuntu installation and log in


  4. While running the Ubuntu guest OS, click Devices >> Install Guest Additions
    note: if you haven't already downloaded and mounted the guest additions .iso, you should be directed to the download location in your browser and when the download completes, you should be prompted to 'mount' the iso in the ubuntu guest installation



  5. Open a terminal window by clicking applications >> accessories >> terminal



  6. Type the following commands (emphasized in bold), pressing enter between each line
    cd /media/cdrom

    sudo bash ./VBoxLinuxAdditions-x86.run
    note: for a 64 bit virtual OS, replace 86 with 64
    enter password when prompted -- this may take a few minutes...wait until you see a 'success' message
    exit hopefully, you saw the message 'Successfully Installed the VirtualBox Guest Additions' // Restart your guest system in order to complete the installation

    Now restart Ubuntu



  7. Verify that you are sharing folders on the host system by going to Devices >> Shared Folders and make note of the 'name' you are sharing the folder as -- you will need to reference this in the next step. Mine is located at C:\Media and I named it 'Media'...that will be used for this example and should be modified to fit your situation.




  8. Open a terminal again and type each of the following lines:
    mkdir windows-share
    note: this can be called anything you like as you are creating a folder which will point to your shared folders
    sudo mount -t vboxsf Media /home/nick/windows-share
    note: If your shared folder isn't called 'Media', then modify this name to reference the 'name' you called your share. Also change 'home/nick/windows-share' to 'home/[your user name]/[the directory you made]'
    Hopefully you didn't get an error message. next close the terminal window (type exit[enter])


  9. note: reference the tutorial text over the screenshot text, as I've tried to simplify it further after taking the screenshot

  10. Now enjoy the fruits...I simply went to places >> home then double-clicked my 'windows-share' folder to access the files



  11. Repeat process to share any further folders...it'll be faster this time!


You are finished, but...


It seems that these steps work to give you access to your files, but when you restart Ubuntu, the mounted folder is gone. To make it persistant (last through system restarts), do the following:

  1. Open the trusty terminal and type the following:
    sudo gedit /etc/rc.local [enter]



  2. Add the following line between the last line with a # before it and the exit 0 line:
    mount -t vboxsf Media /home/nick/windows-share
    where 'Media' is the name of your shared folder and '/home/nick/windows-share' is the directory you created to house the shared folders



  3. Be sure to save the changes, then exit the text editor and restart your computer to ensure it works. Add as many mount -t vboxsf ... lines to that file as necessary if you have multiple shared folders.


References


The following pages greatly helped when writing this:
http://ubuntu-tutorials.com/2007/10/13/installing-guest-additions-for-ubuntu-guests-in-virtualbox/
http://www.giannistsakiris.com/index.php/2008/04/09/virtualbox-access-windows-host-shared-folders-from-ubuntu-guest/

No comments: