Gixx-web.com presents:
Setting up a LAMP on a Virtual Box
An almost step-by-step tutorial

Folder sharing

Only one thing left from the tutorial and that is the file transfer between HOST and GUEST.

There are two things we have to do:

  1. select the folders on the HOST to share
  2. mount the shared folder on the GUEST to able to use it.

In the VM’s status bar, there are some nice icons which – as you may already noticed – are blinking upon activity. These are: Hard disk, CD, USB, Network (I've written about this last one before). The next icon is a faded gray folder icon which means you do not have any shared folders.

VirtualBox status bar

Right-click on it and a “Shared Folders...” menu will popup. Click on it and a new window will open where you can add, edit and remove shared folders.

Folder sharing

Give the Folder Name something easy to type, with no special characters and spaces otherwise there can be trouble with it. If the folder contains sensitive files, it is recommended to set the Read-only option, because I can tell from my own experience that it is easy to get confused and delete files without control. You know the joke about playing chess on the file system: “Pawn hits F8.”

So if you want your files to be safe, check the Read-only option and add a “Write” folder where the Ubuntu can write to.

Choose the Make Permanent option to make this folder to be shared every time you use this VM. Be sure that the Auto-mount option is not checked. It’s a bit buggy. We’ll do it in the professional way.

When you finished, it’s time to mount the folder. There’s no need to restart neither Ubuntu nor the VirtualBox.

In the traditional way we have to run the following command to mount a shared folder:

$> sudo mkdir /mnt/shared $> sudo mount –t vboxsf Shared /mnt/shared

But it’s far uncomfortable to do this upon every system startup. So we will edit the fstab file:

$> sudo mcedit /etc/fstab

In the editor insert the following line to the end of the file:

Shared /mnt/shared vboxsf defaults 0 0

Press F2 to save the file and F10 to exit. On next reboot the system will auto-mount the shared folder. If you want to share more folders, you need to create the target directory and edit the fstab file again to add the new name and path. For example:

Video /mnt/video vboxsf defaults 0 0

And that's all. Now you have a development environment of full value. Easy to use, easy to work with. I hope you enjoyed this tutorial and found the answers for all of the questions you had.

Comments: