autofs: Mount under user home directory

Latest response

Hello,

I setup autofs with kerberos (https://access.redhat.com/solutions/276503), which works great. But I'm having an additional requirement:

Is there a way to make the destination folder in /etc/auto.master "dynamic" by variables?

I want that the destination folder is under each users home. Something like the following in /etc/auto.master:
~/server /etc/auto.cifs
or
&/server /etc/auto.cifs

But these both don't work.

Does someone have an idea?

Regards,

Responses

Can you post the contents (or sanitised contents) of your auto.cifs file?

From memory, the ampersand can be used for key substitution on the right hand side, but the key needs to be defined on the left. In your examples above you are using key substitution on the left.

So the desired result is to mount a directory down from the user's home directory dynamic portion?

eg.

/home/<username>/server

Which version of RHEL are you using?

The current content of my auto.cifs is:

home -fstype=cifs,sec=krb5,user=&,uid=$UID,gid=$GID,cruid=$UID,file_mode=0600,dir_mode=0700,nounix,noserverino ://server/homedirs/&

If user a logs in, then it should be mountet to
/home/a/server/home
if user b logs in, then
/home/b/server/home

I'm trying this on RHEL7.0

So the user home directories, eg:
/home/a
/home/b

Already exist locally on the server, these don't need to be mounted? But the 'server' directory doesn't exist in each '/home/x' directory?

So you are attempting to mount 2 levels at once under the users home directory?

ie. 'server/home'

So the user home directories, eg:
/home/a
/home/b

Already exist locally on the server, these don't need to be mounted?

Right. These are local directories.

But the 'server' directory doesn't exist in each '/home/x' directory?

The 'server' directory exists as an empty directory also in every user home (was created throught /etc/skel/)

So you are attempting to mount 2 levels at once under the users home directory?
ie. 'server/home'

No. I only want that the users home from the Samba server gets mounted to /home/a/server/home/ via CIFS.

And if user b is logged into the system, then autofs should mount user b server home directory to /home/b/server/home/.

The only way I can think you would be able to achieve that with automount is to make an automount entry for each user (perhaps on useradd?)... unless someone else can suggest an alternative? (can't find anything specific in autmount documentation)

You could also create the 'server/home' directory on the fileserver for each user and then mount the user home directory as a normal automount (not multiple levels).

eg. /home/a (a is the autmount), when mounted the user's directory contains 'server/home'

Is the issue that users have local home directory contents on each server that you want to keep? and that is why you want to mount a level down?

It may help if you provide a description of the issue you are attempting to solve (with constraints) and others may be able to provide alternate methods that will work for you.

Is the issue that users have local home directory contents on each
server that you want to keep? and that is why you want to mount a
level down?

Yes. The homes local on the machines should stay untouched.

It may help if you provide a description of the issue you are
attempting to solve (with constraints) and others may be able
to provide alternate methods that will work for you.

The situation is quite simple: The users should be able to access a share on the Samba server easily without mounting it everytime by themself.

  • Storing the password in a credentials file and mounting via /etc/fstab is undesirable.
  • Mounting the share via command is not reasonable for the users
  • Local applications can access the local filesystem (not smb:// URLs, etc.)

The only 'variable' I'm aware of that works on the key side (left side) of an automount map is *.

If you set up the auto.master as:
/home/*/server /etc/auto.cifs

That may work to call the auto.cifs indirect map for the home CIFS mount. I don't recall if auto.master is considered a direct or indirect map though.

where can I find the format of auto.cifs

Close

Welcome! Check out the Getting Started with Red Hat page for quick tours and guides for common tasks.