0

I am mounting my shared drive using terminal in my Ubuntu machine like this:

sudo mount -t cifs -o "username=${USER},password=${PASSWORD},uid=$(id -u),gid=$(id -g)" //server-address/folder /mount/path/on/ubuntu

I wonder how I can permanently mount it using /etc/fstab keeping in mind that I'm automatically fetching the uid and gid as shown above?

  • what are you means of:automatically fetching the uid and gid and what would you of it? – Hossein Vatani Jul 23 '18 at 12:39
1

A syntax similar to this will do the job to create an fstab entry to what you are asking:

//server-address/folder    /mount/path/on/ubuntu        cifs credentials=/root/.smbcredentials,iocharset=utf8,file_mode=0770,dir_mode=0770,uid=1001,gid=1001 0 0

I advise using the /root/.smbcredentials file in order to hide the authentication credentials.

You may also run the command mount after you run the command on the question to see the approximate syntax.

See related: CIFS randomly losing connection to Windows share

  • But how I can get the uid and gid automatically instead of hardcoding it? as I'm using many machines and they have different gids and uids – Tak Jul 23 '18 at 11:37
  • You should have unified gids and uids, either through a central server or doing the effort manually. Or using it in a database + scripting or MySQL; however I am afraid that detailing the steps of it is out of scope here. – Rui F Ribeiro Jul 23 '18 at 11:39

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.