Friday, November 29, 2013

Centos Virtual Box Makefile:183: *** Error: unable to find the sources of your current Linux kernel

When installing virtual box and running /etc/init.d/vboxdrv setup, you get an error message:





This error message is caused when the vboxdrv script can't find the kernel sources.

First make sure the kernel sources are installed. They should be under /lib/modules




There are 2 directories, one for 64 bits. cd into it and take a look. If your sources aren't installed then this directory is blank. Run: sudo yum install kernel-devel.x86_64

Example:


[dc@localhost kernels]$ sudo yum install kernel-devel.x86_64
Loaded plugins: fastestmirror, refresh-packagekit, security
Loading mirror speeds from cached hostfile
 * base: centos.mirror.facebook.net
 * contrib: mirror.hmc.edu
 * epel: mirrors.solfo.com
 * epel-debuginfo: mirrors.solfo.com
 * epel-source: mirrors.solfo.com
 * extras: mirror.keystealth.org
 * updates: mirror.web-ster.com
Setting up Install Process
Resolving Dependencies
--> Running transaction check
---> Package kernel-devel.x86_64 0:2.6.32-358.23.2.el6 will be installed
--> Finished Dependency Resolution

Dependencies Resolved

================================================================================
 Package            Arch         Version                    Repository     Size
================================================================================
Installing:
 kernel-devel       x86_64       2.6.32-358.23.2.el6        updates       8.2 M

Transaction Summary
================================================================================
Install       1 Package(s)

Total download size: 8.2 M
Installed size: 24 M
Is this ok [y/N]: y
Downloading Packages:
kernel-devel-2.6.32-358.23.2.el6.x86_64.rpm              | 8.2 MB     01:06  
Running rpm_check_debug
Running Transaction Test
Transaction Test Succeeded
Running Transaction
  Installing : kernel-devel-2.6.32-358.23.2.el6.x86_64                      1/1
  Verifying  : kernel-devel-2.6.32-358.23.2.el6.x86_64                      1/1

Installed:
  kernel-devel.x86_64 0:2.6.32-358.23.2.el6                                  

Complete!


Then modify by adding 2 lines to the /etc/init.d/vboxdrv program add the path to KERN_DIR and export it.














You should have 2 added lines to your /etc/init.d/vboxdrv script

PATH=/sbin:/bin:/usr/sbin:/usr/bin:$PATH
DEVICE=/dev/vboxdrv
KERN_DIR="/usr/src/kernels/2.6.32-358.23.2.el6.x86_64"
LOG="/var/log/vbox-install.log"
VERSION=4.3.2
MODPROBE=/sbin/modprobe

if $MODPROBE -c | grep -q '^allow_unsupported_modules  *0'; then
  MODPROBE="$MODPROBE --allow-unsupported-modules"
fi

[ -f /etc/debian_release -a -f /lib/lsb/init-functions ] || NOLSB=yes
[ -f /etc/vbox/vbox.cfg ] && . /etc/vbox/vbox.cfg
export BUILD_TYPE
export USERNAME
export USER=$USERNAME
export KERN_DIR

Everything but the bolded lines are the same as before.

Run the /etc/init.d/vboxdrv setup again:


3 comments: