centos VBoxLinuxAdditions 安装报错 Building the main Guest Additions module

虚拟机 virtualbox, 安装操作系统centos6.5

报错信息如下:

$ sudo ./VBoxLinuxAdditions.run 

Verifying archive integrity... All good.
Uncompressing VirtualBox 5.0.24 Guest Additions for Linux............
VirtualBox Guest Additions installer
Removing installed version 5.0.24 of VirtualBox Guest Additions...
Stopping VirtualBox Additions                              [  OK  ]
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 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-431.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              [确定]


$ 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。 停止。
Creating user for the Guest Additions.
Creating udev rule for the Guest Additions kernel module.


解决方法:

1)安装 gcc make gcc-c++

#yum install gcc make gcc-c++

2)安装kernel-headers kernel-devel
#yum install kernel-headers kernel-devel

3)、如果还不行,就把centos所有包升级下

#yum update

4)、重启

#reboot

5)、重新安装

# mount -t auto /dev/cdrom /mnt/cdrom

#sh ./VBoxLinuxAdditions.run



Verifying archive integrity... All good.
Uncompressing VirtualBox 5.0.24 Guest Additions for Linux............
VirtualBox Guest Additions installer
Removing installed version 5.0.24 of VirtualBox Guest Additions...
Stopping VirtualBox Additions                              [  OK  ]
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

Could not find the X.Org or XFree86 Window System, skipping.         [确定]


PS:访问共享文件夹

重启之后,centos就可以访问Windows/mac提供的共享文件夹了。
  • mkdir /mnt/share   新建挂载点(mountpoint)
  • mount -t vboxsf mysharedir /mnt/share   挂载共享文件夹   ------------------mysharedir虚拟机中设置的共享文件夹名称
  • cd /mnt/share   进入共享文件夹
  • ls   看看有什么


CentOS 系统中安装 VirtualBox 增强功能(Guest Additions)可以显著提升虚拟机的性能和用户体验,例如改善图形支持、提高磁盘 I/O 性能以及实现共享文件夹等功能。以下是详细的安装步骤: ### 1. 安装前的准备工作 确保系统已安装必要的依赖项,包括内核开发工具和编译工具。可以通过以下命令安装这些依赖: ```bash sudo yum install -y kernel-devel kernel-headers dkms gcc make perl ``` 此外,确认当前运行的内核版本与安装的 `kernel-devel` 和 `kernel-headers` 版本一致。可以通过以下命令查看当前内核版本: ```bash uname -r ``` 如果版本不一致,可能需要更新内核或安装对应的 `kernel-devel` 包。 ### 2. 挂载 VirtualBox Guest Additions 镜像 在 VirtualBox 虚拟机设置中,选择“设备” > “插入 Guest Additions CD 映像”。这将把 VirtualBox 提供的 Guest Additions ISO 文件挂载到虚拟机中。 接下来,在终端中创建一个挂载点并挂载 CD-ROM: ```bash sudo mkdir /media/VirtualBoxGuestAdditions sudo mount /dev/cdrom /media/VirtualBoxGuestAdditions ``` ### 3. 执行安装脚本 进入挂载目录后,执行安装脚本以安装 Guest Additions: ```bash cd /media/VirtualBoxGuestAdditions sudo ./VBoxLinuxAdditions.run ``` 安装完成后,建议重启系统以确保所有功能正常启用: ```bash sudo reboot ``` ### 4. 验证安装结果 重启后,可以通过检查 `/opt/VBoxGuestAdditions-<version>` 目录是否存在来确认 Guest Additions 是否成功安装。此外,还可以通过以下命令验证相关模块是否加载: ```bash lsmod | grep vbox ``` 输出应包含多个 `vbox` 开头的模块,如 `vboxguest`, `vboxsf`, `vboxvideo` 等。 ### 5. 其他注意事项 - 如果使用的是较新的 CentOS 版本(如 CentOS 8 或 Stream),建议使用 `dnf` 替代 `yum` 进行软件包管理。 - 对于某些特定发行版(如 Fedora 21/20, CentOS 7 等),VirtualBox 官方提供了专门的仓库配置方法,可以直接从官方仓库安装最新的 VirtualBoxGuest Additions [^1]。 - 如果遇到兼容性问题,尤其是内核版本不匹配时,建议更新系统并重新安装对应的 `kernel-devel` 包 [^2]。 ---
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值