1. 程式人生 > >VirtualBox在CentOS中安裝VBOXADDITIONS

VirtualBox在CentOS中安裝VBOXADDITIONS

               

在 Oracle Linux 上安裝 Shared Folders

對於 Oracle Database 11g,ZIP 安裝檔案總共有 2 GB 多。由於需要從每個來賓 VM 訪問它們以安裝資料庫,我決定利用 Oracle VM VirtualBox 的 Shared Folders。Shared Folders 特性允許來賓 VM 訪問主機檔案系統中的儲存,因此它允許我對每個 VM 都訪問相同的安裝檔案。

Shared Folders 是 Oracle VM VirtualBox 的 Guest Additions 中提供的附加功能。Guest Additions 程式包提供可增強來賓作業系統基本功能的裝置驅動程式和系統應用程式。除了 Shared Folders 功能之外,Guest Additions 還包含多個作業系統特定的外掛,如無縫視窗、滑鼠指標整合和更好的視訊支援。

Oracle VM VirtualBox 安裝目錄中的 ISO 檔案中提供了受支援的來賓作業系統型別的 Guest Additions。要安裝適用於特定 VM 的 Guest Additions,可將來賓 VM 中的 ISO 檔案掛載為虛擬 CD-ROM 映像(如果尚未掛載)並從那裡進行安裝。我使用了 Linux 來賓中的一個終端視窗,並將目錄更改為 ISO 掛載點以執行安裝指令碼。我第一次嘗試在 Oracle Linux 來賓 VM 中安裝 Guest Additions 時,安裝失敗了,如清單 2 所示。

清單 2:Guest Additions 安裝失敗
# sh ./VBoxLinuxAdditions.run
Verifying archive integrity... All good.Uncompressing VirtualBox 4.1.2 Guest Additions for Linux.........VirtualBox Guest Additions installerRemoving existing VirtualBox DKMS kernel modules           [  OK  ]Removing existing VirtualBox non-DKMS kernel modules       [  OK  ]Building the VirtualBox Guest Additions kernel modulesThe headers for the current running kernel were not found. If the followingmodule compilation fails then this could be the reason.The missing package can be probably installed withyum install kernel-devel-2.6.32-100.26.2.el5Building the main Guest Additions module                   [FAILED](Look at /var/log/vboxadd-install.log to find out what went wrong)Installing the Window System driversInstalling X.Org 7.1 modules                               [  OK  ]Setting up the Window System to use the Guest Additions    [  OK  ]You may need to restart the hal service and the Window System (or just restartthe guest system) to enable the Guest Additions.Installing graphics libraries and desktop services component[  OK  ]Press Return to close this window...

清單 2 中所示輸出的日誌檔案 /var/log/vboxadd-install.log 指示問題在於缺少核心資源:

# more /var/log/vboxadd-install.log/tmp/vbox.0/Makefile.include.header:94: *** Error: unable to find the sources of your current Linux kernel. Specify KERN_DIR=<directory> and run Make again.  Stop.

Fat Bloke 部落格的幫助下,我確認了問題的根源。Oracle Linux 自帶了兩個核心:一個是與 Red Hat 100% 相容的,另一個是 Unbreakable Enterprise Kernel (UEK)。我的 Linux 來賓執行的是 UEK,因此需要安裝相應的gcckernel-uek-devel 程式包,以便 Guest Additions 安裝能夠正常工作。這是因為 Guest Additions 安裝需要構建和安裝核心驅動程式。我使用了以下yum install 命令來下載和安裝缺少的程式包:

# yum update# yum install gcc# yum install kernel-uek-devel    (yum output not shown)

這次,指令碼執行無誤,如清單 3 所示。

清單 3:Guest Additions 安裝成功
# sh ./VBoxLinuxAdditions.runVerifying archive integrity... All good.Uncompressing VirtualBox 4.1.2 Guest Additions for Linux.........VirtualBox Guest Additions installerRemoving installed version 4.1.2 of VirtualBox Guest Additions...Removing existing VirtualBox DKMS kernel modules        [  OK  ]Removing existing VirtualBox non-DKMS kernel modules    [  OK  ]Building the VirtualBox Guest Additions kernel modulesBuilding the main Guest Additions module                [  OK  ]Building the shared folder support module               [  OK  ]Building the OpenGL support module                      [FAILED](Look at /var/log/vboxadd-install.log to find out what went wrong)Installing the Window System driversInstalling X.Org 7.1 modules                            [  OK  ]Setting up the Window System to use the Guest Additions [  OK  ]You may need to restart the hal service and the Window System (or just restartthe guest system) to enable the Guest Additions.Installing graphics libraries and desktop services component[  OK  ]Press Return to close this window...

