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 as a guideline, Linux knowledge is assumed…
Manually installing VBoxGuestAdditions [windows]
[host] # vboxmanage guestcontrol updateadditions "vbox_name" --source /usr/share/virtualbox/VBoxGuestAdditions.iso --verbose
To easy… from the host command line, the guest additions are installed automagically on the Windows host machine.
Manually installing VBoxGuestAdditions [linux]
0. Guest: Common Errors
1. Host: ‘Putting the Additions in the DVD drive’
2. Guest: Mount the DVD
3. Guest: Install Additions (in case of errors, see 0.)
4. Guest: Unmount the DVD
0. Common Errors: Make sure GCC, MAKE and KERNEL-DEVEL (headers) are installed…
[guest] # yum install gcc make <kernel-devel...> (or similar package command for your distribution)
If not installed, you might run into next trouble:
[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.
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...> [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
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
1d. 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
2. Mount the DVD drive on Guest OS
[guest] # mkdir /mnt/dvd [guest] # mount -t iso9660 -o ro /dev/dvd /mnt/dvd
3. Install VBoxLinuxAdditions
[guest] # cd /mnt/dvd [guest] # ./VBoxLinuxAdditions.run
If you encounter errors here, see: ‘0. Common Errors‘.
4. 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
[guest] # /opt/VBoxGuestAdditions-4.0.8/uninstall.sh
Adding/removing shared folders to VirtualBox
Adding shared folders without a VirtualBox GUI is done like this, “vbox_name” is the name of your virtual machine, “–name install” is the name of the vboxsf name in the guest, “–hostpath /install” is the folder on your host system.
[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
Done… Happy sharing!