[英]Auto-mount VirtualBox shared folder in fstab on Ubuntu Server 16.04
I have Ubuntu Server 16.04 running in VirtualBox on a Windows 10 host. 我在Windows 10主机上的VirtualBox中运行Ubuntu Server 16.04。 I have VirtualBox guest additions installed and correctly set up shared folders which I am successfully mounting using the "mount" command. 我已经安装了VirtualBox guest虚拟机,并正确设置了共享文件夹,使用“ mount”命令可以成功安装该共享文件夹。 I'd like the shared folder to be mounted on system startup, so I added a record to /etc/fstab like: 我希望在系统启动时挂载共享文件夹,所以我在/ etc / fstab中添加了一条记录,如下所示:
Projects /home/development/projects vboxsf rw,uid=1000,gid=1000 0 0
However, whenever I add a record to fstab the next reboot I get the emergency mode. 但是,每当我将记录添加到fstab时,下次重启时,我都会进入紧急模式。 Please help 请帮忙
As ugly as it is, this post on the Ubuntu site worked for me. 尽管很丑陋,但Ubuntu网站上的这篇帖子对我有用。 It's not the approved answer, but it worked when others didn't. 这不是批准的答案,但是在其他人没有的情况下有效。 The problem seems to be the timing--the vbox shares aren't ready when fstab is running, so instead we mount at user login. 问题似乎是时机问题-运行fstab时vbox共享尚未准备好,因此我们在用户登录时挂载。 I'm sure someone will post a better solution for Ubuntu 16 at some point. 我确定有人会在某个时候发布针对Ubuntu 16的更好的解决方案。
Created share point in host: 在主机中创建共享点:
host$ sudo mkdir -p /path/to/myshare
host$ sudo chown user:user /path/to/myshare
(... added a "myshare" share through VBox UI) (...通过VBox UI添加了“ myshare”共享)
Created mount point in guest: 在来宾中创建挂载点:
guest$ sudo mkdir -p /path/to/myshare
guest$ sudo visudo
Added passwordless sudo permission to mounting in guest: 添加了无密码sudo权限以在客户机中挂载:
guest$ sudo visudo
... adding to end: ...添加到结尾:
# Allow mounting without password
# (hack to allow vbox share mounting to be delayed until user login)
ALL ALL=NOPASSWD: /bin/mount
Added mount action to user ".profile": 向用户“ .profile”添加了挂载操作:
guest$ vi ~/.profile
... adding to the end: ...添加到最后:
sudo /bin/mount -t vboxsf -o uid=$UID,gid=$(id -g) myshare /path/to/myshare
Actually, it is not compulsory to edit the fstab file. 实际上,并非必须编辑fstab文件。 Instead, to mount a shared folder using the vboxsf filesystem provided with Guest Additions, we first need to make sure some prerequisites are met as follows: 相反,要使用Guest Additions随附的vboxsf文件系统挂载共享文件夹,我们首先需要确保满足一些先决条件,如下所示:
In recent releases of Virtual Box, we can also automatically mount shared folders on creation (See the image in the answer provided by @the_ousek) 在最新版本的Virtual Box中,我们还可以在创建时自动挂载共享文件夹(请参阅@the_ousek提供的答案中的图像)
After a reboot of the guest this shared folder will be mounted to the guest directory /media//sf_ accessible to all users who had been made member of the group vboxsf. 来宾重新启动后,此共享文件夹将被安装到来宾目录/ media // sf_,该用户目录已成为组vboxsf的所有用户访问。
More details at https://askubuntu.com/questions/252853/how-to-mount-a-virtualbox-shared-folder-at-startup 有关更多详细信息, 请访问https://askubuntu.com/questions/252853/how-to-mount-a-virtualbox-shared-folder-at-startup
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.