Thursday, October 10, 2013

Installing and debugging VirtualBox Guest Additions for Linux (Ubuntu 12.10 64-bit) on a Mac OSX 10.8.5 host

I wanted to install the VirtualBox Guest Additions for Ubuntu 12.10 64-bit on Mac OSX 10.8.5 (I'm using VirtualBox 4.2.18 r88780).
However, after clicking on Devices -> Install Guest Additions... (which mounts a CD image on the VM) and following the installation I noticed that it complained about the kernel headers being missing.
"The headers for the current running kernel were not found. If the following module compilation fails then this could be the reason.

Building the main Guest Additions module!

Looking at /var/log/vboxadd-install.log showed this:
"/tmp/vbox.0/Makefile.include.header:97: *** Error: unable to find the sources of your current Linux kernel. Specify KERN_DIR= and run Make again. Stop."

After reading this web page:

I run the following:
$ sudo apt-get update

$ apt-cache search linux-headers-$(uname -r)
linux-headers-3.8.0-30-generic - Linux kernel headers for version 3.8.0 on 64 bit x86 SMP

$ sudo apt-get install linux-headers-$(uname -r)
After that, the update package UI prompted me to install some more updates.
After that, I got prompted to restart the VM which I did.

NOE: Later in the post you will see that it did not go as expected. Perhaps the installation of the headers failed but I got distracted with the UI prompt.

When I rebooted I noticed that I was about to run out of space; I needed to resize the harddrive of the VM.
I found this question/answer and I run this to make my vdi file be 20GBs instead of 8GBs:
$ VBoxManage modifyhd ~/VirtualBox\ VMs/Ubuntu\ 12.10\ 64-bit/Ubuntu\ 12.10\ 64-bit.vdi --resize 20000
Then, I realized that making the vdi file bigger is not sufficient; you need to change the partitions. I read this post which lead me to do this:
  • I downloaded the GParted ISO -
  • I mount it and started the VM which booted into it (follow the steps from the referred blog post)
  • Here's a screenshot of GParted after resizing the partitions:

Once resized, it was not clear to me how to shut things down; so I did a hard stop of the VM.
I removed the GParted ISO through VirtualBox's GUI after the VM stopped and started the VM again.

The Guest Additions failed to install again as the VM still had a very small screen resolution and sharing folders with the host was not yet working. Trying to install them again failed in the same way as in the beginning of this post.

I re-tried running again the following:
sudo apt-get install linux-headers-$(uname -r)
and run the Guest Additions installation again.

This time it worked fine:
Building the main Guest Additions module ...done!
Perhaps the headers failed to install last time and I got distracted with the "new updates" GUI prompt.

I'm happy now with my VM :)

No comments:

Post a Comment