真的花了超多時間才解決這個問題!
前置作業:
- Devices > Insert Guest Additions CD image
- 切換到root權限
掛載剛剛插入的Guest Additions CD映像檔
mount /dev/sr0 /mnt
確認掛應像檔的內容
cd /mnt
ls -al
執行VBoxLinuxAdditions.run
./VBoxLinuxAdditions.run
若出現以下內容表示安裝失敗:
The make utility was not found. If the following module compilation fails then
this could be the reason and you should try installing it.
The gcc utility was not found. If the following module compilation fails then
this could be the reason and you should try installing it.
The headers for the current running kernel were not found. If the following
module compilation fails then this could be the reason.
Building the main Guest Additions module …fail!
(Look at /var/log/vboxadd-install.log to find out what went wrong)
檢查安裝紀錄檔
tail /var/log/vboxadd-install.log
內容如下:
/opt/VBoxGuestAdditions-5.0.24/src/vboxguest-5.0.24/build_in_tmp: 62: /opt/VBoxGuestAdditions-5.0.24/src/vboxguest-5.0.24/build_in_tmp: make: not found
重點是後面的make: not found
看起來是還沒裝make,安裝make
apt-get install make
再執行一次VBoxLinuxAdditions.run
./VBoxLinuxAdditions.run
結果還是安裝失敗
The gcc utility was not found. If the following module compilation fails then
this could be the reason and you should try installing it.
The headers for the current running kernel were not found. If the following
module compilation fails then this could be the reason.
Building the main Guest Additions module …fail!
(Look at /var/log/vboxadd-install.log to find out what went wrong)
Doing non-kernel setup of the Guest Additions …done.
再檢查一次/var/log/vboxadd-install.log
tail /var/log/vboxadd-install.log
看起來來是少裝了一些東西,爬了一些文章看到這篇試著安裝DKMS就搞定了
/tmp/vbox.0/Makefile.include.header:97: *** Error: unable to find the sources of your current Linux kernel. Specify KERN_DIR= and run Make again. Stop.
安裝dkms
apt-get install dkms
再執行一次VBoxLinuxAdditions.run
./VBoxLinuxAdditions.run
若沒有出現任何的錯誤訊息就重啟VM
確認/media目錄的內容,看到sf_xxx目錄表示設定成功了!
