VirtualBox/SharedFolders


Introduction

This explains how to share files and folders (directories) between host and guest. (Files are shared over a network, in other words, you access remote files. For virtual machines, the network between host and guest is virtual since they are on the same real machine. But the steps you take are similar to setting up file sharing over real networks.)

Required: Virtualbox Guest Additions

Before sharing folders, you must install Guest Additions. For instructions on how to do this, see Guest Additions.

Creating a shared folder

  • Create a folder on the Host computer (ubuntu) that you would like to share, for example ~/share

  • Boot the Guest operating system in VirtualBox.

  • Select Devices -> Shared Folders...

  • Choose the 'Add' button.
  • Select ~/share

  • Optionally select the 'Make permanent' option

Prepare the folder

Linux

With a shared folder named share, as above, the folder can be mounted as the directory ~/host with the command

sudo mount -t vboxsf -o uid=$UID,gid=$(id -g) share ~/host

Windows

On the Windows Guest, run

net use x: \\vboxsvr\share

Now anything placed in this folder should be visible from the host in the ~/share folder.

Troubleshooting

This can be done more generically with the following:

sharename="whatever.you.want.to.call.it"; 
sudo mkdir /mnt/$sharename
sudo chmod 777 /mnt/$sharename
sudo mount -t vboxsf -o uid=1000,gid=1000 $sharename /mnt/$sharename
ln -s /mnt/$sharename $HOME/Desktop/$sharename

For the above command if you get the following error:

mount: unknown filesystem type 'vboxsf'

Then just change the vboxsf to vboxfs

If you want to have it mount automatically upon each boot, put the mount command in /etc/rc.local Debian distros (e.g. Ubuntu 10.04 and later) HOWTO Use Shared Folders

See Section 4.4 "Folder Sharing" in the VirtualBox documentation.

Note: if you want to mount the directory as owned and writable only by root, omit the  -o uid=1000,gid=1000  option to the mount command

/sbin/mount.vboxsf: mounting failed with the error: Protocol error

The above error could be one of the following.

The name was not valid

Make sure you specified the right name on the bash commands. If the guest machine is expecting "share" (as we did in the Prepare Host section) and you wrote

sharename="donotshare"
sudo mkdir /mnt/$sharename 
sudo chmod 777 /mnt/$sharename 
sudo mount -t vboxsf -o uid=1000,gid=1000 $sharename /mnt/$sharename 
ln -s /mnt/$sharename $HOME/Desktop/$sharename

it will not work.

Ubuntu 10.04 host

Note: Running on Ubuntu 10.04 host and Mint 14 as virtual system, the system would not accept a ~/share. It complained that it was not an absolute address. I entered /home/jim/share and it worked fine.

e. g.

  • Create a folder on the Host computer (ubuntu) that you would like to share, for example ~/share

  • Boot the Guest operating system in VirtualBox.

  • Select Devices -> Shared Folders...

  • Choose the 'Add' button.
  • Select '/home/<user>/share' for Folder Path

  • Select 'share' for Folder Name
  • Optionally select the 'Make permanent' option
