Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

TL;DR: The running kernel version was older than the kernel source that VirtualBox found when trying to install. There is no need to build the source yourself; final resolution was to actually remove the newer version of kernel source, and install the matching version found in uname -r, all through yum.

History:

When trying to install VirtualBox-4.2 on a new CentOS server I was getting the following:

Your kernel headers for kernel 2.6.32-358.6.2.el6.x86_64 cannot be found at /lib/modules/2.6.32-358.6.2.el6.x86_64/build or /lib/modules/2.6.32-358.6.2.el6.x86_64/source.

So in following the instructions on CentOS I Need the Kernel Source I tried getting the source and I now have ~/rpmbuild/SOURCES/kernel-2.6.32-358.6.2.el6 with 2 folders: linux-x and vanilla-x.

I tried installing VirtualBox again but it errored about not finding kernel source so I also had to set up these symlinks:

/lib/modules/2.6.32-358.6.2.el6.x86_64/build -> /usr/src/kernels/2.6.32-358.6.2.el6.x86_64 /usr/src/kernels/2.6.32-358.6.2.el6.x86_64 -> /home/dirt/rpmbuild/BUILD/kernel-2.6.32-358.6.2.el6/vanilla-2.6.32-358.6.2.el6

But when trying to install VirtualBox now I get errors about needing to run make:

/var/log/vbox-install.log

Uninstalling modules from DKMS
Attempting to install using DKMS

Creating symlink /var/lib/dkms/vboxhost/4.2.18/source ->
                 /usr/src/vboxhost-4.2.18

DKMS: add completed.

Kernel preparation unnecessary for this kernel.  Skipping...

Building module:
cleaning build area...
make KERNELRELEASE=2.6.32-358.6.2.el6.x86_64 -C /lib/modules/2.6.32-358.6.2.el6.x86_64/build M=/var/lib/dkms/vboxhost/4.2.18/build...(bad exit status: 2)
Failed to install using DKMS, attempting to install without
make KBUILD_VERBOSE=1 SUBDIRS=/tmp/vbox.0 SRCROOT=/tmp/vbox.0 CONFIG_MODULE_SIG= -C /lib/modules/2.6.32-358.6.2.el6.x86_64/build modules
test -e include/linux/autoconf.h -a -e include/config/auto.conf || (            \
        echo;                                                           \
        echo "  ERROR: Kernel configuration is invalid.";               \
        echo "         include/linux/autoconf.h or include/config/auto.conf are missing.";      \
        echo "         Run 'make oldconfig && make prepare' on kernel src to fix it.";  \
        echo;                                                           \
        /bin/false)
