Fedora 14 安裝 VirtualBox 後執行 /etc/init.d/vboxdrv setup 失敗:
Makefile:152: *** Error: unable to find the sources of your current Linux kernel. Specify KERN_DIR=and run Make again.
安裝 kernel-devel 後重新編譯:
KERN_DIR=/usr/src/kernels/2.6.32.21-166.fc12.i686 /etc/init.d/vboxdrv setup Recompiling VirtualBox kernel module [ OK ] Starting VirtualBox kernel module [FAILED] (modprobe vboxdrv failed. Please use 'dmesg' to find out why)
dmesg 顯示:
vboxdrv: version magic '2.6.32.21-166.fc12.i686 SMP mod_unload 686' should be '2.6.32.21-166.fc12.i686.PAE SMP mod_unload 686'
系統運行的是 PAE 核心 (支援 4GB 以上記憶體),但安裝的 kernel-devel 為非 PAE 版本,導致編譯出的模組版本魔術碼不符,無法載入。
yum install kernel-PAE-devel.i686
安裝完成後,/usr/src/kernels/ 下會新增 2.6.32.21-166.fc12.i686.PAE 目錄。
KERN_DIR=/usr/src/kernels/2.6.32.21-166.fc12.i686.PAE /etc/init.d/vboxdrv setup
輸出應顯示:
Stopping VirtualBox kernel module [ OK ] Removing old VirtualBox netadp kernel module [ OK ] Removing old VirtualBox netflt kernel module [ OK ] Removing old VirtualBox kernel module [ OK ] Recompiling VirtualBox kernel module [ OK ] Starting VirtualBox kernel module [ OK ]
# 確認目前運行核心 uname -r # 輸出範例:2.6.32.21-166.fc12.i686.PAE # 確認已安裝 kernel-devel 版本 rpm -qa | grep kernel-devel # 需包含對應 .PAE 版本 # 確認 KERN_DIR 位置 ls /usr/src/kernels/
所有基於 RPM 的發行版 (Fedora、RHEL、CentOS、openSUSE 等) 遇到 VirtualBox、VMware、NVIDIA 驅動等核心外掛模組編譯失敗,核心原則相同:運行核心版本、kernel-devel 版本、KERN_DIR 指向必須三者完全一致 (含 PAE/debug 等後綴)。