Sometimes you don’t want to use a lot of disk space on your VirtualBox for install software or any ‘temporary’ need of space.

Adding shared folders from your host to your VirtualBox guest is a good option to use. If you have a Windows guest and a GUI based Host, it it’s very easy; click, click, done.

BUt if you are stuck with only a command line based guest and or host, it a bit more complex. Please use this post a guideline, Linux knowledge is assumed…

Adding/removing shared folders to VirtualBox

[host] # vboxmanage sharedfolder add "vbox_name" --name install --hostpath /install --automount
[host] # vboxmanage sharedfolder remove "vbox_name" --name install

On guest automounted to ‘/media/sf_install’, otherwise mount (again) with:

[guest] # mount -t vboxsf install /mnt/install

What if in case of the vboxfs mounting error

/sbin/mount.vboxsf: mounting failed with the error: No such device

We are probably missing VBoxGuestAdditions (vboxfs). For a Windows guest we can use the following command:

[host] # vboxmanage guestcontrol updateadditions "vbox_name" --source /usr/share/virtualbox/VBoxGuestAdditions.iso --verbose

If we are using Linux, we might need to do it manually!

Manually installing VBoxGuestAdditions

0. Make sure GCC, MAKE and KERNEL-DEVEL are installed…

[guest] # yum install gcc make kernel-devel
(or similar package command for your distribution)

If not installed, you might run into next troubles:

[guest] # cat /var/log/vboxadd-install.log
Makefile:23: *** Error: unable to find the sources of your current Linux kernel. Specify KERN_DIR=<directory> and run Make again..  Stop.
Creating user for the Guest Additions.
Creating udev rule for the Guest Additions kernel module.

[GOTO 1. if you do not see these errors...]

To see what went wrong run ‘/etc/init.d/vboxadd setup’:

[guest] # /etc/init.d/vboxadd setup
Removing existing VirtualBox DKMS kernel modules           [  OK  ]
Removing existing VirtualBox non-DKMS kernel modules       [  OK  ]
Building the VirtualBox Guest Additions kernel modules
The headers for the current running kernel were not found. If the following
module compilation fails then this could be the reason.
The missing package can be probably installed with
yum install kernel-devel-2.6.18-238.el5                    [FAILED]

Your system does not seem to be set up to build kernel modules.
Look at /var/log/vboxadd-install.log to find out what went wrong.
Once you have corrected it, you can run
/etc/init.d/vboxadd setup
to build them.
Doing non-kernel setup of the Guest Additions              [  OK  ]

Correct what went wrong and run ‘/etc/init.d/vboxadd setup’ again:

[guest] # yum install gcc make kernel-devel
(yada yada yada)
[guest] # /etc/init.d/vboxadd setup
Removing existing VirtualBox DKMS kernel modules           [  OK  ]
Removing existing VirtualBox non-DKMS kernel modules       [  OK  ]
Building the VirtualBox Guest Additions kernel modules
Your guest system does not seem to have sufficient OpenGL support to enable
accelerated 3D effects (this requires Linux 2.6.27 or later in the guest
system).  This Guest Additions feature will be disabled.
Building the main Guest Additions module                   [  OK  ]
Building the shared folder support module                  [  OK  ]
Doing non-kernel setup of the Guest Additions              [  OK  ]
Starting the VirtualBox Guest Additions                    [  OK  ]

1a. Find the IDE Controller device numbers

[host] # vboxmanage showvminfo "vbox_name" | grep "Storage Controller Name"
 Storage Controller Name (0):            IDE controller

1b.Get the port and device numbers

[host] # vboxmanage showvminfo "vbox_name" | grep "IDE controller"
 IDE controller (1, 0): Empty

1c. If not found, add it

[host] # vboxmanage storagectl "vbox_name" --name "IDE controller" --add ide

2. Attach the VBoxGuestAdditions.iso as dvddrive

Port and device numbers needed here!

[host] # vboxmanage storageattach "vbox_name" --storagectl "IDE controller" \
--port 1 --device 0 --type dvddrive \
--medium /usr/share/virtualbox/VBoxGuestAdditions.iso

3. Mount the DVD drive on Guest OS

[guest] # mkdir /mnt/dvd
[guest] # mount -t iso9660 -o ro /dev/dvd /mnt/dvd

4. Install VBoxLinuxAdditions

[guest] # cd /mnt/dvd
[guest] # ./VBoxLinuxAdditions.run

5. Done? Unmount and remove

[guest] # umount /dev/dvd
[host] # vboxmanage controlvm "vbox_name" poweroff
[host] # vboxmanage storageattach "vbox_name" --storagectl "IDE controller" \
--port 1 --device 0 --type dvddrive --medium emptydrive

Uninstall VBoxGuestAdditions

[guest] # /opt/VBoxGuestAdditions-4.0.8/uninstall.sh

VirtualBox downloads

http://download.virtualbox.org/virtualbox/

Done… Happy sharing!

[guest]