Virtualbox allows you to share files between the guest and host operating systems. For the purposes of this tutorial, the host OS is Windows 7 and the guest OS is CentOS 5.5, although we could use any flavor of Linux. This tutorial also assumes that you have guest additions installed.
To start with, create a folder on the host operating system. You can exist anywhere you like. For ease of access, we'll just place ours on the desktop. To do this, right-click on the Windows desktop and select "New > Folder." Give this folder the name "share."
Next, run Virtualbox and start the guest operating system. From Virtualbox's menu, select "Devices > Shared Folders."
This will open up a dialog box with the title "Shared Folders."
On the top right of the dialog, click on the folder icon with the green plus sign. This will open up a file browser.
Browse to the share folder that was created on the host desktop and make sure to check the box labeled "Make Permanent." If this box is unchecked, it will create a transient share folder that will disappear the next time the guest OS is started. Click OK. The share should now appear in the list under the heading labeled "Machine Folders."
After clicking OK, the configuration is complete on the host operating system. Now we need to configure the guest OS. Login to the guest machine, and open up a terminal. We need to create a directory for the shared folder to reside. This can be anywhere on the filesystem, but for our purposes, we will be creating the directory /share. Since we will be creating this directory in the root folder, we need be root. Either change to the root user using su -, or prefix the command with sudo. We will be using sudo. Issue the following command:
sudo mkdir /share
Now we must mount the host's share folder to the /share directory we just created on the guest operating system. We could do this with the mount command, however that would require us to mount the folder every time we start the guest OS. Since we want this share to be permanent, it needs to be mounted on startup. To do this, we must add a line to the /etc/fstab file. We must be root to edit this file, so issue the following command:
sudo vi /etc/fstab
This will open up the /etc/fstab in vi. Scroll down to the bottom of the file, and push o to switch to edit mode and insert the following line at the end of the file:
share /share vboxsf defaults 0 0
The first column is the name of the share we are mounting, given to us from the name column of the shared folders dialog. The second column is the mountpoint, the name of the directory we created on the guest that we will be mounting the folder to. The third column is the filesystem type, and the remaining columns are various options, of which we will use the default setting. After adding the line, save and edit the editor using :wq.
At this point, everything is setup, and all that is required is a reboot of the guest OS for the system to reload the /etc/fstab file. But before we do so, it would be nice to have a shortcut to our share on our linux desktop. To do this, we need to create a symbolic link, and store it in the ~/Desktop directory. Make sure you are logged in as your normal user, and type the following into the terminal:
ln -s /share ~/Desktop/share
A link to the /share folder should now appear on your desktop.
Now, reboot the guest OS and test the shared folder by placing some files into it. If everything went well, the files should show up in the folder on both the host and guest operating systems.