virtual box實現centos和windows共用資料夾,virtualcentos

來源:互聯網
上載者:User

virtual box實現centos和windows共用資料夾,virtualcentos
    今天在要實現centos(在virtualbox中)和windows實現共用資料夾的過程中遇到諸多錯誤,費了一下午時間來搞這個,首先配置共用資料夾的方法就不介紹了,這裡面介紹的是在配置的過程中遇到的諸多錯誤

  1. 在VirtualBox的菜單裡選擇“裝置”->“安裝增強功能包(Install Guest Additions)”
  2. 之後案頭會出現一個光碟片,在命令列裡輸入:
    • cd /media/VBOXADDITIONS_4.3.12_93733/
    • 然後輸入sudo ./VBoxLinuxAdditions.run 
  3. 然後神奇的事情發生了,在安裝增強功能包的時候,就出現了錯誤,如下
    • Building the main Guest Additions module [FAILED]
    • (Look at /var/log/vboxadd-install.log to find out what went wrong)
  4. 思索著難道是VirtualBox版本過舊嗎?於是更新VirtualBox,依然於事無補
  5. 於是進入日誌查看發生了什麼(/var/log/vboxadd-install.log)
  6. 日誌裡面這麼寫著(Error: unable to find the sources of your current Linux kernel.Specify KERN_DIR=<directory> and run Make again)
  7. 奇怪,這個玩意居然說不知道當前的linux kernel源,在一個外文網站發現老外遇到同樣的問題,搞了n久之後終於起效,哎,痛苦的一筆。
  8. 先是試了如下命令:
    1. $ sudo yum updatethen
    2. $ sudo yum install kernel-devel gcc
    3. $ echo export KERN_DIR=/usr/src/kernels/`uname -r` >> ~/.bashrc
  9. 然後又試了如下命令:
    1.  yum install kernel* dkms gcc
    2. Then
    3. yum install kernel-uek-devel
    4. Then reboot your machine
  10. 之後沒有重啟,試著重新安裝增強功能包,依然錯誤,重啟之後又試了這兩個命令:yum install kernel* dkms gcc;yum install kernel-uek-devel,完事,安裝增強功能包:
    Installing additional modules ...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 [ OK ]Doing non-kernel setup of the Guest Additions [ OK ]Starting the VirtualBox Guest Additions [ OK ]Installing the Window System driversInstalling X.Org Server 1.13 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.
    終於看到綠色的ok了,真是太不容易了,然後繼續mount -t vboxsf linux_share /mnt/share,linux_share是在VirtualBox中設定的共用檔案名稱,/mnt/share是centos中建立的檔案夾,注意兩個檔案夾名字最後不要一樣,防止出現其他錯誤。
  11. 後來在測試的時候,我使用的是xshell,發現這玩意不支援中文,真是跪了,中國人太不容易了,特別是程式員,幸好在網上發現了這個,好東西啊,就要共用啊
  12. http://moralistxp.blog.163.com/blog/static/1161103982013112411540183/
  13. http://jingyan.baidu.com/article/3ea51489eca4b452e61bbaca.html
  14. 別忙還沒完,如果你不想每次都手動載入的話,那麼假如您不想每一次都手動掛載,可以在/etc/fstab中添加一項 linux_share /mnt/share vboxsf rw,gid=100,uid=1000,auto 0 0,以後就會每次開機自動載入。已親測,可用。
  15. 如果想要卸載的話,使用umount -f /mnt/share,如果出現umount2: Device or resource busy
    1. umount: /mnt/share: device is busy.
    2. (In some cases useful info about processes that use
    3. the device is found by lsof(8) or fuser(1))
    4. umount2: Device or resource busy
    5. 說明你還沒有退出該目錄,或者掛載裝置正在使用中
  16. 如果有不確定的地方,可以參考http://jingyan.baidu.com/article/2fb0ba40541a5900f2ec5f07.html


Virtualbox共用資料夾設定裡自動掛載什意思?

就是虛擬機器裡面的系統一啟動就自動的把你的 D盤載入上了。
你的虛擬機器裝什麼系統?如果是windows ,看看資源管理員裡面是不是多出一個盤符,如果是linux,/media目錄下應該有一個以sf_開頭的子目錄。看完以後,關閉虛擬機器,把自動掛載取消,再進虛擬機器重複剛才的操作就明白了。
 
VirtualBox在Windows中安裝Ubuntu的共用檔案方法 ?

VirtualBox可以通過分配資料空間來實現主機和虛擬機器之間的資料交換。首先要給虛擬機器安裝增強功能包,然後在“資料空間”裡面添加一個固定分配的資料空間,名稱改為share(名稱可以任意定)。

如果虛擬機器是Linux系統,以Ubuntu為例,假設掛載目錄是/home /aaa/sharefile,(此檔案夾要先行設立,例如 /home/aaa/ccc 可以任意定 )

直接在終端執行下列命令即可:
sudo mount -t vboxsf share /home/aaa/sharefile/

這個時候開啟 sharefile檔案夾,裡面就是主機share中的檔案內容了。

如果要取消掛載,使用下列命令:
sudo umount /home/aaa/sharefile/

這個可以
然後在VirtualBox取消分配空間即可。
 

相關文章

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.