### 回答1: 1. 首先下载并安装VirtualBox软件,可以在官网下载:https://www.virtualbox.org/wiki/Downloads 2. 下载Ubuntu 18.04的ISO镜像文件,可以在官网下载:https://ubuntu.com/download/desktop 3. 打开VirtualBox软件,点击“新建”按钮,输入虚拟机名称,选择操作系统类型为“Linux”,版本选择“Ubuntu(64位)”,点击“下一步”。 4. 分配虚拟机内存大小,建议至少分配2GB以上,点击“下一步”。 5. 创建虚拟硬盘,选择“创建虚拟硬盘现在”,点击“创建”。 6. 选择虚拟硬盘文件类型,建议选择默认的VDI格式,点击“下一步”。 7. 选择虚拟硬盘存储方式,建议选择默认的动态分配方式,点击“下一步”。 8. 分配虚拟硬盘大小,建议至少分配20GB以上,点击“创建”。 9. 在VirtualBox主界面中选择新建的虚拟机,点击“设置”按钮,选择“存储”选项卡,点击“控制器:IDE”下的“空白”,选择“虚拟光驱”,点击“选择虚拟光盘文件”,选择之前下载的Ubuntu 18.04的ISO镜像文件。 10. 点击“启动”按钮,启动虚拟机,按照提示安装Ubuntu 18.04操作系统即可。 11. 安装完成后,可以在VirtualBox中设置共享文件夹,方便在虚拟机和主机之间传输文件。具体操作可以参考VirtualBox官方文档:https://www.virtualbox.org/manual/ch04.html#sharedfolders ### 回答2: 虚拟机是利用一台计算机单独运行出多个操作系统的一种技术。其中,VirtualBox是比较常用的虚拟机软件之一。本文将为大家介绍如何使用VirtualBox安装运行Ubuntu 18.04。 步骤一:安装VirtualBox 在官方网站上下载VirtualBox官方安装包,安装过程中可以根据默认设置进行安装。 步骤二:下载Ubuntu 18.04 在官网上下载Ubuntu 18.04版本的ISO镜像文件。 步骤三:创建虚拟机 打开VirtualBox软件,点击“新建”按钮,在弹出窗口中填写虚拟机的名称、类型、版本等信息,选择合适的分配内存大小。 步骤四:配置虚拟机 1. 点击“设置”按钮,进入虚拟机设置页面,选择“存储”选项卡。 2. 点击“控制器:IDE”下方的“添加光盘”按钮,在弹出操作界面中选择“虚拟光盘文件”。 3. 选择刚才下载的Ubuntu 18.04镜像文件。 4. 点击“网络”选项卡,连接网络方式选择“桥接”。 步骤五:安装Ubuntu 18.04 1. 启动虚拟机。 2. 虚拟机启动后,会出现安装界面,选择“安装Ubuntu”。 3. 选择系统语言,点击“继续”按钮。 4. 在“安装类型”界面中,选择“安装Ubuntu并覆盖磁盘”。 5. 设置时区、键盘布局等信息。 6. 创建用户和设置密码等信息。 7. 点击“安装”按钮,等待安装过程完成。 步骤六:使用Ubuntu 18.04 1. 安装完成后,重启虚拟机。 2. 输入用户名和密码进行登录即可。 总结: VirtualBox安装Ubuntu 18.04的过程虽然有很多步骤,但是相对来说比较简单,只需要按照以上步骤一步步进行即可。通过安装Ubuntu 18.04,用户可以在Windows操作系统下,体验到Linux的使用便捷性,同时也可以学习到相关的知识。 ### 回答3: virtualbox是一款免费且开源的虚拟机软件,可以让用户在自己的电脑上创建多个独立的虚拟操作系统。在使用虚拟机时,往往需要安装操作系统,本文将介绍如何在virtualbox中安装ubuntu18.04。 第一步:下载虚拟机软件 在virtualbox官网下载最新版本的虚拟机软件,并按照安装向导进行安装。 第二步:下载ubuntu18.04操作系统 在ubuntu官网下载最新版本的ubuntu18.04操作系统,成为iso文件。 第三步:创建虚拟机 打开virtualbox软件,点击左上角的“新建”按钮,输入虚拟机名称、虚拟机类型和版本(Linux,Ubuntu)等信息,并设置虚拟机的内存、硬盘空间和网络设置等参数。在虚拟机硬盘设置中选择“创建虚拟硬盘”选项,在接下来的步骤中选择“VDI形式”和“动态分配”,并设置硬盘大小。 第四步:安装ubuntu18.04 在创建好的虚拟机列表中选中新建的虚拟机并点击“启动”按钮,此时会弹出虚拟光驱的设置窗口,选择之前下载的ubuntu18.04的iso镜像文件。在安装过程中会出现如下设置选项: 选择语言、时区和键盘布局等基础设置; 选择是否安装第三方软件; 选择分区方式并进行磁盘分区; 输入用户信息和登录密码; 等待安装完成即可。 第五步:运行ubuntu18.04 安装ubuntu18.04系统完成后,重启虚拟机,从主界面选择安装好的ubuntu系统并进行登录即可。 以上就是virtualbox安装ubuntu18.04的步骤。通过虚拟机软件,我们可以在同一台电脑上创建多个不同的虚拟机系统进行使用,在实际开发和测试过程中,虚拟机的使用也为用户提供了方便。
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值