Situation 1) is probably caused by your
/etc/auto.master.d/mount.nfs not being named
/etc/auto.master.d/mount.autofs: according to
auto.master(5) man page and comment in the
/etc/auto.master configuration file, any files in
auto.master.d must have an
*.autofs suffix to work.
Your situation 2) is basically working exactly like a classic-style
autofs is expected to work with your current configuration.
With your current configuration, the
/home/me/ directory becomes an autofs map mountpoint: a special virtual directory that senses when someone attempts to access it. If you attempt to list the contents of the autofs mountpoint, it will list the contents of the map as sub-directories (in your case, just the
nas sub-directory), and when you actually attempt to access those sub-directories,
autofs will automatically mount them as required NFS share before letting that access happen, and can automatically unmount each share when it is no longer being used.
The indirect maps (like your current configuration) are really designed for situations like
/home/ being an autofs map mountpoint: the user home directories would then be individual NFS shares in the indirect map, that can be mounted and unmounted as users log in and out. Since updates to indirect maps take effect immediately, new users can be created and old ones removed without restarting the
If you want to mount the NFS share without an intervening directory, you could do it by defining a direct map in
echo "/- /etc/auto.me.nfs" >/etc/auto.master.d/mount.autofs
Then changing the contents of
/home/me/nas -fstype=nfs4 nas:/data/directory
And finally restarting the autofs service:
systemctl restart autofs
This should exactly replicate the effects of the
mount nas:/data/directory /home/me/nas command whenever you access
/home/me/nas, and allow it to be unmounted when there are no processes accessing it. But any changes to the configuration of the direct map will require restarting the autofs service, unlike in the case of the indirect map.
Alternative solution with systemd
systemd, there is an alternative way to set up a single auto-mounting directory without even needing a separate
autofs service. Just write an entry in
/etc/fstab like this:
nas:/data/directory /home/me/nas nfs nfsvers=4,nofail,x-systemd.automount 0 0
To activate this entry immediately, you would need two commands:
systemctl daemon-reload #triggers systemd-fstab-generator to re-make *.mount and *.automount units
systemctl start home-me-nas.automount #starts the newly created automount unit
Otherwise, it would activate automatically at next reboot.
For more details and configuration options, read