在VirtualBox安装好了Linux虚拟机后,还需要安装Guest Additions,不然鼠标不能自动的在虚拟机和宿主机之间切换,宿主机共享给虚拟机的目录也不能自动挂载。
在虚拟机的菜单里面选择Devices→Insert Guest Additions CD image可以插入安装软件的光盘
这个光盘会自动运行,出现下面的画面:
也可以mount这个光盘到/mnt目录下,然后运行./VBoxLinuxAdditions.run :
[root@oracleace mnt]# ./VBoxLinuxAdditions.run Verifying archive integrity... All good. Uncompressing VirtualBox 6.1.32 Guest Additions for Linux........ VirtualBox Guest Additions installer Copying additional installer modules ... Installing additional modules ... VirtualBox Guest Additions: Starting. VirtualBox Guest Additions: Building the VirtualBox Guest Additions kernel modules. This may take a while. VirtualBox Guest Additions: To build modules for other installed kernels, run VirtualBox Guest Additions: /sbin/rcvboxadd quicksetup <version> VirtualBox Guest Additions: or VirtualBox Guest Additions: /sbin/rcvboxadd quicksetup all VirtualBox Guest Additions: Kernel headers not found for target kernel 5.4.17-2102.201.3.el7uek.x86_64. Please install them and execute /sbin/rcvboxadd setup modprobe vboxguest failed The log file /var/log/vboxadd-setup.log may contain further information.
结果运行失败,需要的头文件没有安装,使用下面的命令安装内核的开发包:
$ uname -r 5.4.17-2102.201.3.el7uek.x86_64 $ sudo yum install kernel-uek-devel-5.4.17
安装完成后再次检查内核的相关包:
[oracle@oracleace ~]$ rpm -qa|grep 5.4.17 kernel-uek-devel-5.4.17-2102.201.3.el7uek.x86_64 kernel-uek-5.4.17-2102.201.3.el7uek.x86_64
安装相关开发包后再次编译内核:
# yum install gcc make perl ... # /sbin/rcvboxadd quicksetup all VirtualBox Guest Additions: Building the modules for kernel 5.4.17-2102.201.3.el7uek.x86_64. # ./VBoxLinuxAdditions.run Verifying archive integrity... All good. Uncompressing VirtualBox 6.1.32 Guest Additions for Linux........ VirtualBox Guest Additions installer Removing installed version 6.1.32 of VirtualBox Guest Additions... Copying additional installer modules ... Installing additional modules ... VirtualBox Guest Additions: Starting. VirtualBox Guest Additions: Building the VirtualBox Guest Additions kernel modules. This may take a while. VirtualBox Guest Additions: To build modules for other installed kernels, run VirtualBox Guest Additions: /sbin/rcvboxadd quicksetup <version> VirtualBox Guest Additions: or VirtualBox Guest Additions: /sbin/rcvboxadd quicksetup all VirtualBox Guest Additions: Building the modules for kernel 5.4.17-2102.201.3.el7uek.x86_64.
生成了新的内核后,重新启动,发现鼠标已经可以自动的在虚拟机和宿主机之间切换了,宿主机共享给虚拟机的目录也自动挂载了:
[oracle@oracleace ~]$ df -h|grep medi oracle 5.5T 1.5T 4.0T 27% /media/sf_oracle tmp 100G 58G 43G 58% /media/sf_tmp /dev/sr0 59M 59M 0 100% /run/media/oracle/VBox_GAs_6.1.32