Hello everyone,
I had some trouble recently trying to update the VirtualBox Guest Additions from v4.1.4 to v4.1.6 for my Backtrack 5 virtual machine after upgrading the kernel from 2.6.38 to 2.6.39.4. The VirtualBox guest additions compile modules against the kernel source tree which needs to be the same kernel source version of the running kernel. Without the kernel source and headers, the compile fails and the guest drivers do not work properly. I figured out how to fix it and wrote up this silly script to update the guest additions for me.
Common symptoms of faulty guest additions:
- mouse is stuck in the VM winodw and does not auto release when attempting to move outside of the VM
- bidirectional clipboard does not work
- 'dmesg | grep vbox' shows vboxguest loading errors, like this:
-bungfishCode:vboxguest: version magic '2.6.38 SMP mod_unload ELAN ' should be '2.6.39.4 SMP mod_unload ELAN ' vboxguest: version magic '2.6.38 SMP mod_unload ELAN ' should be '2.6.39.4 SMP mod_unload ELAN '
Omaha 2600
P.S. I've also used this script to successfully update from v4.1.4 to v4.1.8 (thanks to the magic of VMs!) Hope this helps! Enjoy!
P.P.S. I see that a post by smilerclan listed a better symlink solution so I updated the script. My solution left this error unresolved:
This new version of the script now takes care of these errors. Thanks, smilerclan!Code: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.
Code:#!/bin/bash # Upgrade VirtualBox Guest Additions on Backtrack # bungfish@gmail.com # last updated on 2012-02-07 # Load the VBoxGuestAdditions.iso file into the CD-ROM drive before running this script as root: # Devices > CD/DVD Devices > VBoxGuestAdditions.iso # or by selecting "Install Guest Additions..." from the "Devices" menu. # # Get the kernel version and assign it to a variable: VERSION=`uname -r` # Attempt to mount the VirtualBox Guest Additions ISO: echo '*** Attempting to mount the VirtualBox Guest Additions ISO... (this may take a minute)' mount -o ro /dev/sr0 /mnt # Test to see if the VBoxGuestAdditions.iso is mounted: if [ ! -f /mnt/VBoxLinuxAdditions.run ]; then echo '*** VirtualBox Guest Additions ISO could not be mounted.' echo '*** Please select "Install Guest Additions..." from the "Devices" menu first.' exit 1 fi # Update the local apt-get repositories: apt-get update # Install the newest kernel source and headers: apt-get -y install linux-source linux-headers # Rename the current symbolic link to the kernel source directory: mv /usr/src/linux /usr/src/linux-old-`date +%s` # Uncompress and extract the kernel source if it does not exist: if [ ! -d /usr/src/linux-source-$VERSION ]; then echo '*** Uncompressing and extracting the kernel source tarball...' tar -xjf /usr/src/linux-source-$VERSION.tar.bz2 --directory /usr/src fi # Uncompress and extract the kernel headers if it does not exist: if [ ! -d /usr/src/linux-headers-$VERSION ]; then echo '*** Uncompressing and extracting the kernel headers tarball...' tar -xjf /usr/src/linux-headers-$VERSION.tar.bz2 --directory /usr/src fi # Create a new symlink to the updated kernel source directory: ln -s /usr/src/linux-source-$VERSION /usr/src/linux # Create a new symlink to the modules header source directory: ln -s /usr/src/linux-headers-$VERSION /lib/modules/$VERSION/build # Run the VirtualBox Guest Additions installer: /mnt/VBoxLinuxAdditions.run # Unmount the VirtualBox Guest Additions ISO: umount /dev/sr0 # All finished: echo '*** Reboot this virtual machine to activate the new VirtualBox Guest Additions!' # "Reboot yo' PC": (uncomment to activate auto reboot, otherwise do it manually) #shutdown -r now # # Updated guest additions allow for: # - automatic mouse control catch and relase. # - bidirectional clipboard copy-pasta. # - dynamic video display resolutions. # - and many other features. # # ProTip: # - You may want to clean out the old kernel sources in /usr/src some day # - Remember to eject the VBoxGuestAdditions.iso by going to: # Devices > CD/DVD Devices > VBoxGuestAdditions.iso # after you are finished. # EOF


