Linux开机自动mount windows cifs共享

本文介绍如何Linux如何开机自动mount Windows cifs共享,可以在server重启时候自动mount数据,不影响应用程序的数据访问

  1. linux安装cifs驱动
    sudo apt-get install cifs-utils
    
  2. 创建credentials文件保存用户密码。
    dxi@mylinux:~$ cat .smbcredentials
    username=dxi
    password=mypassword
    
    将文件改为 600权限.
  3. 在 /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
    
  4. 验证是否mount成功
    sudo mount -a
    

参考文献:
MountWindowsSharesPermanently

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章