<?xml version="1.0" encoding="utf-8" standalone="yes"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom">
    <channel>
        <title>虚拟机 on 洛鹿松的小站</title>
        <link>https://www.fufu.me/tags/%E8%99%9A%E6%8B%9F%E6%9C%BA/</link>
        <description>Recent content in 虚拟机 on 洛鹿松的小站</description>
        <generator>Hugo -- gohugo.io</generator>
        <language>zh-cn</language>
        <lastBuildDate>Wed, 22 Jan 2025 11:02:41 +0800</lastBuildDate><atom:link href="https://www.fufu.me/tags/%E8%99%9A%E6%8B%9F%E6%9C%BA/index.xml" rel="self" type="application/rss+xml" /><item>
        <title>Vmware虚拟机持久挂载共享文件夹</title>
        <link>https://www.fufu.me/vmpersismount/</link>
        <pubDate>Wed, 22 Jan 2025 11:02:41 +0800</pubDate>
        
        <guid>https://www.fufu.me/vmpersismount/</guid>
        <description>&lt;img src="https://www.fufu.me/img/VMware.png" alt="Featured image of post Vmware虚拟机持久挂载共享文件夹" /&gt;&lt;h2 id=&#34;使用场景&#34;&gt;使用场景
&lt;/h2&gt;&lt;p&gt;在我们使用Vmware的linux虚拟机时，通常需要在宿主机和虚拟机间传输一些文件，这时候用共享文件夹就很不错。但是在设置好后却发现这个文件夹不能自动挂载，一旦关机就消失了。&lt;/p&gt;
&lt;p&gt;这里提供一个我自己写的挂载脚本&lt;/p&gt;
&lt;pre&gt;&lt;code class=&#34;language-shell&#34;&gt;#!/bin/bash

# 定义 knmpn-share.service 文件内容
SERVICE_CONTENT=$(cat &amp;lt;&amp;lt;EOF

[Unit]
Description=knmpn-share Compatibility
Documentation=man:systemd-rc-local-generator(8)
ConditionFileIsExecutable=/etc/knmpn-share
After=network.target

[Service]
Type=forking
ExecStart=/etc/knmpn-share start
TimeoutSec=0
RemainAfterExit=yes
GuessMainPID=no

[Install]
WantedBy=multi-user.target
Alias=knmpn-share.service
EOF
)

SHARE_SCRIPT_CONTENT=$(cat &amp;lt;&amp;lt;EOF
#! /bin/bash
# 确保挂载点存在
/bin/mkdir -p /mnt/hgfs

# 执行挂载
/bin/mount -t fuse.vmhgfs-fuse .host:/ /mnt/hgfs -o allow_other
EOF
)

# 创建并写入 knmpn-share.service 文件
echo &amp;quot;$SERVICE_CONTENT&amp;quot; | sudo tee /lib/systemd/system/knmpn-share.service /etc/systemd/system/knmpn-share.service &amp;gt; /dev/null

# 创建并写入 knmpn-share 脚本文件
echo &amp;quot;$SHARE_SCRIPT_CONTENT&amp;quot; | sudo tee /etc/knmpn-share &amp;gt; /dev/null

# 确保 /etc/knmpn-share 可执行
sudo chmod +x /etc/knmpn-share

# 启用并启动 knmpn-share 服务
sudo systemctl enable knmpn-share
sudo systemctl start knmpn-share.service
sudo systemctl status knmpn-share.service

# 重启系统以应用更改
sudo reboot
&lt;/code&gt;&lt;/pre&gt;
&lt;h2 id=&#34;使用方法&#34;&gt;使用方法
&lt;/h2&gt;&lt;p&gt;1.创建一个share.sh文件，将代码保存到其中并运行。&lt;/p&gt;
&lt;p&gt;2.当不再显示新内容时按q键，会重启一次&lt;/p&gt;
&lt;p&gt;3.共享文件夹在/mnt/hgfs目录下&lt;/p&gt;
&lt;h2 id=&#34;文件下载地址shareshhttpscloudnichttopsnwfb&#34;&gt;文件下载地址：&lt;a class=&#34;link&#34; href=&#34;https://cloud.nicht.top/s/nwfb&#34;  target=&#34;_blank&#34; rel=&#34;noopener&#34;
    &gt;📄share.sh
&lt;span style=&#34;white-space: nowrap;&#34;&gt;&lt;svg width=&#34;.7em&#34;
    height=&#34;.7em&#34; viewBox=&#34;0 0 21 21&#34; xmlns=&#34;http://www.w3.org/2000/svg&#34;&gt;
    &lt;path d=&#34;m13 3l3.293 3.293l-7 7l1.414 1.414l7-7L21 11V3z&#34; fill=&#34;currentColor&#34; /&gt;
    &lt;path d=&#34;M19 19H5V5h7l-2-2H5c-1.103 0-2 .897-2 2v14c0 1.103.897 2 2 2h14c1.103 0 2-.897 2-2v-5l-2-2v7z&#34;
        fill=&#34;currentColor&#34;&gt;
&lt;/svg&gt;&lt;/span&gt;

&lt;/a&gt;

&lt;/h2&gt;</description>
        </item>
        
    </channel>
</rss>
