autofs mounting local filesystems by label

previously: https://wibblement.blogspot.com/2023/05/minimal-automounter-config-for-linux.html

There are a couple of oddities around configuring a direct autofs map.

To mount by label, the entry in the direct map looks like:

    /wibble -fstype=auto LABEL=ythh0

If the middle field is ommitted, then it defaults to trying to treat it as NFS.

The order is opposite to fstab(5), which has the device first, and then the mount point.

The automounter will make the mount appear at the location whether the mount point exists as a directory or not.  This is different semantics from mount(8) / fstab(5), which require that the mount point exists.

If you need to troubleshoot, you can set "logging = verbose" in the "[ autofs ]" section of /etc/autofs.conf and restart autofs.  autofs.conf is by default in debian a vast commented-out file, with about 3 lines not commented out.  Better to remove all the commented lines, and just keep the effective ones.

Thus, the revised example from before becomes:

Install package autofs (debian).  Sadly, installing it also presumes to enable and start the service.

/etc/autofs.conf refers to /etc/auto.master; optionally de-comment /etc/autofs.conf to leave something like (debian 12):

[ autofs ] 

master_map_name = /etc/auto.master

timeout = 300

In /etc/auto.master:

/- auto.direct

rationale: The dash signifies a "direct" mount, meaning the one like you want, which transparently (if things are working) makes things appear at paths, rather than the other type, which visibly involves symlinks, and / or mount points which are subdirectories of an assigned automounter directory.

And then in /etc/auto.direct:

/wibble nfs-server.example.org:/srv/wibble
/ythh0 -fstype=auto LABEL=ythh0            # non-nfs requires -fstype


Comments

Popular posts from this blog

the persistent idiocy of "privileged ports" on Unix

google is giving more and more 500 errors

Guernsey Waste in incorrect bag-rejection horror May 6th, 2024