LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - General (https://www.linuxquestions.org/questions/linux-general-1/)
-   -   Any way to pass variables in /etc/fstab? (https://www.linuxquestions.org/questions/linux-general-1/any-way-to-pass-variables-in-etc-fstab-4175627999/)

Timothy Miller 04-19-2018 11:45 AM

Any way to pass variables in /etc/fstab?
 
So I'm trying to set up fstab so that users have access to their homedrive. All homedrives are on the same server, but of course need different credentials, so it's a 2 part question:

1. Is there a way to write the line in fstab so that the remote directory to be mounted is pulled from their username? IE - //remote/$user. I know this specifically doesn't work, but I'm wondering if there's anything that does the same in fstab?

2. Credentials file. Is there anything I can use for specifying the credentials file? IE - credentials=$home/.credentials so that each user passes the correct username/password? I know $home doesn't work, but is there anything I can do that would replicate?

Thanks!
Most of my users are clueless when it comes to linux, so I want as much of a hands-off click and go solution, and some of them share a single linux laptop for their group, so I need it set up to be able to work with multiple users on the same machine. I have it set up to work with a single user just fine.

MensaWater 04-19-2018 11:54 AM

Are these home directories in an NFS share from the server? if so you might want to use automounter to accomplish what you want.

One write up for how to do that on CentOS (which would be the same on RHEL) is at:
http://www.learnitguide.net/2016/01/...nfs-linux.html

Turbocapitalist 04-19-2018 11:55 AM

Which protocol are you using to mount the remote directories or file systems? NFS, OpenAFS, SMB, sshfs (SFTP), Coda, etc?

Which distro is doing the mounting?

Timothy Miller 04-19-2018 12:00 PM

Quote:

Originally Posted by Turbocapitalist (Post 5845213)
Which protocol are you using to mount the remote directories or file systems? NFS, OpenAFS, SMB, sshfs (SFTP), Coda, etc?

Which distro is doing the mounting?

CIFS (SMB)

distro will depend, most users will probably use Ubuntu, but at least some will use Fedora or Debian.

Quote:

Originally Posted by MensaWater (Post 5845212)
Are these home directories in an NFS share from the server? if so you might want to use automounter to accomplish what you want.

One write up for how to do that on CentOS (which would be the same on RHEL) is at:
http://www.learnitguide.net/2016/01/...nfs-linux.html

Hmmm, this is basically exactly what I was looking for...just need to see if I can figure it out. Surprising I'd NEVER heard of this. Too bad that tutorial lacks anything that actually explains how to use it. Will have to do some googling.

Timothy Miller 04-19-2018 12:40 PM

Yes!! Autofs works perfectly!! Thanks!!

PITA to get working on Arch...was easy on Debian, Ubuntu and Fedora.

In the end, I had it mounting to say /mnt/company/x and with Debian, Ubuntu and Fedora, it didn't mind if the /mnt/company folders already existed. With Arch, if the company folder existed, it would fail to mount. Just a small bit of troubleshooting if anyone else runs into this in the future.

Timothy Miller 04-19-2018 11:55 PM

So, just some weirdness.

On my desktop and 1 laptop (both Debian), this works perfectly with vers=3.0 in the mount options.

On another laptop, identical Debian installation, this WILL NOT work with vers=3.0, but does work with vers=2.0 in the mount options. However, if I pass the mount command directly, vers=3.0 does work!!

Odd.


All times are GMT -5. The time now is 06:48 PM.