Double mount autofs and nfs

I have a server with provides home directories through nfs, at path /home/lan. It is defined in my client’s configuration.nix as

services.cachefilesd.enable = true;
fileSystems."/home/lan" = {
    device = "";
    fsType = "nfs";
    options = ["fsc" "x-systemd.automount" "noauto" "x-systemd.idle-timeout=600"];

But on the client, this directory is mounted twice at the same path, as shown by the output of mount | grep /home/lan:

systemd-1 on /home/lan type autofs (rw,relatime,fd=139,pgrp=1,timeout=600,minproto=5,maxproto=5,direct,pipe_ino=11118) on /home/lan type nfs4 (rw,relatime,vers=4.2,rsize=1048576,wsize=1048576,namlen=255,hard,proto=tcp,timeo=600,retrans=2,sec=sys,clientaddr=,fsc,local_lock=none,addr=

I have another nfs mount at another path, but it doesn’t exhibit this behaviour. The only differences are, as far as I know

  • that the home directories in home/lan are referred to in the OpenLDAP logging mechanism.
  • that I have tried a configuration using autofs but I was long ago and I have reinstalled the system on the client from scratch, so that the only remaining traces can only be on the server.

Finally, I think that this is the cause of a problem I have, namely that I have an incessant succession of rpc.mountd attaching and detaching.

Has anyone got an idea on how to fix this?

You used x-systemd.automount. This is expected. It’s how systemd implements that option. It creates an autofs mount at the path so systemd can do the actual mount on-demand when the directory is actually accessed, rather than at boot. Once accessed, the file system is mounted over the autofs.

Nothing to see here. This is what it’s supposed to do.

1 Like

Oh, I see. I get it. Thank you!