In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-17 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >
Share
Shulou(Shulou.com)06/01 Report--
This article mainly introduces the relevant knowledge of "how to install autofs automatic mount service in Linux". The editor shows you the operation process through an actual case. The method of operation is simple and fast, and it is practical. I hope this article "how to install autofs automatic mount service in Linux" can help you solve the problem.
The autofs auto-mount service is a Linux system daemon that automatically mounts a file system that is not yet mounted by a user view when it is detected. To put it simply, when the mount information is written into the / etc/fstab file, the system will be mounted automatically every time it boots, while the autofs service will mount dynamically when the user needs to use the file system, thus saving the cost of network resources and server hardware resources.
[root@localhost] # yum install autofs Loaded plugins: langpacks, product-id, subscription-manager. Running transaction Installing: hesiod-3.2.1-3.el7.x86_64 1 Installing: 1:autofs-5.0.7-40.el7.x86_64 2 Verifying: hesiod-3.2.1-3.el7.x86_64 1 Verifying: 1:autofs-5.0.7-40.el7.x86_64 2 Installed: autofs.x86_64 1 40.el7.x86_64 5.0.7-40.el7 Dependency Installed: hesiod.x86_64 0 40.el7.x86_64 3.2.1-3.el7 Complete!
Linux servers in a production environment generally manage the mount operations of many devices at the same time. If you write all these device mount information into the main configuration file of the autofs service, it will undoubtedly make the main configuration file bloated, which is not conducive to the efficiency of service execution, and is not conducive to modifying the configuration contents in the future, so the main configuration file of the autofs service program needs to be filled in according to the format of "mount directory subconfiguration file". The mount directory is the directory one level above where the device is mounted.
For example, CD-ROM devices are generally mounted to the / media/cdrom directory, so the mount directory can be written as / media. The corresponding sub-configuration file is a further explanation of the mount device information in this mount directory. The subprofile needs to be defined by the user, and the file name is not strictly required, but the suffix must end with .misc. The specific configuration parameters are shown in bold on line 7.
[root@localhost] # vim / etc/auto.master # # Sample auto.master file # This is an automounter map and it has the following format # key [- mount-options-separated-by-comma] location # For details of the format look at autofs (5). / media / etc/iso.misc / misc / etc/auto.misc # # NOTE: mounts done from a hosts map will be mounted with the # "nosuid" and "nodev" options unless the "suid" and "dev" # options are explicitly given / net-hosts # # Include / etc/auto.master.d/*.autofs + dir:/etc/auto.master.d # # Include central master map if it can be found using # nsswitch sources. # # Note that if there are entries for / net or / misc (as # above) in the included master map any keys that are the # same will not be seen as the first read key seen takes # precedence. + auto.master
In the subconfiguration file, you should fill in the format "Mount directory mount file type and permissions: device name". For example, to mount a CD device to the / media/iso directory, the mount directory can be written as iso, and-fstype is the file system format parameter, iso9660 is the CD device format, ro, nosuid and nodev are the specific permission parameters of the CD device, and / dev/cdrom is the name of the device to be mounted. After the configuration is completed, start the autofs service program and add it to the system startup item:
[root@localhost ~] # vim / etc/iso.misc iso-fstype=iso9660,ro,nosuid,nodev: / dev/cdrom [root@localhost ~] # systemctl start autofs [root@localhost ~] # systemctl enable autofs ln-s'/ usr/lib/systemd/system/autofs.service''/ etc/systemd/system/multi-user.target.wants/autofs.service'
A very interesting thing is going to happen next. Let's first check the current mount of the CD device to make sure that the CD device is not mounted and that there is no isosubdirectory in the / media directory. However, we can use the cd command to switch to this iso subdirectory, and the CD device will be automatically mounted immediately. We will be able to view the contents of the CD smoothly.
[root@localhost ~] # df-h Filesystem Size Used Avail Use% Mounted on / dev/mapper/rhel-root 18G 3.0G 15G 17% / devtmpfs 905M 0905M 0% / devtmpfs 914M 140K 914M 1% / dev/shm tmpfs 914M 8.9M 1% / run tmpfs 914M 0914M 0% / sys/fs/cgroup / dev/sda1 497M 119m 379M 24% / boot [root@linuxprobe ~] # cd / media [root@localhost media] # ls [root@localhost media] # cd iso [root@localhost iso] # ls-l total 812 dr-xr-xr-x. 4 root root 2048 May 7 2017 addons dr-xr-xr-x. 3 root root 2048 May 7 2017 EFI-Rmuri. 1 root root 8266 Apr 4 2017 EULA-Rmuri. 1 root root 18092 Mar 6 2012 GPL dr-xr-xr-x. 3 root root 2048 May 7 2017 images dr-xr-xr-x. 2 root root 2048 May 7 2017 isolinuxdr-xr-xr-x. 2 root root 2048 May 7 2017 LiveOS-Rmuri. 1 root root 108 May 7 2017 media.repo dr-xr-xr-x. 2 root root 774144 May 7 2017 Packages dr-xr-xr-x. 24 root root 6144 May 7 2017 release-notes dr-xr-xr-x. 2 root root 4096 May 7 2017 repodata-Rmuri. 1 root root 3375 Apr 1 2017 RPM-GPG-KEY-redhat-beta-Rmuri. 1 root root 3211 Apr 1 2017 RPM-GPG-KEY-redhat-release-Rmuri. 1 root root 1568 May 7 2017 TRANS.TBL [root@localhost ~] # df-h Filesystem Size Used Avail Use% Mounted on / dev/mapper/rhel-root 18G 3.0G 15G 17% / devtmpfs 905M 0905M 0% / devtmpfs 914M 140K 914M 1% / dev/shm tmpfs 914M 8.9M 1% / run tmpfs 914M 0914M 0% / sys/fs/cgroup / dev/cdrom 3.5G 3.5G 0100% / media/iso/dev/sda1 497M 119M 379M 24% / boot, this is the end of the introduction to "how to install the autofs auto-mount service in Linux". Thank you for your reading. If you want to know more about the industry, you can follow the industry information channel. The editor will update different knowledge points for you every day.
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.