1、安装virtualBox增强功能需要先安装gcc和kernel-devel包才行,照往常一样,按照正常方法安装了这两个包。
yum -y install gcc
yum -y install kernel
安装都成功。
2、安装增强功能
Verifying archive integrity... All good. Uncompressing VirtualBox 5.1.30 Guest Additions for Linux........... VirtualBox Guest Additions installer Removing installed version 5.1.30 of VirtualBox Guest Additions... vBoxadd.sh: Stopping VirtualBox Additions. Copying additional installer modules ... Installing additional modules ... vBoxadd.sh: Starting the VirtualBox Guest Additions. Failed to set up service vBoxadd,please check the log file /var/log/VBoxGuestAdditions.log for details. Press Return to close this window...报错。看日志文件:
[root@rac1 ~]# cat /var/log/VBoxGuestAdditions.log vBoxadd.sh: Failed: Look at /var/log/vBoxadd-install.log to find out what went wrong. vBoxadd.sh: Failed: Look at /var/log/vBoxadd-install.log to find out what went wrong. vBoxadd.sh: Failed: modprobe vBoxguest Failed.
继续看日志
[root@rac1 ~]# cat /var/log/vBoxadd-install.log /tmp/vBox.0/Makefile.include.header:112: *** Error: unable to find the sources of your current Linux kernel. Specify KERN_DIR=<directory> and run Make again。 停止。 Creating user for the Guest Additions. Creating udev rule for the Guest Additions kernel module.
3、查看kernel-devel包是否跟内核一致:
[root@rac1 ~]# uname -r 2.6.32-696.16.1.el6.x86_64 [root@rac1 ~]# yum info kernel-devel Loaded plugins: fastestmirror,refresh-packagekit,security Loading mirror speeds from cached hostfile * base: mirrors.aliyun.com * extras: mirrors.aliyun.com * updates: mirrors.aliyun.com Available Packages Name : kernel-devel Arch : x86_64 Version : 2.6.32 Release : 696.16.1.el6 Size : 11 M Repo : updates Summary : Development package for building kernel modules to match the : kernel URL : http://www.kernel.org/ License : GPLv2 Description : This package provides kernel headers and makefiles sufficient to : build modules against the kernel package.发现一致。
4、直接安装:
[root@rac1 VBoxADDITIONS_5.1.30_118389]# yum install -y "kernel-devel-uname-r == $(uname -r)" Loaded plugins: fastestmirror,security Loading mirror speeds from cached hostfile * base: mirrors.aliyun.com * extras: mirrors.aliyun.com * updates: mirrors.aliyun.com Setting up Install Process Resolving Dependencies --> Running transaction check ---> Package kernel-devel.x86_64 0:2.6.32-696.16.1.el6 will be installed --> Finished Dependency Resolution Dependencies Resolved ================================================================================ Package Arch Version Repository Size ================================================================================ Installing: kernel-devel x86_64 2.6.32-696.16.1.el6 updates 11 M Transaction Summary ================================================================================ Install 1 Package(s) Total download size: 11 M Installed size: 26 M Downloading Packages: kernel-devel-2.6.32-696.16.1.el6.x86_64.rpm | 11 MB 00:01 Running rpm_check_debug Running Transaction Test Transaction Test Succeeded Running Transaction Installing : kernel-devel-2.6.32-696.16.1.el6.x86_64 1/1 Verifying : kernel-devel-2.6.32-696.16.1.el6.x86_64 1/1 Installed: kernel-devel.x86_64 0:2.6.32-696.16.1.el6 Complete!
5、完了直接安装增强功能:
[root@rac1 VBoxADDITIONS_5.1.30_118389]# ls 32Bit cert VBoxSolarisAdditions.pkg 64Bit OS2 VBoxWindowsAdditions-amd64.exe AUTORUN.INF runasroot.sh VBoxWindowsAdditions.exe autorun.sh VBoxLinuxAdditions.run VBoxWindowsAdditions-x86.exe [root@rac1 VBoxADDITIONS_5.1.30_118389]# ./VBoxLinuxAdditions.run Verifying archive integrity... All good. Uncompressing VirtualBox 5.1.30 Guest Additions for Linux........... VirtualBox Guest Additions installer Removing installed version 5.1.30 of VirtualBox Guest Additions... vBoxadd.sh: Stopping VirtualBox Additions. Copying additional installer modules ... Installing additional modules ... vBoxadd.sh: Starting the VirtualBox Guest Additions. You may need to restart the Window System (or just restart the guest system) to enable the Guest Additions. [root@rac1 VBoxADDITIONS_5.1.30_118389]#6、成功!写在最后,安装报上面的错,要么是kernel-dev包的版本跟内核版本不一致,要么就是kernel-dev包没装。安装kernel-dev包可以参照我上面的命令,保证两者版本一致。 原文链接:https://www.f2er.com/centos/375163.html