ubuntu - 无法在 3.8 内核上编译 Vagrant VirtualBox Guest Additions

标签 ubuntu kernel virtualbox vagrant

将 VirtualBox 4.3.4 与 Vagrant 1.3.5 结合使用。运行带有 3.8 内核的 Ubuntu 12.04.3 机器:

# uname -a
Linux precise64 3.8.0-34-generic #49~precise1-Ubuntu SMP Wed Nov 13 18:05:00 UTC 2013 x86_64 x86_64 x86_64 GNU/Linux

尝试编译 guest 添加失败:

# /etc/init.d/vboxadd setup
Removing existing VirtualBox DKMS kernel modules ...done.
Removing existing VirtualBox non-DKMS kernel modules ...done.
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.

Building the main Guest Additions module ...fail!
(Look at /var/log/vboxadd-install.log to find out what went wrong)
Doing non-kernel setup of the Guest Additions ...done.

日志指向丢失的 version.h 文件:

# cat /var/log/vboxadd-install.log
grep: /lib/modules/3.8.0-34-generic/build/include/linux/version.h: No such file or directory
make KBUILD_VERBOSE=1 CONFIG_MODULE_SIG= -C /lib/modules/3.8.0-34-generic/build SUBDIRS=/tmp/vbox.0 SRCROOT=/tmp/vbox.0 modules
test -e include/generated/autoconf.h -a -e include/config/auto.conf || (        \
echo >&2;                           \
echo >&2 "  ERROR: Kernel configuration is invalid.";       \
echo >&2 "         include/generated/autoconf.h or include/config/auto.conf are missing.";\
echo >&2 "         Run 'make oldconfig && make prepare' on kernel src to fix it.";  \
echo >&2 ;                          \
/bin/false)
mkdir -p /tmp/vbox.0/.tmp_versions ; rm -f /tmp/vbox.0/.tmp_versions/*
make -f scripts/Makefile.build obj=/tmp/vbox.0
  gcc -Wp,-MD,/tmp/vbox.0/.VBoxGuest-linux.o.d  -nostdinc -isystem /usr/lib/gcc/x86_64-linux-gnu/4.6/include  -I/usr/src/linux-headers-3.8.0-34-generic/arch/x86/include -Iarch/x86/include/generated  -Iinclude -I/usr/src/linux-headers-3.8.0-34-generic/arch/x86/include/uapi -Iarch/x86/include/generated/uapi -I/usr/src/linux-headers-3.8.0-34-generic/include/uapi -Iinclude/generated/uapi -include /usr/src/linux-headers-3.8.0-34-generic/include/linux/kconfig.h -Iubuntu/include  -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 -O2 -m64 -mtune=generic -mno-red-zone -mcmodel=kernel -funit-at-a-time -maccumulate-outgoing-args -fstack-protector -DCONFIG_X86_X32_ABI -DCONFIG_AS_CFI=1 -DCONFIG_AS_CFI_SIGNAL_FRAME=1 -DCONFIG_AS_CFI_SECTIONS=1 -DCONFIG_AS_FXSAVEQ=1 -DCONFIG_AS_AVX=1 -DCONFIG_AS_AVX2=1 -pipe -Wno-sign-compare -fno-asynchronous-unwind-tables -mno-sse -mno-mmx -mno-sse2 -mno-3dnow -mno-avx -Wframe-larger-than=1024 -Wno-unused-but-set-variable -fno-omit-frame-pointer -fno-optimize-sibling-calls -pg -mfentry -DCC_USING_FENTRY -Wdeclaration-after-statement -Wno-pointer-sign -fno-strict-overflow -fconserve-stack -DCC_HAVE_ASM_GOTO -include /tmp/vbox.0/include/VBox/VBoxGuestMangling.h -I/lib/modules/3.8.0-34-generic/build/include -I/tmp/vbox.0/ -I/tmp/vbox.0/include -I/tmp/vbox.0/r0drv/linux -I/tmp/vbox.0/vboxguest/ -I/tmp/vbox.0/vboxguest/include -I/tmp/vbox.0/vboxguest/r0drv/linux -D__KERNEL__ -DMODULE -DVBOX -DRT_OS_LINUX -DIN_RING0 -DIN_RT_R0 -DIN_GUEST -DIN_GUEST_R0 -DIN_MODULE -DRT_WITH_VBOX -DVBGL_VBOXGUEST -DVBOX_WITH_HGCM -DRT_ARCH_AMD64 -DVBOX_WITH_64_BITS_GUESTS  -DMODULE  -D"KBUILD_STR(s)=#s" -D"KBUILD_BASENAME=KBUILD_STR(VBoxGuest_linux)"  -D"KBUILD_MODNAME=KBUILD_STR(vboxguest)" -c -o /tmp/vbox.0/.tmp_VBoxGuest-linux.o    /tmp/vbox.0/VBoxGuest-linux.c
/tmp/vbox.0/VBoxGuest-linux.c:199:49: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘g_VBoxGuestPciId’
/tmp/vbox.0/VBoxGuest-linux.c:328:21: error: ‘g_VBoxGuestPciId’ undeclared here (not in a function)
/tmp/vbox.0/VBoxGuest-linux.c:209:1: error: ‘__mod_pci_device_table’ aliased to undefined     symbol ‘g_VBoxGuestPciId’
make[2]: *** [/tmp/vbox.0/VBoxGuest-linux.o] Error 1
make[1]: *** [_module_/tmp/vbox.0] Error 2
make: *** [vboxguest] Error 2
Creating user for the Guest Additions.
Creating udev rule for the Guest Additions kernel module.

最佳答案

这对我有用:

vagrant plugin install vagrant-vbguest

完整输出如下:

$ vagrant plugin install vagrant-vbguest
$ vagrant up
Bringing machine 'default' up with 'virtualbox' provider...
[default] Clearing any previously set forwarded ports...
[default] Creating shared folders metadata...
[default] Clearing any previously set network interfaces...
[default] Preparing network interfaces based on configuration...
[default] Forwarding ports...
[default] -- 22 => 2222 (adapter 1)
[default] Booting VM...
GuestAdditions versions on your host (4.3.4) and guest (4.2.0) do not match.
stdin: is not a tty
Reading package lists...
Building dependency tree...
Reading state information...
linux-headers-3.8.0-34-generic is already the newest version.
The following NEW packages will be installed:
  dkms
0 upgraded, 1 newly installed, 0 to remove and 0 not upgraded.
Need to get 73.2 kB of archives.
After this operation, 348 kB of additional disk space will be used.
Get:1 http://us.archive.ubuntu.com/ubuntu/ precise-updates/main dkms all 2.2.0.3-  1ubuntu3.1 [73.2 kB]
dpkg-preconfigure: unable to re-open stdin: No such file or directory
Fetched 73.2 kB in 0s (145 kB/s)
Selecting previously unselected package dkms.
(Reading database ... 84686 files and directories currently installed.)
Unpacking dkms (from .../dkms_2.2.0.3-1ubuntu3.1_all.deb) ...
Processing triggers for man-db ...
Setting up dkms (2.2.0.3-1ubuntu3.1) ...
Copy iso file /Applications/VirtualBox.app/Contents/MacOS/VBoxGuestAdditions.iso into the box /tmp/VBoxGuestAdditions.iso
stdin: is not a tty
mount: block device /tmp/VBoxGuestAdditions.iso is write-protected, mounting read-only
Installing Virtualbox Guest Additions 4.3.4 - guest version is 4.2.0
stdin: is not a tty
Verifying archive integrity... All good.
Uncompressing VirtualBox 4.3.4 Guest Additions for Linux............
VirtualBox Guest Additions installer
Removing installed version 4.2.0 of VirtualBox Guest Additions...
Copying additional installer modules ...
Installing additional modules ...
Removing existing VirtualBox DKMS kernel modules ...done.
Removing existing VirtualBox non-DKMS kernel modules ...done.
Building the VirtualBox Guest Additions kernel modules ...done.
Doing non-kernel setup of the Guest Additions ...done.
Starting the VirtualBox Guest Additions ...done.
Installing the Window System drivers ...fail!
(Could not find the X.Org or XFree86 Window System.)
An error occurred during installation of VirtualBox Guest Additions 4.3.4. Some     functionality may not work as intended.
stdin: is not a tty
[default] Waiting for machine to boot. This may take a few minutes...
[default] Machine booted and ready!
[default] Setting hostname...
[default] Mounting shared folders...
[default] -- /vagrant

关于ubuntu - 无法在 3.8 内核上编译 Vagrant VirtualBox Guest Additions,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/20458497/

相关文章:

memory-management - 关于 "__GFP_COMP"的用法?

python - Pycurl导入错误: SSL Backend Mismatch

docker - 启用和禁用 Hyper V Docker 所需的简单说明

linux - 内核自旋锁在释放锁之前启用抢占

android - 在 Sony Xperia NXT 系列(U、Sola、P、S)中安装自定义 Android 内核

laravel - 使用 Mailgun、Laravel 和 VirtualBox 发送电子邮件时出现 "Server response: 451 451 Temporary local - please try later"

java - 在 Linux (Ubuntu) 中禁用快捷键

ubuntu - 如何使用 SaltStack 正确安装 Ubuntu?

symfony - GeniusesOfSymfony/WebSocketBundle 在后台启动服务器

postgresql - 页面管理员。无法在下拉列表中输入