沒有安裝Virtual Box增強功能Guest Additions的虛擬機操作很不方便,比如:
安裝Guest Additions可以解決上述所有問題。
以CentOS 7.3虛擬機為例,如果安裝CentOS時沒有選擇Development Tools組,需要先安裝kernel-devel和gcc$ sudo yum install -y kernel-devel gcc
通過VirtualBox的 設備 | 安裝增強功能... 菜單可以加載VBoxGuestAdditions.iso,可以直接點擊Run安裝或者執(zhí)行$ cd /run/media/centos/VBOXADDITIONS_5.1.22_115126
$ sudo sh ./VBoxLinuxAdditions.run
有時安裝會出錯
Verifying archive integrity... All good.
Uncompressing VirtualBox 5.1.22 Guest Additions for Linux...........
VirtualBox Guest Additions installer
Copying additional installer modules ...
Installing additional modules ...
vboxadd.sh: Starting the VirtualBox Guest Additions.
Failed to set up service vboxadd, please check the log file
/var/log/VBoxGuestAdditions.log for details.
查詢log發(fā)現(xiàn)是找不到和Linux內(nèi)核匹配的源文件$ cat /var/log/VBoxGuestAdditions.log
vboxadd.sh: failed: Look at /var/log/vboxadd-install.log to find out what went wrong.
vboxadd.sh: failed: Look at /var/log/vboxadd-install.log to find out what went wrong.
vboxadd.sh: failed: modprobe vboxguest failed.
$ cat /var/log/vboxadd-install.log
/tmp/vbox.0/Makefile.include.header:112: *** Error: unable to find the sources of your current Linux kernel. Specify KERN_DIR= and run Make again. Stop.
Creating user for the Guest Additions.
Creating udev rule for the Guest Additions kernel module.
查詢kernel-devel版本是3.10.0-514.26.2.el7.x86_64,而Linux內(nèi)核版本是3.10.0-514.el7.x86_64,確實不一致。如果安裝CentOS時選擇了Development Tools組,kernel-devel版本和Linux內(nèi)核版本是匹配的,則不會出現(xiàn)這個問題。$ rpm -qa | grep kernel-devel
kernel-devel-3.10.0-514.26.2.el7.x86_64
$ uname -r
3.10.0-514.el7.x86_64
可以使用下面兩個命令中的一個安裝和Linux內(nèi)核版本匹配的kernel-devel$ sudo yum install -y "kernel-devel-uname-r == $(uname -r)"
$ sudo yum install -y kernel-devel-3.10.0-514.el7
然后再次安裝Guest Additions成功$ cd /run/media/centos/VBOXADDITIONS_5.1.22_115126
$ sudo sh ./VBoxLinuxAdditions.run
來源:http://www.icode9.com/content-3-119951.htmlVerifying archive integrity... All good.
Uncompressing VirtualBox 5.1.22 Guest Additions for Linux...........
VirtualBox Guest Additions installer
Removing installed version 5.1.22 of VirtualBox Guest Additions...
Copying additional installer modules ...
Installing additional modules ...
vboxadd.sh: Starting the VirtualBox Guest Additions.