现在的位置: 首页 > 综合 > 正文

CentOS实验九:安装VBoxAdditions

2012年09月12日 ⁄ 综合 ⁄ 共 2403字 ⁄ 字号 评论关闭

我的CentOS是用VirtualBox做的虚拟机,安装好以后最好再将VBoxAdditions增强功能装上,主要目的是能够在虚拟机和宿主机之间能够共享文件。

1. 更新内核。CentOS 6.2对应的kernel默认为2.6.32-220.el6:

# uname -r
2.6.32-220.el6.x86_64

安装增强功能需要kernel-devel包,必须保证kernel-devel和kernel版本的一致。查看软件源中kernel-devel的版本:

]# yum info kernel-devel
Loaded plugins: fastestmirror, refresh-packagekit, security
Loading mirror speeds from cached hostfile
 * epel: mirrors.ustc.edu.cn
 * rpmforge: mirror.oscc.org.my
Available Packages
Name        : kernel-devel
Arch        : x86_64
Version     : 2.6.32
Release     : 279.5.2.el6
Size        : 7.6 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.

当前的kernel-devel版本是2.6.32-279.5.2.e16。因此,必须升级kernel:

# yum update kernel

升级完后必须重启系统,新的kernel才能被使用。

 

2. 安装kernel-devel和gcc。

# yum install kernel-devel gcc gcc-c++

 

3. 安装增强功能。进入增强功能光盘根目录,执行Linux下的安装命令:

# ./VBoxLinuxAdditions.run 
Verifying archive integrity... All good.
Uncompressing VirtualBox 4.1.18 Guest Additions for Linux.........
VirtualBox Guest Additions installer
Removing existing VirtualBox DKMS kernel modules           [  OK  ]
Removing existing VirtualBox non-DKMS kernel modules       [  OK  ]
Building the VirtualBox Guest Additions kernel modules
Building the main Guest Additions module                   [  OK  ]
Building the shared folder support module                  [  OK  ]
Building the OpenGL support module                         [FAILED]
(Look at /var/log/vboxadd-install.log to find out what went wrong)
Doing non-kernel setup of the Guest Additions              [  OK  ]
Installing the Window System drivers
Installing X.Org Server 1.10 modules                       [  OK  ]
Setting up the Window System to use the Guest Additions    [  OK  ]
You may need to restart the hal service and the Window System (or just restart
the guest system) to enable the Guest Additions.

Installing graphics libraries and desktop services componen[  OK  ]

 

安装VBoxLinuxAdditions可能会报错:

$ ./VBoxLinuxAdditions.run
... ... Building the main Guest Additions module [FAILED] (Look at
/var/log/vboxadd-install.log to find out what went wrong) ... ...
$ cat
/var/log/vboxadd-install.log /tmp/vbox.0/Makefile.include.header:97: *** Error: unable to find the sources of your current Linux kernel. Specify KERN_DIR=<directory> and run Make again. Stop. Creating user for the Guest Additions. Creating udev rule for the Guest Additions kernel module.

可能是内核目录和内核版本不一致造成的:

$ ls /usr/src/kernels/
2.6.32-358.6.2.el6.x86_64

$ uname -r
2.6.32-358.el6.x86_64

建立一个链接指向内核目录应该就可以解决问题:

$ ls -l /usr/src/kernels/
total 4
drwxr-xr-x. 22 root root 4096 May 24 17:39 2.6.32-358.6.2.el6.x86_64
lrwxrwxrwx.  1 root root   42 May 24 17:38 2.6.32-358.el6.x86_64 -> /usr/src/kernels/2.6.32-358.6.2.el6.x86_64

抱歉!评论已关闭.