Virtual Box (Linux) 安装增加模式

参考

  • https://www.jianshu.com/p/7c556c783bb2
  • https://www.cnblogs.com/mychangee/p/12087954.html

centos

1.点击设备->安装增加功能->下载增加镜像,底部镜像按钮挂载VBoxGuestAddtions.iso 运行

2.运行后报错,没有安装内核,需要安装内核和gcc 并且保持kernel 和kernel-devel版本一致

yum install -y kernel-devel kernel-headers gcc make

yum -y upgrade kernel kernel-devel

reboot

uname -r //查看当前启动的内核版本

rpm -qa | grep kernel-[0-9] //查看全部的内核

yum remove xxxx //删除旧版本内核

或者可以使用下面两个命令中的一个安装和Linux内核版本匹配的kernel-devel

yum install -y "kernel-devel-uname-r == $(uname -r)"

yum install -y kernel-devel-xxxx 

centos 8 报错

https://github.com/geerlingguy/packer-centos-8/issues/4

$ cat /var/log/vboxadd-setup.log
Building the main Guest Additions 6.0.12 module for kernel 4.18.0-80.7.1.el8_0.x86_64.
Error building the module.  Build output follows.
make V=1 CONFIG_MODULE_SIG= -C /lib/modules/4.18.0-80.7.1.el8_0.x86_64/build M=/tmp/vbox.0 SRCROOT=/tmp/vbox.0 -j1 modules
Makefile:958: *** "Cannot generate ORC metadata for CONFIG_UNWINDER_ORC=y, please install libelf-dev, libelf-devel or elfutils-libelf-devel".  Stop.
make: *** [/tmp/vbox.0/Makefile-footer.gmk:111: vboxguest] Error 2
Could not find the X.Org or XFree86 Window System, skipping.
modprobe vboxguest failed
yum(dnf)install -y elfutils-libelf-devel elfutils-libelf-devel.x86_64

sh VBoxLinuxAdditions.run

ubuntu

1.同centos

2.报错后

sudo apt update

sudo apt install gcc