Autofs: Difference between revisions
No edit summary |
m Text replacement - "<code>" to "{{code|" |
||
| Line 1: | Line 1: | ||
{{code|autofs</code> is the linux automounter. It's a daemon that automatically mounts filesystems as they are accessed on demand. | |||
== Configuration == | == Configuration == | ||
The primary configuration file used by automount is | The primary configuration file used by automount is {{code|/etc/auto.master</code> which defines what mounts automount is responsible for. | ||
<syntaxhighlight lang="bash" line start="1" enclose="div"> | <syntaxhighlight lang="bash" line start="1" enclose="div"> | ||
| Line 13: | Line 13: | ||
</syntaxhighlight> | </syntaxhighlight> | ||
In the example above, automount is responsible for mounting directories under /home and the configuration for it is under | In the example above, automount is responsible for mounting directories under /home and the configuration for it is under {{code|/etc/auto.home</code>. The configuration under {{code|/etc/auto.home</code> will define directories in {{code|/home</code> and their corresponding mount locations. | ||
<syntaxhighlight lang="bash" line start="1" enclose="div"> | <syntaxhighlight lang="bash" line start="1" enclose="div"> | ||
| Line 22: | Line 22: | ||
</syntaxhighlight> | </syntaxhighlight> | ||
Anyone going to | Anyone going to {{code|/home/leo</code> will cause automount to mount {{code|/home/leo</code> from {{code|file1:/export/home/leo</code>. | ||
You may specify mount options by placing them before the mount location: | You may specify mount options by placing them before the mount location: | ||
| Line 35: | Line 35: | ||
== Dynamic Automount Rules == | == Dynamic Automount Rules == | ||
The automount configuration can be made as a script to make mounting more intelligent. automount will pass in the mounting point to your | The automount configuration can be made as a script to make mounting more intelligent. automount will pass in the mounting point to your {{code|auto</code> mount configuration. | ||
For example, if home directories are stored on multiple file servers, we can make | For example, if home directories are stored on multiple file servers, we can make {{code|/home</code> the mounting point for ''all'' users by doing something like so: | ||
<syntaxhighlight lang="bash" line start="1" enclose="div"> | <syntaxhighlight lang="bash" line start="1" enclose="div"> | ||
Revision as of 19:12, 24 February 2017
{{code|autofs is the linux automounter. It's a daemon that automatically mounts filesystems as they are accessed on demand.
Configuration
The primary configuration file used by automount is {{code|/etc/auto.master which defines what mounts automount is responsible for.
#
# /etc/auto.master
#
+auto.master
/home /etc/auto.home
In the example above, automount is responsible for mounting directories under /home and the configuration for it is under {{code|/etc/auto.home. The configuration under {{code|/etc/auto.home will define directories in {{code|/home and their corresponding mount locations.
#
# /etc/auto.home
#
leo file1:/export/home/leo
Anyone going to {{code|/home/leo will cause automount to mount {{code|/home/leo from {{code|file1:/export/home/leo.
You may specify mount options by placing them before the mount location:
#
# /etc/auto.home
#
leo -fstype=nfs4 file1:/export/home/leo
Dynamic Automount Rules
The automount configuration can be made as a script to make mounting more intelligent. automount will pass in the mounting point to your {{code|auto mount configuration.
For example, if home directories are stored on multiple file servers, we can make {{code|/home the mounting point for all users by doing something like so:
# cat /etc/auto.home
#!/bin/sh
# Automount will pass in the username as the first parameter since we are
# mounting /home/<username>
Username=$1
# The default fileserver is 'file1'
Server="file1"
# The path to the mount for this user
Path="/export/home/$Username"
# As a proof of concept, we can make a specific user use a different filesersver
# Eg: leo's home directory will be mounted from file2
if [ "$Username" = "leo" ] ; then
Server="file2"
fi
# Echo out the configuration for automount
echo "-fstype=nfs4,sec=krb5,soft,rsize=8192,wsize=8192,rw $Server:$Path"