autofs unmout my /home drive

Latest response

Hi

I have different workstations each with its own /home drive and users on the machines.

Workstation_1 with user_a
Workstation_2 with user_b
Workstation_3 with user_c
...
 
On the Workstations I have the following set up, example Workstation_1
In my /etc/fstab I have the flowing entry to bind /nfsexports/user_a with /home/user_a

"/etc/fstab"
/home/user_a               /nfs4exports/user_a   none    rw,bind 0   0

The "/etc/exports" file looks like this.
/nfs4exports        *(rw,nohide,sync,insecure,root_squash,no_subtree_check)
/nfs4exports/user_a        *(rw,nohide,sync,insecure,root_squash,no_subtree_check)

The "/etc/auto.master" file looks like this.
/misc    /etc/auto.misc
/net    /etc/auto.net.nfs4
/home    /etc/users.master

The "/etc/users.master" file looks like this.
/usesr_b    -rw    Workstation_2:/nfs4exports/user_b
/usesr_c    -rw    Workstation_3:/nfs4exports/user_c

The "/etc/auto.net.nfs4" file looks like this.
opts="-fstype=nfs4,hard,intr,nodev,nosuid,nosymlink"
for P in /bin /sbin /usr/bin /usr/sbin
do
    for M in showmount kshowmount
    do
        if [ -x $P/$M ]
        then
            SMNT=$P/$M
            break
        fi
    done
done

[ -x $SMNT ] || exit 1
SHOWMOUNT="$SMNT --no-headers -e $key"

$SHOWMOUNT | LC_ALL=C sort -k 1 | \
    awk -v key="$key" -v opts="$opts" -- '
    BEGIN    { ORS=""; first=1 }
        { if (first) { print opts; first=0 }; print " \\\n\t" $1, key ":" $1 }
    END    { if (!first) print "\n"; else exit 1 }
    ' | sed 's/#/\\#/g'| sed -e 's,:/.[^\s]*,:/ ,'

When I start autofs the /home drive gets umounted and user_a doesn't have a home directory which is under "/home/users_a". I would appreciate it if someone can tell me what have I done wrong?

Responses

This would be expected behavior. When you have autofs set up to mount things under /home, it takes over /home completely. Basically, you're telling autofs "mount an empty directory over /home, then, as needed, add user_b and user_c into this empty mountpoint. /home/user_a still exists, it's just been overlaid by autofs's empty /home root mountpoint. If you want /home/user_a to exist, you would have to define an appropriate mapping in your /etc/users.master file to do so (remove /nfs4exports/user_a from /etc/fstab and create an appropriate mapping for it in your /etc/users.master file).

Hi Thomas

 

Thank you for the info.

This is why I have a scheme for /home.  I'm actually in the middle of blogging it after several requests I document it, but it basically goes like such ...

  • Local, Bind Mount(s) (Direct Map)
    • :/export/local
    • -> /home/local
  • Remote, NFS Mount(s) (LDAP Domain-Realm Map(s)):
    • server:/export/server/user-resource
    • -> /home/domain-realm/user-resource

For /export/local, be sure to run chcon --reference=/home so SELinux doesn't start throwing errors with home directories on /export/local (even if bind mounted to /home/local).

And you'll want to probably switch your default home directory location to be under /home/local.