zoukankan      html  css  js  c++  java
  • nfs自动挂载

    服务器端

    /etc/exports

    /mnt *(rw,sync,no_root_squash,anonuid=500,anongid=500)
    systemctl restart nfs

    客户端

    挂载有两种

    1.mount -t nfs 192.168.100.124:/mnt /test

    vim /etc/fstab

    nfs挂载:192.168.100.124:/mnt/  /test  nfs  defaults 0 0

    window共享后的挂载方式:

    192.168.100.X/mnt  /test  cifs  defaults ,auto,uid=500,gid=500,domain=abc,username=abc.password=abc  0 0


    2.使用autofs

    vim /etc/auto.master

    添加自动挂载的路径 和配置文件

    例子:

    在auto.master中添加/ceshi/guazai   /etc/auto.mvp         这里/ceshi/guazai 是挂载路径,此时如果ceshi目录不存在,他会自动创建,如果guazai目录存在,他会将挂载目录的内容移到缓存中,并根据auto来挂载新的数据,此时guazai目录无法被写入。请确保改路径下没有数据。
    vim /etc/auto.mvp
    nfs -fstype=nfs 192.168.100.124:/mnt            nfs表示挂载的路径文件名,会自动生成这个文件夹
    systemctl start autofs

    参考连接:https://blog.51cto.com/pascaljanus/495132

    如果根据账号密码则如下设置:

      1. root@localhost:~# cat /etc/auto.misc 
      2. backup      -fstype=cifs,username=backup_user@domain,password=backup_password      ://192.168.1.1/backup

    以下是转载的参考链接:

    链接地址:https://blog.51cto.com/pascaljanus/495132

    1.检查和安装autofs

    1. dpkg -l | grep autofs 
    2.  
    3. sudo apt-get install autofs5 

    2.编辑/etc/auto.master文件,启用misc目录

    1. root@localhost:~# cat /etc/auto.master 
    2. # Sample auto.master file 
    3. # This is an automounter map and it has the following format 
    4. # key [ -mount-options-separated-by-comma ] location 
    5. # For details of the format look at autofs(5). 
    6. /misc   /etc/auto.misc 
    7. # NOTE: mounts done from a hosts map will be mounted with the 
    8. #   "nosuid" and "nodev" options unless the "suid" and "dev" 
    9. #   options are explicitly given. 
    10. #/net   -hosts 
    11. # Include central master map if it can be found using 
    12. # nsswitch sources. 
    13. # Note that if there are entries for /net or /misc (as 
    14. # above) in the included master map any keys that are the 
    15. # same will not be seen as the first read key seen takes 
    16. # precedence. 
    17. +auto.master 

    3.修改/etc/auto.misc文件,添加cifs挂载项

    1. root@localhost:~# cat /etc/auto.misc 
    2. backup      -fstype=cifs,username=backup_user@domain,password=backup_password      ://192.168.1.1/backup 

    4.重启autofs服务

    1. root@localhost:~# service autofs restart 

    5.检查是否成功挂载

    1. root@localhost:~# ls -l /misc/backup 
    2. total 3 
    3. drwxrwxrwx 1 root root    0 2011-02-16 10:25 dns_backup 
    4. drwxrwxrwx 1 root root    0 2011-02-16 09:37 mail_backup 
    5. drwxrwxrwx 1 root root    0 2011-02-16 09:30 system_backup 
    6. root@localhost:~# mount 
    7. ...
    8. //192.168.1.1/backup on /misc/backup type cifs (rw,mand) 

    值得注意的是如果通过AD域来认证,则要在用户名后加@domain(domain是AD域的域名,如company.com)才能成功挂载,尝试过用户名的另一种表示方法,domainusername,但不是每一次都能成功,所以选择前者。虽然挂载选项显示可读写,但要在远端服务器上设置相应的权限才能操作

  • 相关阅读:
    折腾了好久的输入法显示已禁用
    文件下载上传小工具
    隐藏进程命令行参数,例如输入密码等高危操作
    创建并使用https证书
    编译lua可执行程序
    使用msys2在window下构建和使用Linux的软件
    golang遍历时修改被遍历对象
    使用shell发送邮件,方便快捷
    关于golang的time包总结
    获取Win和Linux系统启动时间,类似uptime功能,用于判断是否修改过系统时间
  • 原文地址:https://www.cnblogs.com/smlie/p/10829230.html
Copyright © 2011-2022 走看看