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 放在第一個。

2014-03-28

嘗試構建自己的busybox

來源 : http://www.360doc.com/content/13/0829/19/7377734_310794205.shtml

1、一個作為宿主機的Linux;本文使用的是Redhat Enterprise Linux 5.4;
2、在宿主機上提供一塊額外的硬盤作為新系統的存儲盤,為了降低複雜度,這裡添加使用一塊IDE接口的新硬盤;
3、Linux內核源碼,busybox源碼;本文使用的是目前最新版的linux-2.6.34.1和busybox-1.16.1。

說明:本文是一個step by step的實做指南;

2014-03-16

反省錄——接納自己,接納一個不成功的我

最近看了一篇文章,因此面對自己最近眾多的不順和不順的氣,有了一個重新認識。
  說實話,我覺得自己是在被社會貼上標籤後感到痛苦、焦慮和煩躁。總而言之,我活在了別人的世界裡。
  年齡愈大,學歷也不錯,別人認為你當然應該有所成就,自己也覺得應該去追求些什麼,至少每一件事不是傻乎乎,做的背後應該不是單純沒有想法的,而應該帶了某種目的,比如被領導賞識、被領導發現你的才能,展示你優秀的辦事能力。然而現實往往事與願違。這可能就是越單純的人獲得成功的幾率就愈大。相反,帶有目的的人反而被自己絆住了。因而,經常咒怨別人,埋怨現實。
  後來,看了一篇文章,我忽然有所領悟,犯的最根本的錯誤就是——沒有接納自己。
  沒有接納自己,所以任何事的風向標都是以別人為標準,被各種不順所羈絆。
  其實,芸芸眾生中,一部分人可能會很成功,達到世俗認為的——位居高職、收穫財富、有房有車等標準,而另一部分人由於個性、性格、能力以及不努力,可能就不會成功。我就是其中一個,應該告訴自己,由於我性格中的缺陷、社交能力的有限、處世的不圓滑,縱然讀得書多,資歷老了,但未必會實現世俗認為的成功。然而,又能怎樣呢?我同樣可以享受當下,享受每分每秒的快樂。超出我能力範圍之外的事情,我真的不應該憂慮。接納自己有多個方面,比如接受由於性格缺陷、能力不足而犯下的錯誤;承認自己的過失,但不要過分懊惱;丟開束縛世俗韁繩。如果你想快樂,誰也掠奪不走。是的,不成功又怎樣,我不是超人。做真實的自己。
  然而自己不成功就算了呢,不是的,我們雖然不成功,但是很有優秀的精神,我們依然要具備,耐心和毅力,其實我們每個人都有,只是因此懶惰,我們會丟掉。我們沒有必要挑戰所有的困難,但偶爾挑戰自己,讓自己更加具有耐心和毅力,卻不失為一種樂趣。如果你做得了,興許忽然發現很多事情突然變順了。
  接納自己,我不是一個成功的人,但我可以做好能力範圍內的事情就好了。
  挑戰自己,給自己每天一點驚喜,欣賞自己的成就。
  這樣的過程,我可以具備。
  接納自己,接納一個不成功的我。

反省錄

有『麻煩』就是『方法不對』, 有『困難』就是『能力不足』, 有『猶疑』就是『膽識不夠』
有『遺憾』就是『謀略不精』, 有『誤會』就是『溝通不良』, 有『怨言』就是『領導不正』
有『奢侈』就是『勤儉不力』, 有『輕浮』就是『心境不靜』, 有『抗爭』就是『執法不公』
有『大話』就是『腳踏不實』, 有『耳輕』就是『事實不查』, 有『迫害』就是『私心不輕』
有『是非』就是『口德不修』, 有『爭執』就是『己言不改』

2014-01-08

Windows 7 mklink命令詳解

mklink是Windows 7下的一個類似於linux下In的命令,其作用是在NTFS文件系統中創建文件或目錄的鏈接(類似於桌面快捷方式)。如果加以利用其發揮的作用是非常的大的,不僅可以幫助我們節省不少時間,而且可以使我們重裝系統後不再丟失用戶文件。