注意,OpenGL 模組仍然失敗,因為 Oracle Solaris 主機平臺沒有 OpenGL 驅動程式(Windows、現代 Linux 環境和 Mac OS X 不是這樣),但這並不重要,也與我想做的無關。

使用 Shared Folders

為了能夠從 Linux 來賓 VM 訪問主機資料夾,首先要確保該資料夾已經正確匯出以備共享。然後,只需單擊來賓 VM 的 Oracle VM VirtualBox Manager 視窗中Details 下的Shared Folders。於是顯示一個彈出視窗,允許配置我想要訪問的主機資料夾的路徑和該來賓 VM 用於掛載點的資料夾名稱,如圖 5 所示。還可以使用 VBoxManage 命令在命令列設定對 Shared Folders 的訪問;參見使用者手冊

設定 Shared Folders

圖 5. 設定 Shared Folders

預設情況下,來賓 VM 將主機資料夾掛載為 /media/sf_<name>,其中 <name> 是您在建立掛載點時指定的名稱。例如,在重新啟動來賓之後,可以看到主機資料夾/Downloads 中的內容在來賓 VM 的/media/sf_Downloads 中。現在,我可以在來賓 VM 中訪問已下載的資料庫 ZIP 檔案。

VirtualBox安裝上最新的CentOS6.4,安裝增強元件時卻發現Building the OpenGL support module                         [FAILED]最後網上一找,得到解決方法cd /media/VBOXADDITIONS_4.1.8_75467/export MAKE='/usr/bin/gmake -i'./VBoxLinuxAdditions.run 安裝的時候使用"make -i" , -i, --ignore-errors   Ignore errors from commands.忽略錯誤。快樂無極提示您:預設安裝的CentOS,在安裝VBOXADDITIONS前還需要yum groupinstall "Development Tools"yum install kernel-devel

oracle vm,virtualbox增強包VboxAdditions的安裝和共享資料夾

1開機登入linux系統 點選 裝置—安裝增強功能

2桌面上會顯示VBOXADDITIONS_4.1.2_73507

不是root使用者的切換到root使用者輸入su – 按下確定

輸入cd /media/ 點確定

輸入cd  VBOXADDITIONS_4.1.2_73507

輸入 sh ./ VBoxLinuxAdditions.run(看具體檔名叫什麼)

7安裝好重啟

這樣這個增強包就裝好了

接著和主機共享檔案

1首先先在主機上新建一個資料夾共享這個資料夾

2然後點選虛擬機器上的   裝置按鈕

然後點新增資料空間

分配好了確定

root的許可權下實施如下命令:#mkdir /mnt/gongxiang     建樹一個目錄來掛載共享資料夾;當然你可以在任何處所建樹一個目錄 

然後輸入這個命令 # mount -t vboxsf gongxiang /mnt/gongxiang 

到這如果你要和主機共享什麼檔案    就把這個檔案拖到這個資料夾裡

設定共享資料夾

點選【裝置】,選擇【共享資料夾】選單,如下圖所示。

點選新增一個共享資料夾,選項固定和臨時是指該資料夾是否是持久的。共享名可以隨意取,如【share1】,儘量使用英文名稱,不要有空格,選擇資料夾所處的位置,比如【E:\share1】,點選確定,如下圖所示。

開啟終端,在CentOS系統中建立一個資料夾,如在/mnt下建立一個share1資料夾。

程式碼如下:

Linux程式碼  收藏程式碼
  1. mkdir /mnt/share1  

在CentOS系統中,訪問在之前系統中設立的共享文件夾

程式碼如下:

Linux程式碼  收藏程式碼
  1. mount -t vboxsf share1 /mnt/share1  

其中"share1"是之前建立的共享資料夾的名字。而"/mnt/share1"是在CentOS中共享資料夾的路徑,如下圖所示。

現在虛擬機器和主機可以互傳檔案了,在原系統“E:\share1”中拷貝兩個檔案,然後在CentOS中檢視,如下圖所示,就可以在此CentOS中看到這兩個檔案了。

設定共享資料夾完成。

http://hermosa-young.iteye.com/blog/1798006