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)才能成功掛載,嘗試過用戶名的另一種表示方法,domain\username,但不是每一次都能成功,所以選擇前者。雖然掛載選項顯示可讀寫,但要在遠端服務器上設置相應的權限才能操作

 


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM