Trying to get idmap to startup before autofs

I am using autofs to mount some NFS4 shares, NFS4 needs idmapd which I have enabled, on a reboot i don’t see idmapd startup

i have to
systemctl restart nfs-common

and then

systemctl restart autofs

after a reboot to get everything working right, any quick ideas to sort this out?

think I need the nfs-client.target, that is missing… not sure what the right way to add this is.

Any reason why you needed autofs and didn’t use x-systemd.automount?

didn’t know better… just figuring out automount, can i mount many mount points with automount do i need .mount .automount files for each mount point?

You don’t need any files, just respective fstab entries. Search this forum for x-systemd.automount nfs fstab

the solutions for fstab seem quite kldugy… no? other scripts/timers etc…

just tried automount vis systemd, still doesn’t start the idmapd service… like I said looks like I need the nfs-client.target file that usually starts up all the dependant rpc services like idmapd.

Kludgy it is! never mind…

To be honest I am lost in what are you trying to do! I assumed you just wanted to mount a NFS export on OSMC than all you need is a simple fstab entry and nothing more.
Or are you actually trying to run a NFS Server on OSMC?

I am trying to mount NFS 4 shares, fstab/automount/autofs all need idmapd to do proper id mapping between the server and clients.

I need the IDMAPD daemon to be running. I like automount/autofs because it mounts stuff on demand and unmounts them when not used vs fstab. This also deals with any issues like restart the nfs server nicely without stale file handles etc.

idmpad is service that is used by the nfs client to do idmapping.

that is what I have used forever really with good results.

You can use a system drop-in to override parts of a systemd unit, keep it persistent across updates and change ordering. It sounds like you want to add a Wants= directive.

Wants= directive means, there is a systemd unit that I can “want” but the problem is that there doesn’t seem to be, suspect this is more work than its worth, probably easier to put a sleep 20; restart nfs-common in the rc.local or rcS and be done with it…

Out of the box, the rpc.idmapd job fails to start with nfs-common.service but starts once nfs-common.service is manually restarted.

In fact, there is a “virtual” nfs-common.service file that is created on the fly by systemd from the init.d job.

-> Unit nfs-common.service:
        Description: LSB: NFS support files common to client and server
        Instance: n/a
        Unit Load State: loaded
        Unit Active State: active
        Inactive Exit Timestamp: Thu 2017-09-21 10:34:06 BST
        Active Enter Timestamp: Thu 2017-09-21 10:34:06 BST
        Active Exit Timestamp: Thu 2017-09-21 10:34:06 BST
        Inactive Enter Timestamp: Thu 2017-09-21 10:34:06 BST
        GC Check Good: yes
        Need Daemon Reload: no
        Transient: no
        Slice: system.slice
        CGroup: /system.slice/nfs-common.service
        CGroup realized: yes
        CGroup mask: 0x10
        CGroup members mask: 0x0
        Name: nfs-common.service
        Fragment Path: /run/systemd/generator.late/nfs-common.service
        Source Path: /etc/init.d/nfs-common
        Condition Timestamp: Thu 2017-09-21 10:34:06 BST
        Condition Result: yes
        Wants: system.slice
        WantedBy: sysinit.target
        Conflicts: shutdown.target
        Before: sysinit.target
        Before: shutdown.target
        After: rpcbind.target
        After: time-sync.target
        After: systemd-journald.socket
        After: system.slice
        References: sysinit.target
        References: shutdown.target
        References: rpcbind.target
        References: time-sync.target
        References: systemd-journald.socket
        References: system.slice
        ReferencedBy: sysinit.target
        StopWhenUnneeded: no
        RefuseManualStart: no
        RefuseManualStop: no
        DefaultDependencies: no
        OnFailureJobMode: replace
        IgnoreOnIsolate: no
        IgnoreOnSnapshot: no
        Service State: running
        Result: success
        Reload Result: success
        PermissionsStartOnly: no
        RootDirectoryStartOnly: no
        RemainAfterExit: yes
        GuessMainPID: no
        Type: forking
        Restart: no
        NotifyAccess: none
        KillMode: process
        KillSignal: SIGTERM
        SendSIGKILL: yes
        SendSIGHUP:  no
        UMask: 0022
        WorkingDirectory: /
        RootDirectory: /
        NonBlocking: no
        PrivateTmp: no
        PrivateNetwork: no
        PrivateDevices: no
        ProtectHome: no
        ProtectSystem: no
        IgnoreSIGPIPE: no
        LimitNOFILE: 4096
        StandardInput: null
        StandardOutput: journal
        StandardError: inherit
        SyslogFacility: daemon
        SyslogLevel: info
        -> ExecStart:
                Command Line: /etc/init.d/nfs-common start
                        PID: 611
                        Start Timestamp: Thu 2017-09-21 10:34:06 BST
                        Exit Timestamp: Thu 2017-09-21 10:34:06 BST
                        Exit Code: exited
                        Exit Status: 0
        -> ExecStop:
                Command Line: /etc/init.d/nfs-common stop
                        PID: 603
                        Start Timestamp: Thu 2017-09-21 10:34:06 BST
                        Exit Timestamp: Thu 2017-09-21 10:34:06 BST
                        Exit Code: exited
                        Exit Status: 0
        SysVStartPriority: 14

So even though there is only a virtual nfs-common.service file, we can still use a “drop-in” to modify its behaviour, as Sam suggested.

I’ve only had time to try After=connman-wait-for-network.service and that was unsuccessful but there is sure to be something that will work. Unfortunately, I’m out of time for now.

Edit: After some more testing I’ve been unable to get drop-ins working with generated .service units. The problem seems to be that systemd applies the drop-in to the freshly-generated unit but a “systemctl daemon-reload” is required before the unit can be used. It was a useful learning exercise.

Thanks for trying this, would have been stuck for hours with this!