Mklink命令詳細介紹

Windows 7下的mklink命令通過指定參數可以建立出不同形式的文件或目錄鏈接,分為 hard link、symbolic link 和junction 三種。

1.symbolic link

  A symbolic link is like a short-cut but instead of being saved as a file it is registered to the hard drive partition. It does not use any disk space and all programs recognise both the link and the target. A symbolic link can point to any file or folder either locally on the computer or over a network using a SMB path. ( A short cut is a file that points to another file. It is an antiquated pointing system from the Windows 95 era that many programs do not recognise. Short-cuts do not only use up space on the hard drive, they also break and linger behind after the target has been deleted, renamed or moved. )

2.junction

  作用基本和 symbolic link 類似。區別在於,junction 在建立時會自動引用原文件(或目錄)的絕對路徑, 而 symbolic link 允許相對路徑的引用。A junction behaves like a hard link for directories but unlike file hard links you can create junctions that span multiple partitions. Again a directory junction and its content is stored on the hard drive partition but they do not use any additional space. Any changes to the content within either the target or the links will automatically propagate except where the target directory is deleted or renamed. In that case all hard links that point to the target will break and linger on the partition.

3.hard link

  建立一個 hard link 相當於給文件建立了一個別名,例如對1.TXT創建了名字為2.TXT的硬鏈接,若使用記事本對1.TXT進行修改,則2.TXT也同時被修改,若刪除1.TXT,則2.TXT依然存在,且內容與1.TXT一樣。 A file hard link is a little different and can not be used over multiple partitions meaning you can not have a link on drive C: pointing to a file on drive D:. A file hard link points to and duplicates a target as a mirrored copy but the copy does not use any additional space on the hard drive partition. So 2 hard links that mirrored a 1 GB file would  in total only use 1 GB on the partition rather than 3 GB. Importantly if either the hard links or the target are deleted the other links retain the data. Changes to the content of either the target or the links automatically propagate to all other items.

建立鏈接請注意:
1、建立文件或目錄鏈接限於 NTFS 文件系統,symbolic (junction) link 的建立可以跨文件系統;
2、hard link 只能用於文件,不能用於目錄,symbolic (junction) link 可以為目錄建立鏈接;
3、hard link 只能建立同一分區內的文件指向;
4、hard link 不允許對空文件建立鏈接,symbolic (junction) 可以。

Mklink的參數定義

無參數指定:建立文件的符號鏈接。無參數指定的默認情況下,建立的是文件的符號鏈接,刪除鏈接文件不會影響源文件,
/d:建立目錄的符號鏈接符號鏈接(symbolic link)
/j:建立目錄的軟鏈接(聯接)(junction)
/h:建立文件的硬鏈接(hard link)

命令格式:mklink /d(定義參數) \MyDocs(鏈接文件) \Users\User1\Documents(原文件)

最後,至於刪除建立的鏈接,跟刪除文件一樣使用」DEL」命令。

Mklink命令用途

轉移系統中的用戶設置文件

  Windows 7中將用戶設置與系統文件分離, 所有的用戶設置及用戶文件都存儲在C盤下的User目錄 (在中文版Windows 7中顯示為「用戶」目錄), 重裝系統後所有的系統設置及用戶文件都會消失。

  Windows 7安裝完成後可以將C盤下的User目錄轉移到非系統分區,如D盤,這樣,重裝系統後只要重新將C盤下的User目錄鏈接到D盤即可。我們在創建鏈接後系統在訪問C:/User目錄其實是在訪問D:/User目錄。

命令如下:

1.複製User目錄到D盤 : robocopy 「C:\Users」 「D:\Users」 /E /COPYALL /XJ
2.強制刪除User目錄 : rmdir 「C:\Users」 /S /Q
3.創建C盤下的User的軟件鏈接,鏈接到D盤User目錄:mklink /J 「C:\Users」 「D:\Users」

