2

I have a couple of network shares mounted with cifs in fstab and it works fine when the network is up. However, this is a laptop and often my wi-fi connection isn't up when mounting is triggered by fstab so it fails. Is there a way to have the network shares mounted when I log into my user account instead?

Christian
  • 1,789
  • 2
  • 22
  • 38

1 Answers1

1

You can perform mounts at login by using pam_mount.

First install the required packages with:

sudo apt-get install cifs-utils libpam-mount

Then edit the "/etc/security/pam_mount.conf.xml" configuration file to declare your mounts.

See my post for an example configuration and "man pam_mount.conf" for the general syntax.

It will mount all shares every time a user logs in (except those already mounted) and unmount them when all users have logged out. This will even enable you to mount password-protected shares, provided your Ubuntu login credentials are the same as the ones on the CIFS server(s).

However, as mentioned in my post, be aware that it will introduce a delay in the login process in case the shares are not accessible.

it_man
  • 41