Mount NFS share at user login

Dear Forum,

currently, I have the problem that my NFS shares that should be mounted via systemd unit are not mounted at system startup, because the network is only connected when the user logs in. The reason is that I do not have a network setup for all users, but have set up a separate setup for each user via KDE network manager.
I could solve the problem by creating a network setup that all users can use. However, this is then also used when the user logs in, and not the user-specific network setup.

How can I solve my problem?

Is there a way to tell the systemd units to mount the NFS only on login?

Or is there a possibility that KDE changes the network on login?

My mount unit looks like:

Description=Mount /my_path/to/music via NFS

Remark: I did not us a automount unit.

Thank you in advance for your help.

Why don’t you use an automount unit?

An automount unit only mount the share when it is accessed - which is what your want - a user logged in before mounting the share.

Is what you want or do you want to create a different share for different users?


Hi @mepi0011,

Have a look at linux - How to start a systemd service after user login and stop it before user logout - Super User. Sounds like what you need.

Also see [root tip] systemd mount unit samples
There might be something for you.

Hope this helps!

1 Like

Hello @Mirdarthos,
Hello @linux-aarhus,

Thank you for your suggested solutions. After some tests I decide to use the solution with automount units as described in the NFS - ArchWiki article.

This topic was automatically closed 15 days after the last reply. New replies are no longer allowed.