分成4种情况,win->win映射、linux->linux映射、linux->win、win->linux。
这里只介绍后面两种情况。
linux映射到windows
- 虚拟机可以安装vmware-tools,开启文件夹共享
- 利用Ubuntu 共享
- 安装samba,按照以下步骤
# install depend softwares
# install samba
apt install samba
# modify profile
# uncomment all configure of `homes` labels
vim /etc/samba/smb.conf
# add users
smbpasswd -a root
# restart samba
service samba restart
在这里按照提示输入地址,账号密码。如果不行就关闭防火墙与selinux
# 关闭firewall
service ufw stop
# 临时关闭selinux
setenforce 0
windows映射到linux
- 同上!虚拟机共享
- 按照下面步骤
# on windows, enable sharing and build a share directory
# install samba client
apt install samba-client cifs-utils
新建脚本文件mount_windows.sh
添加以下内容。
mount.cifs //windows_ip_address/directory_of_share /root -o username=windows_user,password=windows_password
运行这个文件就挂在在root目录下了。