萬盛學電腦網

您现在的位置: 萬盛學電腦網 >> 作業系統 >  >> Linux 教學

Ubuntu 13.10 VirtualBox 無法啟動修復指南:Kernel 模組重新編譯與 linux-headers 安裝

Ubuntu 13.10 升級核心後,VirtualBox Kernel 模組(vboxdrv)因版本不匹配失效,提示 Kernel driver not installed (rc=-1908)。核心解決路徑:安裝對應核心版本的 linux-headers → 重新編譯註冊 vboxdrv 模組。本文提供完整排查日誌分析與修復指令。

錯誤現象與日誌分析

Kernel driver not installed (rc=-1908)
The VirtualBox Linux kernel driver (vboxdrv) is either not loaded
or there is a permission problem with /dev/vboxdrv.
Re-setup the kernel module by executing '/etc/init.d/vboxdrv setup' as root.
Users of Ubuntu, Fedora or Mandriva should install the DKMS package first.

執行 sudo /etc/init.d/vboxdrv setup 仍報錯:

Makefile:183: *** Error: unable to find the sources of your current Linux kernel.
Specify KERN_DIR= and run Make again. Stop.

關鍵線索:unable to find the sources of your current Linux kernel → 缺少 linux-headers-$(uname -r)。

修復步驟

  1. 確認當前核心版本
    uname -r
    # 輸出例:3.11.0-17-generic
    
  2. 安裝對應版本 linux-headers
    sudo apt-get install linux-headers-$(uname -r)
        # 或具體版本:sudo apt-get install linux-headers-3.11.0-17-generic
        
  3. 確認 DKMS 已安裝
    sudo apt-get install dkms
        
  4. 重新編譯並載入 vboxdrv 模組
    sudo /etc/init.d/vboxdrv setup
        # 輸出應顯示:
        # Stopping VirtualBox kernel modules ... done.
        # Uninstalling old VirtualBox DKMS kernel modules ... done.
        # Trying to register the VirtualBox kernel modules using DKMS ... done.
        # Starting VirtualBox kernel modules ... done.
        
  5. 驗證:啟動 VirtualBox GUI,建立/啟動虛擬機測試。

根因深度解析

  • Ubuntu 核心升級(apt-get dist-upgrade)會安裝新核心並設為預設啟動。
  • DKMS 框架應自動為新核心重建模組,但若 linux-headers 缺失或 DKMS 掛掉,重建失敗。
  • 舊核心下已編譯的 vboxdrv.ko 不會自動遷移到新核心模組目錄(/lib/modules/$(uname -r)/)。

預防最佳實踐

  • 安裝 linux-headers-generic 元套件,確保核心升級自動拉取對應 headers:
    sudo apt-get install linux-headers-generic dkms
  • 優先使用 Ubuntu 官方倉庫版 VirtualBox(virtualbox-dkms),DKMS 整合更完善。
  • 若必須用官方 .deb,安裝後立即執行 sudo /sbin/vboxconfig(新版指令)註冊模組。

適用版本說明

本文以 Ubuntu 13.10 (核心 3.11) 為例,同樣適用於 12.04、14.04、16.04 等版本的核心升級後 VirtualBox 失效場景。

copyright © 萬盛學電腦網 all rights reserved