Autofs: Difference between revisions

From Lolly's Wiki
Jump to navigationJump to search
m (Text replacement - "<source" to "<syntaxhighlight")
Line 4: Line 4:
==Automount home directories==
==Automount home directories==
===/etc/auto.master===
===/etc/auto.master===
<source lang=bash>
<syntaxhighlight lang=bash>
#
#
# Include /etc/auto.master.d/*.autofs
# Include /etc/auto.master.d/*.autofs
Line 11: Line 11:
</source>
</source>
===/etc/auto.master.d/home.autofs===
===/etc/auto.master.d/home.autofs===
<source lang=bash>
<syntaxhighlight lang=bash>
/home  /etc/auto.master.d/home.map
/home  /etc/auto.master.d/home.map
</source>
</source>
===/etc/auto.master.d/home.map===
===/etc/auto.master.d/home.map===
Mount homes from different locations.
Mount homes from different locations.
<source lang=bash>
<syntaxhighlight lang=bash>
*      :/data/home/& nfs.server.de:/home/&
*      :/data/home/& nfs.server.de:/home/&
</source>
</source>
or from a server that supports NFSv4.1:
or from a server that supports NFSv4.1:
<source lang=bash>
<syntaxhighlight lang=bash>
*      -proto=tcp,vers=4.1 nfs.server.de:/home/&
*      -proto=tcp,vers=4.1 nfs.server.de:/home/&
</source>
</source>
Line 27: Line 27:
The ampers and is replaced by the part which was matched by *.
The ampers and is replaced by the part which was matched by *.
So if you enter /home/a the automounter searches local for /data/home/a which will be mounted when found.
So if you enter /home/a the automounter searches local for /data/home/a which will be mounted when found.
<source lang=bash>
<syntaxhighlight lang=bash>
# cd /home/a
# cd /home/a
# mount -v | grep /home/a
# mount -v | grep /home/a
Line 34: Line 34:


For another /home/b which is on the nfs server it looks like this:
For another /home/b which is on the nfs server it looks like this:
<source lang=bash>
<syntaxhighlight lang=bash>
# cd /home/b
# cd /home/b
# mount -v | grep /home/b
# mount -v | grep /home/b
Line 42: Line 42:
===cifs===
===cifs===
<i>/etc/auto.master.d/mycifsshare.autofs</i>:
<i>/etc/auto.master.d/mycifsshare.autofs</i>:
<source lang=bash>
<syntaxhighlight lang=bash>
/data/cifs /etc/auto.master.d/mycifsshare.map
/data/cifs /etc/auto.master.d/mycifsshare.map
</source>
</source>
<i>/etc/auto.master.d/mycifsshare.map</i>:
<i>/etc/auto.master.d/mycifsshare.map</i>:
<source lang=bash>
<syntaxhighlight lang=bash>
mycifsshare -fstype=cifs,rw,credentials=/etc/samba/mycifsshare_credentials,uid=<myuser>,forceuid ://192.168.1.2/mycifsshare
mycifsshare -fstype=cifs,rw,credentials=/etc/samba/mycifsshare_credentials,uid=<myuser>,forceuid ://192.168.1.2/mycifsshare
</source>
</source>

Revision as of 16:27, 25 November 2021

autofs autofs

Automount home directories

/etc/auto.master

<syntaxhighlight lang=bash>

  1. Include /etc/auto.master.d/*.autofs

+dir:/etc/auto.master.d </source>

/etc/auto.master.d/home.autofs

<syntaxhighlight lang=bash> /home /etc/auto.master.d/home.map </source>

/etc/auto.master.d/home.map

Mount homes from different locations. <syntaxhighlight lang=bash>

  • :/data/home/& nfs.server.de:/home/&

</source> or from a server that supports NFSv4.1: <syntaxhighlight lang=bash>

  • -proto=tcp,vers=4.1 nfs.server.de:/home/&

</source>

The asterisk marks any dir in /home/* should be matched by this rule. The ampers and is replaced by the part which was matched by *. So if you enter /home/a the automounter searches local for /data/home/a which will be mounted when found. <syntaxhighlight lang=bash>

  1. cd /home/a
  2. mount -v | grep /home/a

/data/home/a on /home/a type none (rw,bind) </source>

For another /home/b which is on the nfs server it looks like this: <syntaxhighlight lang=bash>

  1. cd /home/b
  2. mount -v | grep /home/b

nfs.server.de:/home/b on /home/b type nfs (rw,addr=172.16.17.24) </source>

cifs

/etc/auto.master.d/mycifsshare.autofs: <syntaxhighlight lang=bash> /data/cifs /etc/auto.master.d/mycifsshare.map </source> /etc/auto.master.d/mycifsshare.map: <syntaxhighlight lang=bash> mycifsshare -fstype=cifs,rw,credentials=/etc/samba/mycifsshare_credentials,uid=<myuser>,forceuid ://192.168.1.2/mycifsshare </source>