調整Virtual Box中螢幕尺寸(解析度) .
當在 Virtual Box 中安裝完 CentOS (或者其他,比如win7 or ubuntu)後,螢幕的解析度只能是4:3的,這樣如果自己的螢幕不是4:3的話,看起來非常不方便。這個時候就需要安裝VBoxGuestAdditions_x.x.x.iso 這個增強功能了。
但在安裝過程中產生了錯誤:
Buildingthemainguestadditionmodules[Failed].(Yoursystemdoesnotseemtobesetuptobuildkernelmodules.Lookat/var/log/vboxadd-install.logtofindoutwhatwentwrong)
Building the main guest addition modules [Failed]. (Your system does not seem to be set up to build kernel modules. Look at /var/log/vboxadd-install.log to find out what went wrong)
同時,在檔案/var/log/vboxadd-install.log 中發現如下錯誤:
Error:unabletofindthesourcesofyourcurrentLinuxkernel.SpecifyKERN_DIR=<directory>andrunMakeagain..Stop.
Error: unable to find the sources of your current Linux kernel. Specify KERN_DIR=<directory> and run Make again.. Stop.
測試環境:Mac OS 10.9.4, Virtual Box-4.3.14-95030, CentOS-7.0-1406-x86_64-GnomeLive
解決方案:
首先,檢查自己的核心版本:(我的版本號碼是3.10.0-123.el7.x86_64)
- uname-r
uname -r
然後,檢查自己有沒有安裝kernel-devel, 且版本號碼與kernel是否一致:(版本是3.10.0-123.6.3.el7.x86_64,不一致)
rpm-qkernel-devel
rpm -q kernel-devel
如果沒有安裝,使用如下命令進行安裝:
yuminstallkernel-devel
yum install kernel-devel
如果二者不一致,需要對kernel進行更新:
- yumupdatekernel
yum update kernel
接下來,安裝一些必要的程式:
yuminstallgcc
yum install gcc
最後,就可以安裝VBoxGuestAdditions_x.x.x.iso了:(首先使用root許可權進入iso的檔案夾)
./VBoxLinuxGuestAddition.run
./VBoxLinuxGuestAddition.run
reboot 一下就可以了。