mkdir -p /tmp/vbox.0/.tmp_versions ; rm -f /tmp/vbox.0/.tmp_versions/*

  WARNING: Symbol version dump /home/dirt/rpmbuild/BUILD/kernel-2.6.32-358.6.2.el6/vanilla-2.6.32-358.6.2.el6/Module.symvers
           is missing; modules will have no dependencies and modversions.

make -f scripts/Makefile.build obj=/tmp/vbox.0
  gcc -Wp,-MD,/tmp/vbox.0/linux/.SUPDrv-linux.o.d  -nostdinc -isystem /usr/lib/gcc/x86_64-redhat-linux/4.4.7/include -Iinclude  -I/home/dirt/rpmbuild/BUILD/kernel-2.6.32-358.6.2.el6/vanilla-2.6.32-358.6.2.el6/arch/x86/include -include include/linux/autoconf.h -D__KERNEL__ -Wall -Wundef -Wstrict-prototypes -Wno-trigraphs -fno-strict-aliasing -fno-common -Werror-implicit-function-declaration -Wno-format-security -fno-delete-null-pointer-checks -Os -m64 -mtune=generic -mno-red-zone -mcmodel=kernel -funit-at-a-time -maccumulate-outgoing-args -DCONFIG_AS_CFI=1 -DCONFIG_AS_CFI_SIGNAL_FRAME=1 -DCONFIG_AS_CFI_SECTIONS=1 -pipe -Wno-sign-compare -fno-asynchronous-unwind-tables -mno-sse -mno-mmx -mno-sse2 -mno-3dnow -Wframe-larger-than=2048 -fno-stack-protector -Wno-unused-but-set-variable -fno-omit-frame-pointer -fno-optimize-sibling-calls -Wdeclaration-after-statement -Wno-pointer-sign -fno-strict-overflow -fno-dwarf2-cfi-asm -fconserve-stack -include /tmp/vbox.0/include/VBox/SUPDrvMangling.h -I/lib/modules/2.6.32-358.6.2.el6.x86_64/build/include -I/tmp/vbox.0/ -I/tmp/vbox.0/include -I/tmp/vbox.0/r0drv/linux -I/tmp/vbox.0/vboxdrv/ -I/tmp/vbox.0/vboxdrv/include -I/tmp/vbox.0/vboxdrv/r0drv/linux -D__KERNEL__ -DMODULE -DRT_OS_LINUX -DIN_RING0 -DIN_RT_R0 -DIN_SUP_R0 -DVBOX -DRT_WITH_VBOX -DVBOX_WITH_HARDENING -DCONFIG_VBOXDRV_AS_MISC -DRT_ARCH_AMD64 -DVBOX_WITH_64_BITS_GUESTS  -DMODULE -D"KBUILD_STR(s)=#s" -D"KBUILD_BASENAME=KBUILD_STR(SUPDrv_linux)"  -D"KBUILD_MODNAME=KBUILD_STR(vboxdrv)"  -c -o /tmp/vbox.0/linux/SUPDrv-linux.o /tmp/vbox.0/linux/SUPDrv-linux.c
In file included from /home/dirt/rpmbuild/BUILD/kernel-2.6.32-358.6.2.el6/vanilla-2.6.32-358.6.2.el6/arch/x86/include/asm/unistd.h:5,
                 from include/linux/unistd.h:7,
                 from /home/dirt/rpmbuild/BUILD/kernel-2.6.32-358.6.2.el6/vanilla-2.6.32-358.6.2.el6/arch/x86/include/asm/seccomp_64.h:4,
                 from /home/dirt/rpmbuild/BUILD/kernel-2.6.32-358.6.2.el6/vanilla-2.6.32-358.6.2.el6/arch/x86/include/asm/seccomp.h:4,
                 from include/linux/seccomp.h:8,
                 from include/linux/sched.h:80,
                 from /tmp/vbox.0/r0drv/linux/the-linux-kernel.h:92,
                 from /tmp/vbox.0/linux/SUPDrv-linux.c:32:
/home/dirt/rpmbuild/BUILD/kernel-2.6.32-358.6.2.el6/vanilla-2.6.32-358.6.2.el6/arch/x86/include/asm/unistd_64.h:719:29: error: asm/asm-offsets.h: No such file or directory
make[2]: *** [/tmp/vbox.0/linux/SUPDrv-linux.o] Error 1
make[1]: *** [_module_/tmp/vbox.0] Error 2
make: *** [vboxdrv] Error 2

1) I'm not sure exactly where I am supposed to run these make commands
2) I tried running the commands in each BUILD/kernel-x/vanilla & linux folders but I got errors when doing it in the vanilla folder:

[dirt@loki kernel-2.6.32-358.6.2.el6]$ cd linux-2.6.32-358.6.2.el6.x86_64/
[dirt@loki linux-2.6.32-358.6.2.el6.x86_64]$ make oldconfig && make prepare
scripts/kconfig/conf -o arch/x86/Kconfig
#
# configuration written to .config
#
scripts/kconfig/conf -s arch/x86/Kconfig
  CHK     include/linux/version.h
  CHK     include/linux/utsrelease.h
  SYMLINK include/asm -> include/asm-x86
  CALL    scripts/checksyscalls.sh
[dirt@loki linux-2.6.32-358.6.2.el6.x86_64]$ cd ../vanilla-2.6.32-358.6.2.el6/
[dirt@loki vanilla-2.6.32-358.6.2.el6]$ make oldconfig && make prepare
scripts/kconfig/conf -o arch/x86/Kconfig
#
# configuration written to .config
#
scripts/kconfig/conf -s arch/x86/Kconfig
  CHK     include/linux/version.h
  CHK     include/linux/utsrelease.h
  SYMLINK include/asm -> include/asm-x86
  CC      arch/x86/kernel/asm-offsets.s
In file included from include/linux/fs.h:424,
                 from include/trace/events/kmem.h:8,
                 from include/linux/kmemtrace.h:12,
                 from include/linux/slub_def.h:13,
                 from include/linux/slab.h:162,
                 from include/linux/percpu.h:5,
                 from /home/dirt/rpmbuild/BUILD/kernel-2.6.32-358.6.2.el6/vanilla-2.6.32-358.6.2.el6/arch/x86/include/asm/local.h:4,
                 from include/linux/module.h:20,
                 from include/linux/crypto.h:21,
                 from arch/x86/kernel/asm-offsets_64.c:8,
                 from arch/x86/kernel/asm-offsets.c:4:
include/linux/percpu-rwsem.h:11: error: expected specifier-qualifier-list before 'local_t'
include/linux/percpu-rwsem.h: In function 'percpu_down_read':
include/linux/percpu-rwsem.h:19: error: 'struct percpu_rw_semaphore' has no member named 'locked'
include/linux/percpu-rwsem.h:21: error: 'struct percpu_rw_semaphore' has no member named 'mtx'
include/linux/percpu-rwsem.h:23: error: implicit declaration of function 'local_inc'
include/linux/percpu-rwsem.h:23: error: implicit declaration of function 'this_cpu_ptr'
include/linux/percpu-rwsem.h:23: error: 'struct percpu_rw_semaphore' has no member named 'counters'
include/linux/percpu-rwsem.h:25: error: 'struct percpu_rw_semaphore' has no member named 'mtx'
include/linux/percpu-rwsem.h:29: error: 'struct percpu_rw_semaphore' has no member named 'counters'
include/linux/percpu-rwsem.h: In function 'percpu_up_read':
include/linux/percpu-rwsem.h:49: error: implicit declaration of function 'local_dec'
include/linux/percpu-rwsem.h:49: error: 'struct percpu_rw_semaphore' has no member named 'counters'
include/linux/percpu-rwsem.h: At top level:
include/linux/percpu-rwsem.h:53: error: expected ')' before '*' token
include/linux/percpu-rwsem.h: In function 'percpu_down_write':
include/linux/percpu-rwsem.h:66: error: 'struct percpu_rw_semaphore' has no member named 'mtx'
include/linux/percpu-rwsem.h:67: error: 'struct percpu_rw_semaphore' has no member named 'locked'
include/linux/percpu-rwsem.h:69: error: implicit declaration of function '__percpu_count'
include/linux/percpu-rwsem.h:69: error: 'struct percpu_rw_semaphore' has no member named 'counters'
include/linux/percpu-rwsem.h: In function 'percpu_up_write':
include/linux/percpu-rwsem.h:76: error: 'struct percpu_rw_semaphore' has no member named 'locked'
include/linux/percpu-rwsem.h:77: error: 'struct percpu_rw_semaphore' has no member named 'mtx'
include/linux/percpu-rwsem.h: In function 'percpu_init_rwsem':
include/linux/percpu-rwsem.h:83: error: 'struct percpu_rw_semaphore' has no member named 'counters'
include/linux/percpu-rwsem.h:83: error: implicit declaration of function 'alloc_percpu'
include/linux/percpu-rwsem.h:83: error: 'local_t' undeclared (first use in this function)
include/linux/percpu-rwsem.h:83: error: (Each undeclared identifier is reported only once
include/linux/percpu-rwsem.h:83: error: for each function it appears in.)
include/linux/percpu-rwsem.h:84: error: 'struct percpu_rw_semaphore' has no member named 'counters'
include/linux/percpu-rwsem.h:87: error: implicit declaration of function 'local_set'
include/linux/percpu-rwsem.h:87: error: implicit declaration of function 'per_cpu_ptr'
include/linux/percpu-rwsem.h:87: error: 'struct percpu_rw_semaphore' has no member named 'counters'
include/linux/percpu-rwsem.h:88: error: 'struct percpu_rw_semaphore' has no member named 'locked'
include/linux/percpu-rwsem.h:89: error: 'struct percpu_rw_semaphore' has no member named 'mtx'
include/linux/percpu-rwsem.h: In function 'percpu_free_rwsem':
include/linux/percpu-rwsem.h:95: error: implicit declaration of function 'free_percpu'
include/linux/percpu-rwsem.h:95: error: 'struct percpu_rw_semaphore' has no member named 'counters'
include/linux/percpu-rwsem.h:96: error: 'struct percpu_rw_semaphore' has no member named 'counters'
cc1: warnings being treated as errors
In file included from /home/dirt/rpmbuild/BUILD/kernel-2.6.32-358.6.2.el6/vanilla-2.6.32-358.6.2.el6/arch/x86/include/asm/local.h:4,
                 from include/linux/module.h:20,
                 from include/linux/crypto.h:21,
                 from arch/x86/kernel/asm-offsets_64.c:8,
                 from arch/x86/kernel/asm-offsets.c:4:
include/linux/percpu.h: At top level:
include/linux/percpu.h:168: error: conflicting types for 'free_percpu'
include/linux/percpu-rwsem.h:95: note: previous implicit declaration of 'free_percpu' was here
In file included from include/linux/module.h:20,
                 from include/linux/crypto.h:21,
                 from arch/x86/kernel/asm-offsets_64.c:8,
                 from arch/x86/kernel/asm-offsets.c:4:
/home/dirt/rpmbuild/BUILD/kernel-2.6.32-358.6.2.el6/vanilla-2.6.32-358.6.2.el6/arch/x86/include/asm/local.h:19: error: conflicting types for 'local_inc'
/home/dirt/rpmbuild/BUILD/kernel-2.6.32-358.6.2.el6/vanilla-2.6.32-358.6.2.el6/arch/x86/include/asm/local.h:19: error: static declaration of 'local_inc' follows non-static declaration
include/linux/percpu-rwsem.h:23: note: previous implicit declaration of 'local_inc' was here
/home/dirt/rpmbuild/BUILD/kernel-2.6.32-358.6.2.el6/vanilla-2.6.32-358.6.2.el6/arch/x86/include/asm/local.h:25: error: conflicting types for 'local_dec'
/home/dirt/rpmbuild/BUILD/kernel-2.6.32-358.6.2.el6/vanilla-2.6.32-358.6.2.el6/arch/x86/include/asm/local.h:25: error: static declaration of 'local_dec' follows non-static declaration
include/linux/percpu-rwsem.h:49: note: previous implicit declaration of 'local_dec' was here
make[1]: *** [arch/x86/kernel/asm-offsets.s] Error 1
make: *** [prepare0] Error 2
share|improve this question

closed as off-topic by Iain, Ward, kce, mdpc, MadHatter Oct 18 '13 at 11:35

This question appears to be off-topic. The users who voted to close gave this specific reason:

  • "Questions must be relevant to professional system administration. Server Fault is a site dedicated to professionals; novice questions are off-topic. Please see the Help Center for more information on topicality. The best advice we can give you is to hire a professional to help you out." – Ward, kce, mdpc, MadHatter
If this question can be reworded to fit the rules in the help center, please edit the question.

    
So what was in the logs? –  Michael Hampton Oct 16 '13 at 3:17
    
@MichaelHampton added log contents, thanks –  Brock Hensley Oct 16 '13 at 12:20
    
The end of the log is likely to be more useful –  Iain Oct 16 '13 at 12:34
    
@MichaelHampton Sorry, was hitting the content limit. I added more of the log. I figured the beginning stating that the version variables not being there would explain the errors in the rest of the file. –  Brock Hensley Oct 16 '13 at 12:41
    
I edited the question to be more precise/clear with logs. Thanks for any help. –  Brock Hensley Oct 16 '13 at 13:19

2 Answers 2

up vote 1 down vote accepted

No thanks to the down-voters, I was able to figure this out and make the process much easier, no need to manually build the source.

The problem (for me) was that the newer versions of the kernel/headers were installed and I had to remove them before I could install the older version I needed to match my running kernel:

First remove 18.1 (I found that the 'headers' are the only ones you need to remove, the 'devel' can have the newer and older version side by side):

sudo yum remove kernel-headers-2.6.32-358.18.1.el6.x86_64

Now install 6.2:

sudo yum install kernel-headers-2.6.32-358.6.2.el6.x86_64
sudo yum install kernel-devel-2.6.32-358.6.2.el6.x86_64

Now when installing VirtualBox everything is good.

share|improve this answer
    
I downvoted your question because you failed to even bother to read the information provided in your terminal or the logfile but I still tried to help. –  Iain Oct 16 '13 at 16:24

ERROR: Kernel configuration is invalid.

     include/linux/autoconf.h or include/config/auto.conf are missing.
     Run 'make oldconfig && make prepare' on kernel src to fix it.

I'd start with that.

share|improve this answer
    
I ran those commands in ~/rpmbuild/BUILD/kernel-x/vanilla-x and ~/rpmbuild/BUILD/kernel-x/linux-x. The one in vanilla gave errors. Am I not doing this in the right place? Am I not getting/building the source correctly? –  Brock Hensley Oct 16 '13 at 13:01
    
I edited the question to be more precise/clear with logs. Thanks for any help. –  Brock Hensley Oct 16 '13 at 13:18

Not the answer you're looking for? Browse other questions tagged or ask your own question.