背景
A、在windows 安装了虚拟机,安装了centos7作为测试环境
B、设置了windows 主机跟虚拟机centos 7 文件夹共享
原因
每当虚拟机重启的时候,虚拟机里面的文件夹共享都不生效,需要手动执行命令
/usr/bin/vmhgfs-fuse .host:/ /data/wwwroot/VM/ -o subtype=vmhgfs-fuse,allow_other
解决
1、添加自定义shell脚本,让虚拟机开机自动执行该脚本
a、写入自定义shell脚本
vi /home/shell/me.sh
b、赋予执行权限
chmod +x /home/shell/me.sh
c、系统目录自动执行文件 /etc/rc.d/rc.local,把脚本添加进入该脚本末尾
echo "/home/shell/me.sh" >> /etc/rc.d/rc.local
d、查看 /etc/rc.d/rc.local 是否有执行权限 没有则执行下面命令(centos7 默认该文件没有执行权限)
chmod +x /etc/rc.d/rc.local
f、reboot 查看脚本是否生效
号外
/usr/bin/vmhgfs-fuse .host:/ /data/wwwroot/VM/ -o subtype=vmhgfs-fuse,allow_other
/data/wwwroot/VM/ 挂载的目录路径
文件夹共享
文件夹设置共享