vm 将宿主机文件夹 映射至 虚拟机

一、关于centos如何安装(自行百度)

二、设置共享文件夹

  • 添加共享文件夹(关闭虚拟机时操作)
虚拟机->设置->选项->共享文件夹

共享文件夹配置

三、安装vm-tools (请用root用户执行)

  • 3.1 安装vm-tools
yum install -y open-vm-tools open-vm-tools-desktop
  • 3.2 挂载
# 1 查看共享的目录
vmware-hgfsclient
# www

# 2 创建hgfs 文件夹
mkdir -p /mnt/hgfs

# 3 用vmhgfs-fuse命令挂载目录
vmhgfs-fuse .host:/ /mnt/hgfs

# 4 此刻 www 目录即 真正挂载到 虚拟机上了
ls /mnt/hgfs
# www
  • 3.3 系统启动即自动挂载
    因为每次开机需要重新执行上述命令 ,所以想让系统自动挂载. 执行如下操作可使系统自动挂载
# 1 执行命令
mount -t fuse.vmhgfs-fuse .host:/ /mnt/hgfs -o allow_other
# 2 添加数据
vim /etc/fstab
# 在末尾另起一行 添加下面一行
.host:/ /mnt/hgfs fuse.vmhgfs-fuse allow_other 0 0
# 3 重新挂载
vmhgfs-fuse .host:/ /mnt/hgfs

四、软连接至/home 目录下

ln -s /mnt/hgfs/www /home/www
原文地址:https://www.cnblogs.com/xiaobaiskill/p/11298236.html