重裝系統後只需重覆第二條和第三條命令及可

有了這條命令就再也不怕重新系統了

2014-01-02

Task Scheduling Error : Event 100, Bonjour Service

暫時解法 :

Solution 1 : 解除安裝 Bonjour 服務.

Solution 2 : Adrian said : Apparently you can ignore this as the Bonjour service (used by iTunes) is quick to record it anytime it "thinks" it experiences an unreasonable delay. If you don't want the event in your logs, you can disable Bonjour (open Services, find Bonjour Service in the list, stop it and change the startup type to "Manual" or "Disabled").

Source: http://www.eventid.net/display-eventid-100-source-Bonjour%20Service-eventno-10659-phase-1.htm

The "Task Scheduling Error" type of problems seem to be a common issue on Windows 7 64 bit. Several users ended up stopping the service in order to avoid the logs being filled with these errors. They would only start the service when needed (iTunes needs this service in order to run properly).
From our experience, iTunes will start regardless of the status of the Bonjour service, however a warning is displayed saying that Bonjour is needed to access shared libraries. The warning will only be shown once so it won't bother you every time iTunes is started. In iTunes Preferences, the Sharing tab will display a message saying that the Bonjour service is required in order to use this feature.

 

安裝 iTunes 之後, 事件檢視器中, 持續出現類似以下的錯誤:

Task Scheduling Error: Continuously busy for more than a second
Task Scheduling Error: m->NextScheduledEvent 7004
Task Scheduling Error: m->NextScheduledSPRetry 7004

2014/01/02 : 嘗試於 AP 防火牆中 disable “Filter multicast”. (還是會發生)

2014/01/04 : AP disable “Filter multicast” 之後, 仍然會發生 Event 100 ERROR; 決定解除安裝 Bonjour, and enable “Filter multicast” again. 觀察後續 iTunes 和 iPhone 搭配使用上是否會有問題.

2014/01/09 : 解壓縮 iTunes64Setup.exe 之後, 單獨安裝 Bonjour64.msi. 再觀察看看.(還是會發生)

2014/01/11 : 改變 Windows 防火牆-進階設定-輸入規則-Bonjour 服務 設定 : 4 rules –> 2 rules. .(還是會發生)
原本 : 設定檔(公用)+程式(32 bits or 64 bits mDNSResponder.exe)+通訊協定(TCP or UDP)
新版 : 設定檔(任何)+程式(32 bits or 64 bits mDNSResponder.exe)+通訊協定(任何)

2014/01/11 19:16 : disable AP DD-WRT SPI firewall .(還是會發生)

2014/01/12 05:32 改變網路卡電源管理, 允許電腦關閉這個裝置以節省電源 : Enabled->Disabled (還是會發生)

2014/01/12 09:20 將 iPod 服務由手動改為自動, Bonjour 服務防火牆設定如下 [不是我設的, 系統自己變成這樣] : (還是會發生)

2014/01/15 04:58 關閉 Windows Firewall ( Testing … )

2014/01/17 03:34 mDNSresponder.exe 改用 x86 版.(還是會發生)

2014/01/17 06:47 改變省電時間設定 ( 10/30 –> 20/20 ) .(還是會發生)

2014-01-12_174052

備註 1 : Bonjour 服務需要 UDP port 5353
Bonjour_Firewall
備註 2 : 需要 Bonjour Service 才能和其他使用者共享音樂, 透過 AirPlay 揚聲器播放音樂, 連接 Apple TV 和使用 iPhone 和iPod touch 遙控器. (目前我似乎用不上)
備註 3 : iTunes64Setup.exe 實際上是一個壓縮檔, 可用 7z.exe 解壓縮.

2013-12-21

如何使 Dr.eye (譯點通) 在電腦啟動時, 自動執行

首先建立 Dreye.exe 桌面捷徑.  開始->啟動->右鍵選`檔案總管`. 將先前建立的桌面捷徑, 直接拉放至檔案總管內.