首先依次点击vsbox [设备]--->[安装增强功能],reboot 重启。
依次执行以下命令
[root@wch02 ~]# cd /media/VBOXADDITIONS_5.0.26_108824/ #执行命令切换进入目录
[root@wch02 VBOXADDITIONS_5.0.26_108824]# ./VBoxLinuxAdditions.run
Verifying archive integrity... All good.
Uncompressing VirtualBox 5.0.26 Guest Additions for Linux............
VirtualBox Guest Additions installer
Removing installed version 5.0.26 of VirtualBox Guest Additions...
Stopping VirtualBox Additions [确定]
Removing existing VirtualBox non-DKMS kernel modules [确定]
Copying additional installer modules ...
Installing additional modules ...
Removing existing VirtualBox non-DKMS kernel modules [确定]
Building the VirtualBox Guest Additions kernel modules
The gcc utility was not found. If the following module compilation fails then
this could be the reason and you should try installing it.
The headers for the current running kernel were not found. If the following
module compilation fails then this could be the reason.
The missing package can be probably installed with
yum install kernel-devel-2.6.32-573.el6.x86_64
Building the main Guest Additions module [失败]
(Look at /var/log/vboxadd-install.log to find out what went wrong)
Doing non-kernel setup of the Guest Additions [确定]
- Building the main Guest Additions module [失败],由此信息可知安装失败,根据提示查看/var/log/vboxadd-install.log 可知,缺乏相应的kernel包,执行以下命令:
[root@wch02 VBOXADDITIONS_5.0.26_108824]# yum install gcc kernel-devel kernel-headers -y #等待安装完成
[root@wch02 VBOXADDITIONS_5.0.26_108824]# rpm -qa | grep kernel |sort #查看kernel的版本是否一致
abrt-addon-kerneloops-2.0.8-34.el6.centos.x86_64
dracut-kernel-004-388.el6.noarch
kernel-2.6.32-573.el6.x86_64
kernel-devel-2.6.32-642.6.1.el6.x86_64
kernel-firmware-2.6.32-573.el6.noarch
kernel-headers-2.6.32-642.6.1.el6.x86_64
libreport-plugin-kerneloops-2.0.9-24.el6.centos.x86_64
- kernel-2.6.32-573.el6.x86_64,kernel-devel-2.6.32-642.6.1.el6.x86_64,由此可知kernel版本号不一致,执行一下命令:
[root@wch02 VBOXADDITIONS_5.0.26_108824]# yum update kernel -y #更新kernel,下载量有点大60M左右,得多等一会儿。等待安装完成
[root@wch02 VBOXADDITIONS_5.0.26_108824]# reboot # 重启
- 重启后再次执行 ./VBoxLinuxAdditions.run,执行以下命令。
[root@wch02 ~]# cd /media/VBOXADDITIONS_5.0.26_108824/
[root@wch02 VBOXADDITIONS_5.0.26_108824]# ./VBoxLinuxAdditions.run
Verifying archive integrity... All good.
Uncompressing VirtualBox 5.0.26 Guest Additions for Linux............
VirtualBox Guest Additions installer
Removing installed version 5.0.26 of VirtualBox Guest Additions...
Stopping VirtualBox Additions [确定]
Removing existing VirtualBox non-DKMS kernel modules [确定]
Copying additional installer modules ...
Installing additional modules ...
Removing existing VirtualBox non-DKMS kernel modules [确定]
Building the VirtualBox Guest Additions kernel modules
Building the main Guest Additions module [确定]
Building the shared folder support module [确定]
Building the graphics driver module [确定]
Doing non-kernel setup of the Guest Additions [确定]
Starting the VirtualBox Guest Additions Installing the Window System drivers
Installing X.Org Server 1.15 modules [确定]
Setting up the Window System to use the Guest Additions [确定]
You may need to restart the the Window System (or just restart the guest system)
to enable the Guest Additions.
Installing graphics libraries and desktop services componen[确定]
[确定]
- 到此时,增强功能即安装完成,共享目录等实用功能即可使用了。[设备]--->[共享文件夹],重启。重启之后既能与外部宿主机共享文件夹。
[root@wch02 ~]# cd /media/
[root@wch02 media]# ll
总用量 6
drwxrwx---. 1 root vboxsf 4096 10月 7 23:09 sf_mysql
dr-xr-xr-x. 6 root root 2048 7月 18 19:58 VBOXADDITIONS_5.0.26_108824
- 完成。