Hello all.
I use virtualbox for every experiment i do, and i need to use kernel-2.6.27 in my laptop because of my intel wireless card. So, using gentoo, i get an error when compiling virtualbox-modules using the 2.6.27 kernel.
Here is a quick fix for it.
(as root)
copy the vbox-kernel-module-src-1.6.4.tar.bz2 in /usr/portage/distfiles to some where else. Uncompress the file
tar -jxvf vbox-kernel-module-src-1.6.4.tar.bz2
A vboxdrv directory will be created. Enter the new directory
cd vboxdrv
Now, backup the following files (the paths will always be having vboxdrv as the main):
- SUPDRV.h
- linux/SUPDrv-linux.c
Edit SUPDRV.h and remove the line that contais include <asm/semaphore.h> (Line 104)
(…)
# include <linux/string.h>
# include <linux/spinlock.h>
# include <linux/slab.h>
# if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 27)
# include <linux/semaphore.h>
# else /* older kernels */
# include <asm/semaphore.h>
# endif /* older kernels */
//# include <asm/semaphore.h> << - Coment out or remove this line
# include <linux/timer.h>
(…)
Now, edit linux/SUPDrv-linux.c and change the following line (line 1331)
smp_call_function(VBoxDrvLinuxGipResumePerCpu, pDevExt, 0 /*retry*/, 1 /* wait */);
to
smp_call_function(VBoxDrvLinuxGipResumePerCpu, pDevExt, 1 /* wait */);
Save and rebuild the module
Since we are in gentoo, we have two options
- Doing things at Gentoo Way (the prefered method)
- We build the kernel module
The Gentoo Way
The Gentoo way involves compressing the file, putting it in /usr/portage/distfiles, rebuilding the Manifest and emerging virtualbox-modules.
Compress the vboxdrv directory (we’ll change the filename later):
tar -jcvf vboxdrv.tar.bz2 vboxdrv
Removing the old file (the one without the changes) and copying it to /usr/portage/distfiles
rm -f /usr/portage/distfiles/vbox-kernel-module-src-1.6.4.tar.bz2
cp ~/vboxdrv.tar.bz2 /usr/portage/distfiles
cd /usr/portage/distfiles
mv vboxdrv.tar.bz2 vbox-kernel-module-src-1.6.4.tar.bz2
Now, we have the new module renamed and almost ready for emerge. We need to go to /usr/portage/app-emulation/virtualbox-modules and re-digest the ebuild (the checksum of the file has changed)
cd /usr/portage/app-emulation/virtualbox-modules
rm -f Manifest
ebuild virtualbox-modules-1.6.4.ebuild digest
Now, we need to remove the temporary directory that portage uses to compile the module.
rm -rf /var/tmp/portage/app-emulation
now, just emerge it
emerge -av virtualbox-modules
and everything should work
Building the Kernel Module
After the change, in the vboxdrv directory just type:
make
make install
modprobe vboxdrv
Now, we have a working vboxdrv with kernel 2.6.27
Somethings of this solution have been taking from ubuntu forums