1 Linux host automatically mounts cifs
yum install cifs-utils -y
Method 1: /etc/fstab
Add mount items
# mount -t cifs 共享目录 本地挂载目录 -o username=admin,password=123456
共享目录 本地挂载目录 cifs defaults,auto,username=admin,password=123456 0 0
Example:
mkdir -p /mnt/public
vim /etc/fstab
//192.168.1.147/public /mnt/public cifs defaults,auto,username=admin,password=123456 0 0
Note: You need to create a new mounting folder locally, and be careful not to have too special characters in the username and password.
Method 2: /etc/rc.local
Add the mount command in
mount -t cifs -o username=admin,password=123456 //192.168.1.147/public /mnt/public
If the mounted server port is not the default port, then:
mount -t cifs -o username=admin,password=123456,port=4432 //192.168.1.147/public /mnt/public
After saving the file, execute the mount:
mount -a
Unmount:
umount /mnt/photo
Check the mount point:
df -hT
Generally, CIFS file system is used to achieve file sharing in Linux systems, which requires the installation Samba
of services. Specific reference:
https://blog.csdn.net/weixin_40806910/article/details/81917077
https://www.cnblogs.com/wxx6925/p/15632110.html
2 Windows host automatically mounts cifs
@echo off
net use y: \\10.1.1.31\smb "111111" /user:"user1"
Among them, y
is the network drive letter, 111111
is the password of the logged in user, user1
and is the logged in user .
Put the file C:\Users\Administrator\AppData\Roaming\Microsoft\Windows\Start Menu\Programs\Startup
in the directory and restart to automatically mount it.
ps: There may be hidden directories, and you need to check "Hidden Items" in the "View" properties of the file, as follows:
3 SSHFS mount
SSHFS (Secure SHell FileSystem) is a client that allows us to mount remote file systems through SSH File Transfer Protocol (SFTP) and interact with remote directories and files on the local machine.
yum install sshfs
mkdir -p /mnt/public
vi /etc/rc.local
sshfs [email protected]:/public /mnt/public
mount -a
If the mounted path is not empty:
sshfs -o nonempty [email protected]:/public /mnt/public
reference:
https://www.jianshu.com/p/fa66a2fc5cbb
https://www.cnblogs.com/seaBiscuit0922/p/11240800.html
https://www.linuxprobe.com/sshfs-linux-fires.html