本文介绍如何Linux如何开机自动mount Windows cifs共享,可以在server重启时候自动mount数据,不影响应用程序的数据访问
- linux安装cifs驱动
sudo apt-get install cifs-utils
- 创建credentials文件保存用户密码。
将文件改为 600权限.dxi@mylinux:~$ cat .smbcredentials username=dxi password=mypassword
- 在 /etc/fstab 中增加cifs mount
dxi@mylinux:~$ cat /etc/fstab # /etc/fstab: static file system information. # # Use 'blkid' to print the universally unique identifier for a # device; this may be used with UUID= as a more robust way to name devices # that works even if disks are added and removed. See fstab(5). # # <file system> <mount point> <type> <options> <dump> <pass> //windows_server_name/datasets /mnt/data/datasets cifs credentials=/home/dxi/.smbcredentials,iocharset=utf8,sec=ntlm 0 0
- 验证是否mount成功
sudo mount -a