1. 程式人生 > 實用技巧 >VirtualBox中Linux設定共享資料夾

VirtualBox中Linux設定共享資料夾

設定共享檔案路徑

點選虛擬機器 設定-->選擇 共享資料夾

(圖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

得到輸出內容

  1. [root@localhost VBOXADDITIONS_5.1.2_108956]# ./VBoxLinuxAdditions.run
  2. Verifying archive integrity... All good.
  3. Uncompressing VirtualBox 5.1.2 Guest Additions for Linux...........
  4. VirtualBox Guest Additions installer
  5. Removing installed version 5.1.2 of VirtualBox Guest Additions...
  6. vboxadd.sh: Stopping VirtualBox Additions.
  7. vboxadd-service.sh: Stopping VirtualBox Guest Addition service.
  8. Copying additional installer modules ...
  9. Installing additional modules ...
  10. vboxadd.sh: Building Guest Additions kernel modules.
  11. vboxadd.sh: You should restart your guest to make sure the new modules are actually used.
  12. vboxadd.sh: Starting the VirtualBox Guest Additions.
  13. You may need to restart the the Window System (or just restart the guest system)
  14. to enable the Guest Additions.

即安裝成功!

掛載共享資料夾

進入Linux,開啟終端,建立掛載點目錄,這裡為/home/deepin/Downloands

sudo mkdir /mnt/shared如果是/home/deepin/Downloands 不用建立

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

sudo mount -t vboxsf shared_file /home/deepin/Downloands  這裡要注意大小寫

注意格式為

sudo mount -t vboxsf 共享資料夾名稱(在設定頁面設定的) 掛載的目錄

然後進入/mnt/shared,就可以看到windows中的檔案了

設定自動掛載,可以在/etc/fstab中新增一項
sudo vim /etc/fstab
share /mnt/shared vboxsf rw,gid=110,uid=1100,auto 0 0
解除安裝掛載點命令
sudo umount -f/home/deepin/Downloands

其他使用技巧

如果宿主機是windows經常需要來回的拷貝內容,那麼可以開啟【共享貼上板】,步驟為:

裝置-->共享貼上板-->雙向