vmware下Ubuntu虚拟机OS开启共享文件夹,使得Ubuntu与宿主机器通过共享文件夹来实现共享文件数据。
参考博客:
mnt/hgfs 共享文件夹文件丢失不见_bad mount point_Henry Heng的博客-CSDN博客
虚拟机找不到/mnt/hgfs挂载目录_SoldierJazz2021的博客-CSDN博客
1. 给Ubuntu安装open-vm-tools:
sudo install -y open-vm-tools
sudo install -y open-vm-tools-containerinfo
sudo install -y open-vm-tools-salt-minion
sudo install -y open-vm-tools-desktop
sudo install -y open-vm-tools-sdmp
sudo install -y open-vm-tools-dev
2. 在Ubuntu里建立文件夹hgfs:
mkdir hgfs
如图:
3. 使用下面的shell脚步,来加载、卸载共享文件夹
#!/bin/sh
# 运行该shell脚本后, 输入选择标志, 1代表加载共享文件夹, 2代表卸载共享文件夹
read -p "switch(1:mount;2:umount): " flag
if [ $flag -eq 1 ];then
echo "mount host share folder."
vmhgfs-fuse .host:/ /home/think/hgfs
elif [ $flag -eq 2 ];then
echo "umount host share folder."
umount -v /home/think/hgfs
else
echo "error flag value."
fi
运行效果如下图: