Autofs automatic mounting

Source: Internet
Author: User
Autofs: The Automatic mounting tool is a daemon process that monitors directories. when the target subdirectory is referenced, automatic execution of pre-defined NFS mounting automatic mounts managed by autofs service scripts automatic mounts by auto. configure the master configuration file, which references a convention called... autofs: Automatic mounting device
The automatic mount device is a daemon that monitors directories. when the target subdirectory is referenced, it automatically performs a predefined NFS mount.
The automatic mount device is managed by the autofs service script.
The auto mount device is configured in the auto. master configuration file, which references a level-2 configuration file named/etc/auto. misc or similar by convention.
Autofs and NFS are usually used after configuration.
 
The mount command has many parameters. The following are NFS-related parameters.
(1)-a: Mount all the paths listed in/etc/fstab.
(2)-t: specifies the mount type, such as nfs.
(3)-r: Set the mount path to read only.
(4)-v mount: each operation in the process has a message sent back to the screen.
(5) rsize = n: the number of bytes used by NFS when the NFS server reads files. the default value is 1 024 bytes.
(6) wsize = n: Number of bytes used by NFS to write files to the NFS server. the default value is 1 024 bytes.
(7) timeo = n: the number of 1st seconds from the timeout period to the 1/7 re-transfer. the default value is 7/7 seconds.
(8) retry = n: number of times that can be tried before the backend mount operation is abandoned. the default value is.
(9) soft: The system is mounted in soft mounting mode. if the Client request does not receive a response, the system will send a new request and return an error message.
(10) hard: Mount the system by means of hard mounting. this value is the default value. repeat the request until the NFS server responds.
(11) intr: allows NFS to interrupt file operations and return values to programs that call it. By default, file operations are not allowed to be interrupted.
(12) fg: repeat mounting at the prompt.
(13) bg: If the file system fails to be mounted for 1st times, continue to try mounting in the background. the default value is not processed in the background after the failure.
(14) tcp: Mount the file system using TCP instead of the default UDP.
Note: another important parameter for mounting NFS servers is hard mount or soft mount.
 
With hard mount, NFS customers constantly try to connect to the NFS server (no prompt is provided in the background) until it is mounted.
When soft mount is used, the system tries to connect to the NFS server on the foreground. When an error message is received, the system terminates the mount attempt and provides related information.
 
###################### Simple configuration ################ ###########
1. Mount local partitions
In RHEL5.5, the autofs software package is installed by default.
[Root @ kumu ~] # Rpm-qa autofs
Autofs-5.0.1-0.rc2.143.el5
[Root @ kumu ~] #
 
[Root @ kumu ~] # Grep-v '^ #'/etc/auto. master
/Misc/etc/auto. misc
# Misc is the magic directory, and auto. master defines the Magic Directory as misc auto. misc is the configuration file automatically mounted.
/Net-hosts
+ Auto. master
[Root @ kumu ~] # Grep-v '^ #'/etc/auto. misc
 
Cd-fstype = iso9660, ro, nosuid, nodev:/dev/cdrom
# If cd is the middle segment of the target directory name, it is the mount option and the last is the Mount directory.
[Root @ kumu ~] #
 
[Root @ kumu misc] # ls
[Root @ kumu misc] # grep sda4/etc/auto. master
/Misc/sda4/etc/auto. sda -- timeout = 60
[Root @ kumu misc] # grep sda4/etc/auto. sda
Sda4-fstype = ext3:/dev/sda4
[Root @ kumu misc] # service autofs start // start the service
Start automount: [OK]
[Root @ kumu misc] # ls // The Magic Directory appears automatically
Sda4
[Root @ kumu misc] # cd sda4/
[Root @ kumu sda4] # ls // There is nothing after it enters
[Root @ kumu sda4] # cd sda4 // directly cd sda4. it's amazing to go in.
[Root @ kumu sda4] # pwd
/Misc/sda4/sda4
[Root @ kumu sda4] # ls
Lost + found
[Root @ kumu sda4] # mount | grep sda4 // mount
/Dev/sda4 on/misc/sda4/sda4 type ext3 (rw)
[Root @ kumu sda4] #
 
 
2. mount the NFS shared directory
[Root @ kumu ~] # Cat/etc/exports
/Tmp 192.168.0.0/24 (rw)
[Root @ kumu ~] # Service nfs restart
Disable NFS mountd: [failed]
Disable the NFS daemon: [failed]
Disable NFS quotas: [failed]
Disable NFS: [failed]
Start the NFS service: [OK]
Disable NFS quota: [OK]
Start the NFS daemon: [OK]
Start NFS mountd: [OK]
[Root @ kumu ~] # Showmount-e 127.0.0.1
Export list for 127.0.0.1:
/Tmp 192.168.0.0/24
[Root @ kumu ~] # Vi/etc/auto. master
[Root @ kumu ~] # Grep tmp/etc/auto. master
/Misc/tmp/etc/auto. nfs
[Root @ kumu ~] # Vi/etc/auto. nfs
[Root @ kumu tmp] # grep tmp/etc/auto. nfs
Tmp-typefs = nfs, rw 127.0.0.1:/tmp
# Here is a local test. for remote test, change the IP address to the remote NFS server.
[Root @ kumu ~] # Service autofs restart
Stop automount: [OK]
Start automount: [OK]
[Root @ kumu ~] # Cd/misc/tmp
[Root @ kumu tmp] # ls
Gconfd-root scim-panel-socket: 0-root whatis. Qs3891
Mapping-root setuplog.txt
[Root @ kumu tmp] #
 
3. Mount samba
Mounting samba is not demonstrated here. in addition to adding similar statements in auto. master, create an auto. smb file and fill in:
Windows-fstype = smbfs, username = admin % password: // hostname/login folder
You can.
 
4. Mount a local image
[Root @ kumu ~] # Grep iso/etc/auto. master
/Misc/iso/etc/auto. iso
[Root @ kumu ~] # Cat/etc/auto. iso
Iso-fstype = iso9660, ro, nosuid, nodev, loop:/root/rhel5u5. iso
[Root @ kumu ~] # Service autofs restart
Stop automount: [OK]
Start automount: [OK]
[Root @ kumu ~] # Cd/misc/
[Root @ kumu misc] # ls
Iso
[Root @ kumu misc] # cd iso/
[Root @ kumu iso] # ls
[Root @ kumu iso] # cd iso
[Root @ kumu iso] # ls
Cluster README-te.html RELEASE-NOTES-U5-en
ClusterStorage README-zh_CN.html RELEASE-NOTES-U5-en.html
EULA README-zh_TW.html RELEASE-NOTES-U5-es.html
Eula. en_US RELEASE-NOTES-as.html RELEASE-NOTES-U5-fr.html
GPL RELEASE-NOTES-bn.html RELEASE-NOTES-U5-gu.html
------ Omitted ------
[Root @ kumu iso] # mount | grep rhel5u5. iso
/Root/rhel5u5. iso on/misc/iso type iso9660 (ro, nosuid, nodev, loop =/dev/loop1)
[Root @ kumu iso] #
 
In this way, autofs can be used with yum to install software. if it is not installed, it will not be mounted. when the software is installed, it will be automatically mounted.
[Root @ kumu mnt] # tail-5/etc/yum. repos. d/rhel-debuginfo.repo
[Repo]
Name = repo
Baseurl = file: // misc/iso/Server
Enabled = 1
Gpgcheck = 0
[Root @ kumu mnt] # yum clean all
Loaded plugins: rhnplugin, security
Cleaning up Everything
[Root @ kumu mnt] # yum list
Loaded plugins: rhnplugin, security
This system is not registered with RHN.
RHN support will be disabled.
Repo | 1.3 kB: 00
Repo/primary | 753 kB: 00
Repo 2348/2348
------ Omitted ------
 
 
#####################################
 
This article is from the "dry wood Linux Blog" blog
Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.