0

I have a cifs fileshare that I use. My organisation requires that it uses Kerberos so it's mounted with sec=krb5. This is fine, but I'd like it to mount after login automatically without having to click on the icon on Nautilus.

I can create a .desktop entry to .config/autostart/ but it seems a bit clunky. I was hoping to be able to do it in the fstab but I cannot fins the right option. It's currently this; $FILEPATH $DFS_MOUNT cifs _netdev,sec=krb5,users,rw 0 0

1 Answer 1

1

This is what works for me in Ubuntu 18.04:
I added an fstab entry for the fileshare directory on the file server:

//server.my.domain.name/directory /mount/point cifs noauto,users,_netdev,sec=krb5 

Then I created a shell script with the file extension .sh in /etc/profile.d to mount the directory on login, but only for users who belong to the appropriate domain:

if [[ " $(groups) " =~ ' domain [email protected] ' ]]; then mount /mount/point >/dev/null fi 

The paths above have been anonymized to protect the guilty ;-}

P.S. If your network takes too long to start, you may need something that takes that into account, such as:

for i in {1..30} # give up if server isn't reachable in 30 seconds do sleep 1 # wait a second if [ ping -c1 server.my.domain.name &> /dev/null ]; then continue # loop if server can't be reached elif [[ " $(groups) " =~ ' domain [email protected] ' ]]; then mount /mount/point >/dev/null # mount share once server responds fi done 

WARNING: This is untested; use at your own risk!

You must log in to answer this question.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.