歡迎來到Linux教程網
Linux教程網
Linux教程網
Linux教程網
Linux教程網 >> Linux基礎 >> Linux教程 >> 在VirtualBox中與主機共享文件夾

在VirtualBox中與主機共享文件夾

日期:2017/2/28 13:49:55   编辑:Linux教程

安裝VirtualBox為了共享文件夾,折騰了一晚上!網上的很多資料都不是很全面,這裡就全面的總結一下,如果有其他的疑問,可以留言多多交流。

VirtualBox 5.1發布下載,增加Linux集成並提高多媒體支持 http://www.linuxidc.com/Linux/2016-07/133135.htm

VirtualBox虛擬機XP與宿主機Ubuntu互訪共享文件夾 http://www.linuxidc.com/Linux/2010-09/28457.htm

設置共享文件路徑

點擊虛擬機 設置-->選擇 共享文件夾

(圖1 設置共享文件夾)

設置共享文件夾路徑

  • 1 選擇路徑
  • 2 填寫自定義的共享名稱(在後面需要與掛載路徑相對應)
  • 3 設置自動掛載/固定分配

(圖2 設置共享文件路徑屬性)

安裝VirtualBox增強工具

先安裝必備的包

執行下面的命令:

yum install -y gcc gcc-devel gcc-c++ gcc-c++-devel make kernel kernel-devel

安裝完後,重啟虛擬機:

shutdown -r now

安裝virtualBox增強工具

點擊 設置-->點擊 安裝增強功能...

(圖3 點擊設置)

自動執行安裝 或者 進入目錄/media/VBOXADDITIONS_5.1.2_108956,執行命令

./VBoxLinuxAddtion.run

得到輸出內容

[root@localhost VBOXADDITIONS_5.1.2_108956]# ./VBoxLinuxAdditions.run 
Verifying archive integrity... All good.
Uncompressing VirtualBox 5.1.2 Guest Additions for Linux...........
VirtualBox Guest Additions installer
Removing installed version 5.1.2 of VirtualBox Guest Additions...
vboxadd.sh: Stopping VirtualBox Additions.
vboxadd-service.sh: Stopping VirtualBox Guest Addition service.
Copying additional installer modules ...
Installing additional modules ...
vboxadd.sh: Building Guest Additions kernel modules.
vboxadd.sh: You should restart your guest to make sure the new modules are actually used.
vboxadd.sh: Starting the VirtualBox Guest Additions.

You may need to restart the the Window System (or just restart the guest system)
to enable the Guest Additions.

即安裝成功!

掛載共享文件夾

切換到root用戶輸入掛載命令:

sudo mount -t vboxsf shared_file /home/xingoo/shared

注意格式為

sudo mount -t vboxsf 共享文件夾名稱(在設置頁面設置的) 掛載的目錄

然後進入/home/xingoo/shared,就可以看到windows中的文件了

(圖4 windows文件)

[root@localhost shared]# ll
total 337516
-rwxrwxrwx. 1 root root 149599799 Aug 15 21:29 apache-hive-2.1.0-bin.tar.gz
-rwxrwxrwx. 1 root root 196015975 Aug 15 21:31 Hadoop-2.6.4.tar.gz
Copyright © Linux教程網 All Rights Reserved