2

I have this setup

Client: Centos 7.6.1810 up to date

Server: Windows 7 pro

AutoFS Configuration

# tail -1 /etc/auto.master
/srv/xray   /etc/auto.xray

# cat /etc/auto.xray
cdm8240  -fstype=cifs,ro,vers=2.0,credentials=/etc/auto.smb.cdm8-240.credentials  ://my.server/share/

# cat /etc/auto.smb.cdm8-240.credentials
username=mylogin
password=passpass123

if I mount this share manually, everything is fine

# mount.cifs -o ro,vers=2.0,credentials=/etc/auto.smb.cdm8-240.credentials //my.server/share/ /srv/xray/

# ls -l /srv/xray/ | wc -l
34
# umount /srv/xray/

If I try with autofs, I have this wrong mount entry.

/etc/auto.xray on /srv/xray type autofs (rw,relatime,fd=17,pgrp=71348,timeout=300,minproto=5,maxproto=5,indirect,pipe_ino=404555)

Then I tried to pre-create the mount point cdm8240 in the /srv/xray/ folder...

# ls -ld /srv/xray/cdm8240/
drwxrwxrwx 2 root root 6 Jun  6 08:17 /srv/xray/cdm8240/

...reload autofs and access the share and it works

# systemctl restart autofs
# ls -l /srv/xray/cdm8240/ | wc -l
34

But now here is the weird part, if I restart autofs, it dismounts the share and remove the cdm8240 folder!

# systemctl restart autofs
# find /srv/xray/ -ls
406293    0 drwxr-xr-x   2 root     root            0 Jun  6 08:20 /srv/xray/

And even changing the perms on /srv/xray/, leaving it with 755 instead of the 777 it has before! And I come back to the first situation and it's wrong mount entry.

Update 1

Tried with the "direct" mode and it looks fine now

# tail -1 /etc/auto.master
/-   /etc/auto.xray

# cat /etc/auto.xray 
/test/cdm8240  -fstype=cifs,ro,credentials=/etc/.cdm8240cred,vers=2.1,file_mode=0775,dir_mode=0775,users  ://my.server/share

so, is it a bug in the indirect mode or something "normal"?

Update 2 As explained bellow, everything was fine. I added --ghost option in my auto.master file as follow

/srv/autofs/xray   /etc/auto.xray --ghost

now the share is displayed and everything is working fine.

1 Answer 1

1

That looks perfectly normal.

The automounter takes over the top level directory, /srv/xray for all the mounts defined in the corresponding file or program, /etc/auto.xray. (In your case it's a normal file.)

Filesystems are only mounted on demand, so when you looked inside /srv/xray you would initially have seen nothing. But when you ran ls -ld /srv/xray/cdm8240/ the automounter saw the reference to the mapped directory cmd8240 and mounted the corresponding filesystem at /srv/xray/cdm8240 for you.

At some point in the future, once you'd stopped accessing the filesystem mounted at /srv/xray/cdm8240 the automounter would unmount it and /srv/xray would appear to be empty once more.


What I personally find helpful is to run the automounter underneath /var/autofs, so that for a mapping file auto.misc I'd have /var/autofs/misc and for an entry remote in that auto.misc file I'd have /var/autofs/misc/remote.

I then create a top-level directory /autofs and symlink directories from /var/autofs/misc/. This way they're visible to me even when not mounted, and I never need to worry about the /var/autofs/misc directory tree again.

mkdir -p -m755 /autofs
cd /autofs
ln -s ../var/autofs/misc/remote    # Create link to automounted 'remote'
0

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.