2014-03-29

VirtualBox 與 Debian/Ubuntu 客端額外功能(Guest Additions)

來源 : 石頭閒語
本文的內容包括 :
  • 安裝客端額外功能(Guest Additions)
  • 滑鼠整合沒作用(Mouse pointer integration not work)
  • 螢幕解析度可調整項目變少了

必須要先安裝的套件

一、安裝 build-essential and module-assistant
安裝 build-essential ,這將用於編譯 VirtualBox 客端功能的 Linux 核心模組。
$ sudo apt-get install build-essential
$ sudo apt-get install module-assistant
$ sudo apt-get install linux-headers-$(uname -r)

 
二、安裝 dkms

若你的 Guest OS 是 Ubuntu 10.04 Lucid 或更新的散佈版本時,必須安裝 dkms。它是新的核心模組載入機制。已知 VirtualBox 的滑鼠整合功能模組依賴此機制載入。若未安裝 dkms ,則滑鼠整合功能不會發生作用。

$ sudo apt-get install dkms

如果你已經安裝了客端額外功能,才發現沒有安裝 dkms 且滑鼠整合功能沒作用,你必須安裝 dkms 之後,再重裝一次客端額外功能。更快捷的方式是在安裝 dkms 之後,直接執行指令 sudo /etc/init.d/vboxadd setup。裝好之後,須重新啟動 Guest OS.

三、下載 VirtualBox Guest Additions ISO

當你使用 VirtualBox 選單的「安裝 Guest Additions ...」之後,VirtualBox 通常會自動下載客端額外功能軟體的 CD ISO 影像檔,並且自動掛載。若你碰到未自動下載的情形時,也可自行到官方網站下載。下載後,再自行透過 CD 裝置掛載該 ISO 影像。掛載 VBoxGuestAdditions CD ISO檔後,開啟它,並以 root 的權限執行其中的 VBoxLinuxAdditions.run。

I tried to install the VirtualBox Guest Additions on a virtual Debian machine. However when I tried executing the installer script I got this error:

bash: ./VBoxLinuxAdditions.run: Permission denied
The script uses /bin/sh as shell and on Debian Wheezy /bin/sh is symlinked to /bin/dash. Dash is a more light-weight replacement for Bash, and it turns out that the VirtualBox script does not work as it should when run with “dash”. An easy workaround is to explicitly run the script with “bash” with the following command:
sudo bash ./VBoxLinuxAdditions.run
or
sudo sh ./VboxLinuxAdditions.run

滑鼠整合沒作用(Mouse pointer integration not work)


Guest OS 為 Ubuntu 10.04 及之後的版本,請參考上一節第二項關於 dkms 的內容。

正常來說,新建的 Guest OS 在安裝「客端額外功能(Guest Additions)」並重新啟動 Guest OS 之後,「滑鼠整合」就會發揮功效。但若你碰到滑鼠整合功能沒有作用的詭異情形時,你需要編輯 /etc/X11/xorg.conf (*1*1. 若此文件不存在,則 Guest OS 應該是新版的,請參考上一節 dkms 的內容),手動加入下列的設定段落。

Section "InputDevice"
        Identifier      "vboxmouse"
        Driver          "vboxmouse"
        Option          "CorePointer"
        Option          "Device"        "/dev/input/mice"
EndSection


正常來說,就算 xorg.conf 沒有上述的 InputDevice 段落,滑鼠整合功能依然會作用。

我今天新裝了一個 Ubuntu 9.04 Desktop 的 guest 系統,安裝客端額外功能後,滑鼠整合功能竟然沒有發生作用。我覺得很奇怪,已經我先前安裝過數次 Ubuntu Desktop 作為 guest 系統,但都沒發生這問題。查詢後才知道,有時候要自己手動加入上述的設定內容。我開啟先前安裝的 Ubuntu Desktop guset ,把兩邊的 xorg.conf 比對一下,結果先前安裝的 Ubuntu Desktop guest 的 xorg.conf 沒有這一段,但滑鼠整合還是可作用。真是怪哉。

螢幕解析度可調整項目變少了


首先,如果是 Ubuntu 9.04 的使用者,可以參考我先前寫的使用筆記,按照裡面的步驟修正客端額外功能的安裝程式。 Ubuntu 9.10 的使用者,請參考 Logan 寫的Ubuntu 9.10 + VirtualBox Guest Additions修正。

當我安裝額外功能並重新啟動 guest 系統後的第一次晝面,我的螢幕解析度有 1280x768 (按預設 12MB 顯示記憶體)。我啟動 Ubuntu Desktop 的「顯示」控制台,一開始顯示我可以選擇從 1280x768 到 640x480 的5種解析度。接著我將螢幕解析度下調到 1024x768。調整完畢後,我很訝異地發現,在「顯示」控制台內,我可以選擇的解析度只剩下 1024x768 到 640x480 的3種解析度了。我沒有辦法再往上調整更高的解析度了。

如果你跟我一樣碰到這種情形,我們需要編輯 /etc/X11/xorg.conf ,手動在 Screen 段落中,加入 Display 的子段落,明確地列出我們希望能調整的解析度項目。如下所示:

Section "Screen"
   Identifier   "Default Screen"
   Monitor      "Configured Monitor"
   Device      "Configured Video Device"

   DefaultDepth    24
   SubSection      "Display"
      Depth           24
      Modes           "800x600" "1440x900" "1360x768" "1280x1024" "1280x960" "1152x864" "1024x768" 
   EndSubSection

EndSection

上例設定範例,列出7種解析度,那麼在「顯示」控制台中,就會至少出現這7種解析度供我們選擇。不再愈調愈少。

登入晝面(GDM)會取 Modes 中的第一個項目作為解析度。所以我把 800x600 放在第一個。

No comments:

Post a Comment

Note: Only a member of this blog may post a comment.