{"id":214009,"date":"2021-03-26T10:02:31","date_gmt":"2021-03-26T02:02:31","guid":{"rendered":"https:\/\/gulass.cn\/?p=214009"},"modified":"2021-03-22T10:03:08","modified_gmt":"2021-03-22T02:03:08","slug":"linux-autofs","status":"publish","type":"post","link":"https:\/\/gulass.cn\/linux-autofs.html","title":{"rendered":"Linux\u7cfb\u7edf\u5982\u4f55\u5b89\u88c5AutoFs\u6302\u8f7d\u670d\u52a1"},"content":{"rendered":"\n\n\n
\u5bfc\u8bfb<\/td>\n\u65e0\u8bba\u662fSamba\u670d\u52a1\u8fd8\u662fNFS\u670d\u52a1\uff0c\u90fd\u8981\u628a\u6302\u8f7d\u4fe1\u606f\u5199\u5165\u5230\/etc\/fstab\u4e2d\uff0c\u8fd9\u6837\u8fdc\u7a0b\u5171\u4eab\u8d44\u6e90\u5c31\u4f1a\u81ea\u52a8\u968f\u670d\u52a1\u5668\u5f00\u673a\u800c\u8fdb\u884c\u6302\u8f7d\u3002<\/strong><\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n

\"\"<\/p>\n

\r\n[root@localhost ~]# yum install autofs  \r\nLoaded plugins: langpacks, product-id, subscription-manager  \r\n......  \r\nRunning transaction  \r\nInstalling : hesiod-3.2.1-3.el7.x86_64 1\/2  \r\nInstalling : 1:autofs-5.0.7-40.el7.x86_64 2\/2  \r\nVerifying : hesiod-3.2.1-3.el7.x86_64 1\/2  \r\nVerifying : 1:autofs-5.0.7-40.el7.x86_64 2\/2  \r\nInstalled:  \r\nautofs.x86_64 1:5.0.7-40.el7  \r\nDependency Installed:  \r\nhesiod.x86_64 0:3.2.1-3.el7  \r\nComplete! \r\n<\/pre>\n

\u5904\u4e8e\u751f\u4ea7\u73af\u5883\u4e2d\u7684Linux\u670d\u52a1\u5668\uff0c\u4e00\u822c\u4f1a\u540c\u65f6\u7ba1\u7406\u8bb8\u591a\u8bbe\u5907\u7684\u6302\u8f7d\u64cd\u4f5c\u3002\u5982\u679c\u628a\u8fd9\u4e9b\u8bbe\u5907\u6302\u8f7d\u4fe1\u606f\u90fd\u5199\u5165\u5230autofs\u670d\u52a1\u7684\u4e3b\u914d\u7f6e\u6587\u4ef6\u4e2d\uff0c\u65e0\u7591\u4f1a\u8ba9\u4e3b\u914d\u7f6e\u6587\u4ef6\u81c3\u80bf\u4e0d\u582a\uff0c\u4e0d\u5229\u4e8e\u670d\u52a1\u6267\u884c\u6548\u7387\uff0c\u4e5f\u4e0d\u5229\u4e8e\u65e5\u540e\u4fee\u6539\u91cc\u9762\u7684\u914d\u7f6e\u5185\u5bb9\uff0c\u56e0\u6b64\u5728 autofs \u670d\u52a1\u7a0b\u5e8f\u7684\u4e3b\u914d\u7f6e\u6587\u4ef6\u4e2d\u9700\u8981\u6309\u7167\u201c\u6302\u8f7d\u76ee\u5f55 \u5b50\u914d\u7f6e\u6587\u4ef6\u201d\u7684\u683c\u5f0f\u8fdb\u884c\u586b\u5199\u3002\u6302\u8f7d\u76ee\u5f55\u662f\u8bbe\u5907\u6302\u8f7d\u4f4d\u7f6e\u7684\u4e0a\u4e00\u7ea7\u76ee\u5f55\u3002<\/p>\n

\u4f8b\u5982\uff0c\u5149\u76d8\u8bbe\u5907\u4e00\u822c\u6302\u8f7d\u5230\/media\/cdrom\u76ee\u5f55\u4e2d\uff0c\u90a3\u4e48\u6302\u8f7d\u76ee\u5f55\u5199\u6210\/media\u5373\u53ef\u3002\u5bf9\u5e94\u7684\u5b50\u914d\u7f6e\u6587\u4ef6\u5219\u662f\u5bf9\u8fd9\u4e2a\u6302\u8f7d\u76ee\u5f55\u5185\u7684\u6302\u8f7d\u8bbe\u5907\u4fe1\u606f\u4f5c\u8fdb\u4e00\u6b65\u7684\u8bf4\u660e\u3002\u5b50\u914d\u7f6e\u6587\u4ef6\u9700\u8981\u7528\u6237\u81ea\u884c\u5b9a\u4e49\uff0c\u6587\u4ef6\u540d\u5b57\u6ca1\u6709\u4e25\u683c\u8981\u6c42\uff0c\u4f46\u540e\u7f00\u5fc5\u987b\u4ee5.misc\u7ed3\u675f\u3002\u5177\u4f53\u7684\u914d\u7f6e\u53c2\u6570\u5982\u7b2c7\u884c\u7684\u52a0\u7c97\u5b57\u6240\u793a\u3002<\/p>\n

\r\n[root@localhost ~]# vim \/etc\/auto.master  \r\n#  \r\n# Sample auto.master file  \r\n# This is an automounter map and it has the following format  \r\n# key [ -mount-options-separated-by-comma ] location  \r\n# For details of the format look at autofs(5).  \r\n\/media \/etc\/iso.misc  \r\n\/misc \/etc\/auto.misc  \r\n#  \r\n# NOTE: mounts done from a hosts map will be mounted with the  \r\n# \"nosuid\" and \"nodev\" options unless the \"suid\" and \"dev\"  \r\n# options are explicitly given.  \r\n\/net -hosts  \r\n#  \r\n# Include \/etc\/auto.master.d\/*.autofs  \r\n+dir:\/etc\/auto.master.d  \r\n#  \r\n# Include central master map if it can be found using  \r\n# nsswitch sources.  \r\n#  \r\n# Note that if there are entries for \/net or \/misc (as  \r\n# above) in the included master map any keys that are the  \r\n# same will not be seen as the first read key seen takes  \r\n# precedence.  \r\n+auto.master \r\n<\/pre>\n

\u5728\u5b50\u914d\u7f6e\u6587\u4ef6\u4e2d\uff0c\u5e94\u6309\u7167\u201c\u6302\u8f7d\u76ee\u5f55 \u6302\u8f7d\u6587\u4ef6\u7c7b\u578b\u53ca\u6743\u9650 :\u8bbe\u5907\u540d\u79f0\u201d\u7684\u683c\u5f0f\u8fdb\u884c\u586b\u5199\u3002\u4f8b\u5982\uff0c\u8981\u628a\u5149\u76d8\u8bbe\u5907\u6302\u8f7d\u5230\/media\/iso\u76ee\u5f55\u4e2d\uff0c\u53ef\u5c06\u6302\u8f7d\u76ee\u5f55\u5199\u4e3aiso\uff0c\u800c-fstype\u4e3a\u6587\u4ef6\u7cfb\u7edf\u683c\u5f0f\u53c2\u6570\uff0ciso9660\u4e3a\u5149\u76d8\u8bbe\u5907\u683c\u5f0f\uff0cro\u3001nosuid\u53canodev\u4e3a\u5149\u76d8\u8bbe\u5907\u5177\u4f53\u7684\u6743\u9650\u53c2\u6570\uff0c\/dev\/cdrom\u5219\u662f\u5b9a\u4e49\u8981\u6302\u8f7d\u7684\u8bbe\u5907\u540d\u79f0\u3002\u914d\u7f6e\u5b8c\u6210\u540e\u518d\u987a\u624b\u5c06autofs\u670d\u52a1\u7a0b\u5e8f\u542f\u52a8\u5e76\u52a0\u5165\u5230\u7cfb\u7edf\u542f\u52a8\u9879\u4e2d\uff1a<\/p>\n

\r\n[root@localhost ~]# vim \/etc\/iso.misc  \r\niso   -fstype=iso9660,ro,nosuid,nodev :\/dev\/cdrom  \r\n[root@localhost ~]# systemctl start autofs  \r\n[root@localhost ~]# systemctl enable autofs  \r\nln -s '\/usr\/lib\/systemd\/system\/autofs.service' '\/etc\/systemd\/system\/multi-user.target.wants\/autofs.service' \r\n<\/pre>\n

\u63a5\u4e0b\u6765\u5c06\u53d1\u751f\u4e00\u4ef6\u975e\u5e38\u6709\u8da3\u7684\u4e8b\u60c5\u3002\u6211\u4eec\u5148\u67e5\u770b\u5f53\u524d\u7684\u5149\u76d8\u8bbe\u5907\u6302\u8f7d\u60c5\u51b5\uff0c\u786e\u8ba4\u5149\u76d8\u8bbe\u5907\u6ca1\u6709\u88ab\u6302\u8f7d\u4e0a\uff0c\u800c\u4e14\/media\u76ee\u5f55\u4e2d\u6839\u672c\u5c31\u6ca1\u6709iso\u5b50\u76ee\u5f55\u3002\u4f46\u662f\uff0c\u6211\u4eec\u5374\u53ef\u4ee5\u4f7f\u7528cd\u547d\u4ee4\u5207\u6362\u5230\u8fd9\u4e2aiso\u5b50\u76ee\u5f55\u4e2d\uff0c\u800c\u4e14\u5149\u76d8\u8bbe\u5907\u4f1a\u88ab\u7acb\u5373\u81ea\u52a8\u6302\u8f7d\u4e0a\u3002\u6211\u4eec\u4e5f\u5c31\u80fd\u987a\u5229\u67e5\u770b\u5149\u76d8\u5185\u7684\u5185\u5bb9\u4e86\u3002<\/p>\n

\r\n[root@localhost ~]# df -h  \r\nFilesystem Size Used Avail Use% Mounted on  \r\n\/dev\/mapper\/rhel-root 18G 3.0G 15G 17% \/  \r\ndevtmpfs 905M 0 905M 0% \/dev  \r\ntmpfs 914M 140K 914M 1% \/dev\/shm  \r\ntmpfs 914M 8.9M 905M 1% \/run  \r\ntmpfs 914M 0 914M 0% \/sys\/fs\/cgroup  \r\n\/dev\/sda1 497M 119M 379M 24% \/boot \r\n[root@linuxprobe ~]# cd \/media  \r\n[root@localhost media]# ls  \r\n[root@localhost media]# cd iso  \r\n[root@localhost iso]# ls -l  \r\ntotal 812  \r\ndr-xr-xr-x. 4 root root 2048 May 7 2017 addons  \r\ndr-xr-xr-x. 3 root root 2048 May 7 2017 EFI  \r\n-r--r--r--. 1 root root 8266 Apr 4 2017 EULA  \r\n-r--r--r--. 1 root root 18092 Mar 6 2012 GPL  \r\ndr-xr-xr-x. 3 root root 2048 May 7 2017 images  \r\ndr-xr-xr-x. 2 root root 2048 May 7 2017 isolinux \r\ndr-xr-xr-x. 2 root root 2048 May 7 2017 LiveOS  \r\n-r--r--r--. 1 root root 108 May 7 2017 media.repo  \r\ndr-xr-xr-x. 2 root root 774144 May 7 2017 Packages  \r\ndr-xr-xr-x. 24 root root 6144 May 7 2017 release-notes  \r\ndr-xr-xr-x. 2 root root 4096 May 7 2017 repodata  \r\n-r--r--r--. 1 root root 3375 Apr 1 2017 RPM-GPG-KEY-redhat-beta  \r\n-r--r--r--. 1 root root 3211 Apr 1 2017 RPM-GPG-KEY-redhat-release  \r\n-r--r--r--. 1 root root 1568 May 7 2017 TRANS.TBL  \r\n<\/pre>\n
\r\n[root@localhost ~]# df -h  \r\nFilesystem Size Used Avail Use% Mounted on  \r\n\/dev\/mapper\/rhel-root 18G 3.0G 15G 17% \/  \r\ndevtmpfs 905M 0 905M 0% \/dev  \r\ntmpfs 914M 140K 914M 1% \/dev\/shm  \r\ntmpfs 914M 8.9M 905M 1% \/run  \r\ntmpfs 914M 0 914M 0% \/sys\/fs\/cgroup  \r\n\/dev\/cdrom 3.5G 3.5G 0 100% \/media\/iso \r\n\/dev\/sda1 497M 119M 379M 24% \/boot  \r\n<\/pre>\n","protected":false},"excerpt":{"rendered":"

[root@localhost ~]# yum install autofs Loaded plugins: […]<\/p>\n","protected":false},"author":370,"featured_media":87408,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"_acf_changed":false,"footnotes":""},"categories":[55],"tags":[],"class_list":["post-214009","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-thread"],"acf":[],"_links":{"self":[{"href":"https:\/\/gulass.cn\/wp-json\/wp\/v2\/posts\/214009","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/gulass.cn\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/gulass.cn\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/gulass.cn\/wp-json\/wp\/v2\/users\/370"}],"replies":[{"embeddable":true,"href":"https:\/\/gulass.cn\/wp-json\/wp\/v2\/comments?post=214009"}],"version-history":[{"count":2,"href":"https:\/\/gulass.cn\/wp-json\/wp\/v2\/posts\/214009\/revisions"}],"predecessor-version":[{"id":214012,"href":"https:\/\/gulass.cn\/wp-json\/wp\/v2\/posts\/214009\/revisions\/214012"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/gulass.cn\/wp-json\/wp\/v2\/media\/87408"}],"wp:attachment":[{"href":"https:\/\/gulass.cn\/wp-json\/wp\/v2\/media?parent=214009"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/gulass.cn\/wp-json\/wp\/v2\/categories?post=214009"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/gulass.cn\/wp-json\/wp\/v2\/tags?post=214009"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}