分成4種情況,win->win映射、linux->linux映射、linux->win、win->linux。
這裏只介紹後面兩種情況。
linux映射到windows
- 虛擬機可以安裝vmware-tools,開啓文件夾共享
- 安裝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
service ufw stop && 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目錄下了。