virtualbox

VirtualBox shared folders with Ubuntu Server guest

Reading time of 511 words
3 minutes
Reading time of 511 words ~ 3 minutes


Did you find this article helpful?
Please consider tipping me a coffee as a thank you.
Ko-fi Buy Me a Coffee
Did you find this article helpful? Please consider tipping me a coffee or three as a thank you.
Tip using Ko-fi or Buy Me a Coffee

Shared folders is a nifty way that VirtualBox allows guest operating system to access files stored on your host system. I find it very convenient to share my host’s download directory with my guest servers. So that way I do not need to type out long, sometimes cryptic URLs for software downloads packages I might want to install onto my guest systems.

In this example I will be creating a shared folder within VirtualBox that will link my c:\users\ben\downloads directory with one on the Linux box.

Now let’s start;

Within VirtualBox, select the guest machine you wish to contain the shared folder.

Press the Settings button.

  1. In the Settings dialog, press Shared Folders tab.
  2. Click the Add Shared Folder button.
  3. In the popup dialog, select the directory you want to share with the guest machine. In my case I will be choosing the directory c:\users\ben\downloads.
  4. Give the share a simple, but descriptive name.
  5. I would suggest selecting the Read-only checkbox. This will mean the guest operating system will not be able to modify any files or directories on within the shared folder.
virtualbox

Start your guest machine and login as normal.

Select Devices, CD/DVD Devices, VBoxGuestAdditions.iso.

virtualbox

We will now mount the VirtualBox Guest Additions.iso CD

sudo mount /dev/cdrom /media/cdrom

If successful you should receive a message about the block device being mounted and that it is read-only.

We now need to install some software packages that are required by the VBoxGuestAdditions.iso but that are not installed by Ubuntu Server as default.

sudo apt-get install build-essential linux-headers-`uname –r`

I needed around 26.9 MB of downloads though your mileage might vary.

Once complete we run the Guest Additions install script. For 32bit users: sudo /media/cdrom/VBoxLinuxAdditions-x86.run For 64bit users: sudo /media/cdrom/VBoxLinuxAdditions-amd64.run

The installation should be an automated process and if everything runs okay you should receive messages informing you that the Guest Addition, folder support, OpenGL, non-kernal Guest Additions have been built. You should also receive an error message saying the Window System drivers have failed to install, which is fine because our guest machine is not running X-Windows.

Now I recommend rebooting the guest machine and re-logging in.

sudo reboot

For the final part of this process we need to mount our shared folder. But firstly we need to create a directory within the guest that we can mount the shared folder to. I recommend placing it in the /mnt directory, but you can place it anywhere and give it any name.

sudo mkdir /mnt/host-downloads

Now we just need to mount the shared folder to our newly created directory using the following command.

sudo mount –t vboxsf {host shared folder name} {guest mount directory}

So in my example I would do the following, please remember that Linux is case sensitive.

sudo mount –t vboxsf Downloads /mnt/host-downloads

Then I should be able to

cd /mnt/host-downloads
ls -sh

Now you can easy copy over Internet downloads onto your guest operating system.

cp {files} {guest home directory}

So I could do the following to copy the 125MB Railo install package to my guest machine.

cp railo-3.1.2.001-pl0-linux-installer.bin /home/ben

Written by Ben Garrett

Did you find this article helpful?
Please consider tipping me a coffee as a thank you.
Ko-fi Buy Me a Coffee
Did you find this article helpful? Please consider tipping me a coffee or three as a thank you.
Tip using Ko-fi or Buy Me a Coffee