Results 1 to 1 of 1

Thread: How to: Upgrading failed VirtualBox Guest Additions after updating the kernel

Threaded View

  1. #1
    Just burned his ISO bungfish's Avatar
    Join Date
    Sep 2010
    Location
    Omaha
    Posts
    5

    Smile How to: Upgrading failed VirtualBox Guest Additions after updating the kernel

    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:
    Code:
    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 '
    -bungfish
    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:
    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.
    This new version of the script now takes care of these errors. Thanks, smilerclan!

    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
    Last edited by bungfish; 02-07-2012 at 12:58 PM. Reason: eliminated a bunch of typos.

Similar Threads

  1. Virtual Box Guest Additions BT5 R1 2.6.39.4 Fix
    By smilerclan in forum BackTrack 5 Beginners Section
    Replies: 0
    Last Post: 08-26-2011, 12:18 PM
  2. Virtualization guest additions?
    By masteroc in forum Beginners Forum
    Replies: 4
    Last Post: 03-31-2011, 08:08 PM
  3. Upgraded to R2, get VBox Guest Additions Error
    By falseteeth in forum Beginners Forum
    Replies: 6
    Last Post: 01-19-2011, 01:56 AM
  4. Backtrack 4r2 and Virtualbox Guest Additions
    By ghee22 in forum Beginners Forum
    Replies: 13
    Last Post: 12-11-2010, 11:31 AM
  5. BT4 Pre-Final - Cannot Install VirtualBox Guest Additions
    By squeege in forum OLD BT4beta Software Related Issues
    Replies: 1
    Last Post: 06-04-2009, 02:28 AM

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •