自拍偷在线精品自拍偷,亚洲欧美中文日韩v在线观看不卡

Linux系統(tǒng)安裝AutoFs掛載服務(wù)

系統(tǒng) Linux
無論是Samba服務(wù)還是NFS服務(wù),都要把掛載信息寫入到/etc/fstab中,這樣遠(yuǎn)程共享資源就會自動隨服務(wù)器開機而進(jìn)行掛載。

 無論是Samba服務(wù)還是NFS服務(wù),都要把掛載信息寫入到/etc/fstab中,這樣遠(yuǎn)程共享資源就會自動隨服務(wù)器開機而進(jìn)行掛載。雖然這很方便,但是如果掛載的遠(yuǎn)程資源太多,則會給網(wǎng)絡(luò)帶寬和服務(wù)器的硬件資源帶來很大負(fù)載。如果在資源掛載后長期不使用,也會造成服務(wù)器硬件資源的浪費。

可能會有讀者說,可以在每次使用之前執(zhí)行mount命令進(jìn)行手動掛載。這是一個不錯的選擇,但是每次都需要先掛載再使用,您不覺得麻煩嗎?

autofs自動掛載服務(wù)可以幫我們解決這一問題。與mount命令不同,autofs服務(wù)程序是一種Linux系統(tǒng)守護進(jìn)程,當(dāng)檢測到用戶試圖訪問一個尚未掛載的文件系統(tǒng)時,將自動掛載該文件系統(tǒng)。

換句話說,我們將掛載信息填入/etc/fstab文件后,系統(tǒng)在每次開機時都自動將其掛載,而autofs服務(wù)程序則是在用戶需要使用該文件系統(tǒng)時才去動態(tài)掛載,從而節(jié)約了網(wǎng)絡(luò)資源和服務(wù)器的硬件資源。 

  1. [root@localhost ~]# yum install autofs  
  2. Loaded plugins: langpacks, product-id, subscription-manager  
  3. ......  
  4. Running transaction  
  5. Installing : hesiod-3.2.1-3.el7.x86_64 1/2  
  6. Installing : 1:autofs-5.0.7-40.el7.x86_64 2/2  
  7. Verifying : hesiod-3.2.1-3.el7.x86_64 1/2  
  8. Verifying : 1:autofs-5.0.7-40.el7.x86_64 2/2  
  9. Installed:  
  10. autofs.x86_64 1:5.0.7-40.el7  
  11. Dependency Installed:  
  12. hesiod.x86_64 0:3.2.1-3.el7  
  13. Complete! 

處于生產(chǎn)環(huán)境中的Linux服務(wù)器,一般會同時管理許多設(shè)備的掛載操作。如果把這些設(shè)備掛載信息都寫入到autofs服務(wù)的主配置文件中,無疑會讓主配置文件臃腫不堪,不利于服務(wù)執(zhí)行效率,也不利于日后修改里面的配置內(nèi)容,因此在 autofs 服務(wù)程序的主配置文件中需要按照“掛載目錄 子配置文件”的格式進(jìn)行填寫。掛載目錄是設(shè)備掛載位置的上一級目錄。

例如,光盤設(shè)備一般掛載到/media/cdrom目錄中,那么掛載目錄寫成/media即可。對應(yīng)的子配置文件則是對這個掛載目錄內(nèi)的掛載設(shè)備信息作進(jìn)一步的說明。子配置文件需要用戶自行定義,文件名字沒有嚴(yán)格要求,但后綴必須以.misc結(jié)束。具體的配置參數(shù)如第7行的加粗字所示。 

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

在子配置文件中,應(yīng)按照“掛載目錄 掛載文件類型及權(quán)限 :設(shè)備名稱”的格式進(jìn)行填寫。例如,要把光盤設(shè)備掛載到/media/iso目錄中,可將掛載目錄寫為iso,而-fstype為文件系統(tǒng)格式參數(shù),iso9660為光盤設(shè)備格式,ro、nosuid及nodev為光盤設(shè)備具體的權(quán)限參數(shù),/dev/cdrom則是定義要掛載的設(shè)備名稱。配置完成后再順手將autofs服務(wù)程序啟動并加入到系統(tǒng)啟動項中: 

  1. [root@localhost ~]# vim /etc/iso.misc  
  2. iso   -fstype=iso9660,ro,nosuid,nodev :/dev/cdrom  
  3. [root@localhost ~]# systemctl start autofs  
  4. [root@localhost ~]# systemctl enable autofs  
  5. ln -s '/usr/lib/systemd/system/autofs.service' '/etc/systemd/system/multi-user.target.wants/autofs.service' 

接下來將發(fā)生一件非常有趣的事情。我們先查看當(dāng)前的光盤設(shè)備掛載情況,確認(rèn)光盤設(shè)備沒有被掛載上,而且/media目錄中根本就沒有iso子目錄。但是,我們卻可以使用cd命令切換到這個iso子目錄中,而且光盤設(shè)備會被立即自動掛載上。我們也就能順利查看光盤內(nèi)的內(nèi)容了。 

  1. [root@localhost ~]# df -h  
  2. Filesystem Size Used Avail Use% Mounted on  
  3. /dev/mapper/rhel-root 18G 3.0G 15G 17% /  
  4. devtmpfs 905M 0 905M 0% /dev  
  5. tmpfs 914M 140K 914M 1% /dev/shm  
  6. tmpfs 914M 8.9M 905M 1% /run  
  7. tmpfs 914M 0 914M 0% /sys/fs/cgroup  
  8. /dev/sda1 497M 119M 379M 24% /boot 
  9. [root@linuxprobe ~]# cd /media  
  10. [root@localhost media]# ls  
  11. [root@localhost media]# cd iso  
  12. [root@localhost iso]# ls -l  
  13. total 812  
  14. dr-xr-xr-x. 4 root root 2048 May 7 2017 addons  
  15. dr-xr-xr-x. 3 root root 2048 May 7 2017 EFI  
  16. -r--r--r--. 1 root root 8266 Apr 4 2017 EULA  
  17. -r--r--r--. 1 root root 18092 Mar 6 2012 GPL  
  18. dr-xr-xr-x. 3 root root 2048 May 7 2017 images  
  19. dr-xr-xr-x. 2 root root 2048 May 7 2017 isolinux 
  20. dr-xr-xr-x. 2 root root 2048 May 7 2017 LiveOS  
  21. -r--r--r--. 1 root root 108 May 7 2017 media.repo  
  22. dr-xr-xr-x. 2 root root 774144 May 7 2017 Packages  
  23. dr-xr-xr-x. 24 root root 6144 May 7 2017 release-notes  
  24. dr-xr-xr-x. 2 root root 4096 May 7 2017 repodata  
  25. -r--r--r--. 1 root root 3375 Apr 1 2017 RPM-GPG-KEY-redhat-beta  
  26. -r--r--r--. 1 root root 3211 Apr 1 2017 RPM-GPG-KEY-redhat-release  
  27. -r--r--r--. 1 root root 1568 May 7 2017 TRANS.TBL  
  1. [root@localhost ~]# df -h  
  2. Filesystem Size Used Avail Use% Mounted on  
  3. /dev/mapper/rhel-root 18G 3.0G 15G 17% /  
  4. devtmpfs 905M 0 905M 0% /dev  
  5. tmpfs 914M 140K 914M 1% /dev/shm  
  6. tmpfs 914M 8.9M 905M 1% /run  
  7. tmpfs 914M 0 914M 0% /sys/fs/cgroup  
  8. /dev/cdrom 3.5G 3.5G 0 100% /media/iso 
  9. /dev/sda1 497M 119M 379M 24% /boot  

 

責(zé)任編輯:龐桂玉 來源: 良許Linux
相關(guān)推薦

2019-05-08 13:18:22

Linux網(wǎng)絡(luò)文件系統(tǒng)系統(tǒng)運維

2010-02-24 15:56:48

Linux系統(tǒng)

2020-03-26 22:12:49

Linux系統(tǒng)服務(wù)器

2021-03-29 10:29:09

LinuxdockerLinux系統(tǒng)

2009-09-08 15:06:45

NFS服務(wù)器

2024-11-29 14:59:16

Linux掛載硬盤

2024-01-04 17:03:43

Linux操作系統(tǒng)硬盤

2018-07-05 10:27:05

Linux系統(tǒng)數(shù)據(jù)盤

2009-12-17 17:19:45

Linux系統(tǒng)

2010-11-09 13:53:33

2009-12-02 15:46:36

Linux系統(tǒng)掛接

2023-09-27 23:19:04

Linuxmount

2010-02-04 09:57:06

Linux mount

2011-08-18 15:21:37

autofs中文man

2011-08-23 10:08:25

automount中文man

2015-05-29 13:22:10

Linux掛載運維

2009-12-17 17:41:52

2014-08-04 11:22:21

linuxsamba服務(wù)器

2010-03-02 15:09:26

Linux mount

2010-03-15 16:30:53

Ubuntu Linu
點贊
收藏

51CTO技術(shù)棧公眾號