尔爸 發表於 2021-4-14 17:11:06

virtualbox下怎么实现ubuntu20.04开机自动挂载共享文件夹?

<p>今天我们就来看看VirtualBox虚拟机安装Ubuntu20.04后,如何实现开机自动挂载VirtualBox共享文件夹呢?详细请看下文介绍。</p>
<p>安装Ubuntu20.04LTS,并安装VirtualBox内置的增强功能<strong>,关闭虚拟机</strong>。</p>
<p align="center"><img alt="" src="https://img.jbzj.com/file_images/article/202104/20210414165532139.jpg" /></p>
<p>在VirtualBox主界面中Ubuntu20.04对应虚拟机,选择&ldquo;<strong>设置</strong>&rdquo;,在设置中定位到&quot;<span style="color: #ff0000"><strong>共享文件夹</strong></span>&quot;,点击右侧添加按钮,如图:</p>
<p align="center"><img alt="" src="https://img.jbzj.com/file_images/article/202104/20210414165532140.jpg" /></p>
<p align="center"><img alt="" src="https://img.jbzj.com/file_images/article/202104/20210414165532141.jpg" /></p>
<p>在弹出的对话框中设置在windows中需要共享的文件位置,其他选择将&ldquo;<span style="color: #ff0000"><strong>固定挂载</strong></span>&rdquo;前对勾选中,点击&ldquo;<strong>OK</strong>&rdquo;。在&ldquo;设置&rdquo;对话框中选择&ldquo;<strong>OK&rdquo;</strong>如图:</p>
<p align="center"><img alt="" src="https://img.jbzj.com/file_images/article/202104/20210414165533142.jpg" /></p>
<p align="center"><img alt="" src="https://img.jbzj.com/file_images/article/202104/20210414165533143.jpg" /></p>
<p>启动虚拟机,开机完成后,按Ctrl+Alt+T打开终端,输入:<span style="color: #ff0000"><strong>sudo gedit /lib/systemd/system/rc-local.service</strong></span>,&quot;回车&quot;,打开并编辑rc-local.service内容,最后追加:</p>
<div class="jb51code">
<pre class="brush:plain;">

WantedBy=multi-user.target
Alias=rc-local.service</pre>
</div>
<p>保存关闭。如图:</p>
<p align="center"><img alt="" src="https://img.jbzj.com/file_images/article/202104/20210414165533144.jpg" /></p>
<p align="center"><img alt="" src="https://img.jbzj.com/file_images/article/202104/20210414165533145.jpg" /></p>
<p>在终端中输入:</p>
<p><strong>sudo gedit /etc/rc.local</strong></p>
<p>回车</p>
<p>在弹出来的文件中填写如下内容:</p>
<div class="jb51code">
<pre class="brush:plain;">
#!/bin/sh
mount -t vboxsf shared /mnt/shared
exit 0</pre>
</div>
<p>其中&ldquo;shared&rdquo;是之前共享文件夹中的共享文件名。</p>
<p>保存,关闭。</p>
<p align="center"><img alt="" src="https://img.jbzj.com/file_images/article/202104/20210414165534146.jpg" /></p>
<p align="center"><img alt="" src="https://img.jbzj.com/file_images/article/202104/20210414165534147.jpg" /></p>
<p>在终端中输入以下命令:</p>
<p>1. 新建连接文件夹:</p>
<p><span style="color: #ff0000"><strong>sudo mkdir /mnt/shared</strong></span></p>
<p>2. 在/systemd/system下创建软链接:</p>
<p><span style="color: #ff0000"><strong>sudo ln -s /lib/systemd/system/rc-local.service /etc/systemd/system/</strong></span></p>
<p>重新启动后就可以在/mnt/shared下看到已经挂载文件夹的内容了。如需在桌面创建软链接(快捷方式),可以在终端输入:</p>
<p><strong>ln -s /mnt/shared ~/桌面/</strong></p>
<p>如果是英文系统输入</p>
<p><strong>ln -s /mnt/shared ~/desktop/</strong></p>
<p align="center"><img alt="" src="https://img.jbzj.com/file_images/article/202104/20210414165534148.jpg" /></p>
<p>以上就是ubuntu20.04 开机自动挂载virtualbox共享文件夹的技巧,希望大家喜欢,请继续关注琼殿技术社区。</p>
<p><strong>相关推荐:</strong></p>
<p><a target="_blank" href="https://www.jb51.net/os/Ubuntu/676977.html">Ubuntu系统怎么查看磁盘使用情况? </a></p>
<p><a target="_blank" href="https://www.jb51.net/os/Ubuntu/682640.html">Ubuntu系统怎么打开蓝牙? Ubuntu蓝牙的打开方法</a></p>
<p><a target="_blank" href="https://www.jb51.net/os/Ubuntu/682918.html">Ubuntu怎么建文件夹? Ubuntu创建桌面文件夹的三种方法</a></p>
頁: [1]
查看完整版本: virtualbox下怎么实现ubuntu20.04开机自动挂载共享文件夹?