autofs and rbind mount

Hello!

I’m running into problems using NFS/NIS and automount for homes.
My config files are (nearly) identical on every client:
/etc/fstab:


/dev/disk/by-id/ata-ST1000VX000-1CU162_Z1DCQMPZ-part3  swap                 swap       defaults              0 0
/dev/disk/by-id/ata-ST1000VX000-1CU162_Z1DCQMPZ-part1  swap                 swap       defaults              0 0
/dev/disk/by-id/ata-ST1000VX000-1CU162_Z1DCQMPZ-part2  /                    ext4       acl,user_xattr        1 1
/localhome                                             /nfs4/localhome      none       defaults,bind         0 0

/etc/exports:


/nfs4                                 *(fsid=0,crossmnt,rw,no_root_squash,async,no_subtree_check,insecure)
/nfs4/localhome                       *(rw,no_root_squash,async,no_subtree_check,insecure)
/nfs4/localhome/[local client name]   *(rw,no_root_squash,async,no_subtree_check,insecure)

/etc/auto.master:


+auto.master
/home    auto.home    rsize=8192,wsize=8192

/etc/auto.home:


*        -fstype=nfs4,rw,intr,hard,timeo=300        &:/localhome/&

Up to now users had their home defined in /etc/passwd just as /home/[local client]/[userid]
and everything worked fine: users could login on any client in the subnet and found their home mounted.
But now I had to upgrade one client with a bunch of harddisks, mounted in subdirs of /localhome.
The config files for the client with newly mounted disks in subdirs:
/etc/fstab:


/dev/disk/by-id/ata-INTEL_SSDSC2BW240H6_CVTR551303N8240CGN-part1  swap                         swap       defaults              0 0
/dev/disk/by-id/ata-INTEL_SSDSC2BW240H6_CVTR551303N8240CGN-part3  swap                         swap       defaults              0 0
/dev/disk/by-id/ata-INTEL_SSDSC2BW240H6_CVTR551303N8240CGN-part2  /                            ext4       acl,user_xattr        1 1
/dev/disk/by-id/ata-ST4000NM0033-9ZM170_Z1Z9CWSK-part1            /localhome/gauss/1           ext4       defaults              1 2
/dev/disk/by-id/ata-ST4000NM0033-9ZM170_Z1Z9D4KQ-part1            /localhome/gauss/2           ext4       defaults              1 2
/dev/disk/by-id/ata-ST4000NM0033-9ZM170_Z1Z9D7WZ-part1            /localhome/gauss/3           ext4       defaults              1 2
/localhome                                                        /nfs4/localhome              none       defaults,rbind        0 0

/etc/exports:


/nfs4                   *(fsid=0,crossmnt,rw,no_root_squash,async,no_subtree_check,insecure)
/nfs4/localhome         *(rw,no_root_squash,async,no_subtree_check,insecure)
/nfs4/localhome/gauss   *(rw,no_root_squash,async,no_subtree_check,insecure)
/nfs4/localhome/gauss/1 *(rw,no_root_squash,async,no_subtree_check,insecure)
/nfs4/localhome/gauss/2 *(rw,no_root_squash,async,no_subtree_check,insecure)
/nfs4/localhome/gauss/3 *(rw,no_root_squash,async,no_subtree_check,insecure)

The new case should be /home/gauss/1/[userid] for this user.
and this is exactly what is done by autofs and NFS on remote clients.
These subdirs are exported fine so on remote clients they are visible AND filled with their content.
But on the localhost they are empty. It seems that autofs detects it as local and does a bind mount instead of a rbind mount.
Result is that the sub-folders 1 to 3 of the bind-mounted localhome/gauss/ don’t show the file system but just the empty dirname.
In consequence a local login of the user leads to the message:
> cd ~
bash: cd: /home/gauss/1/[userid]: No such file or directory

Any suggestions on how to
a) tell autofs to use rbind instead of bind or
b) any workaround for this scenario?

Not really a workaround, but rather some advice / suggestions:

  • I’d use “/home” instead of “/localhome”
  • I’d use NIS for the user administration and user login
  • I’d use Yast to setup the whole thing.

It looks like the server is acting as it’s own client

I am using NIS+automount (Yast was used to set up NFS and NIS leading to the cited config files).
/home is used by automount and is empty until user logs in.
(auto.home tells the automounter to mount &:/localhome/& in /home where & points to the client and subdir, where the user’s home physically is)
Current setting is for example:
user joe works usually on client tesla, so his home is defined in the NIS servers passwd as “/home/tesla/joe”.
physically it lies on client tesla in /localhome/tesla/joe.
This is mounted by NFS/automount locally AND on remote hosts on login in /home/tesla/joe
and works fine.

Difficulties started when I tried to extend home space on one client with more than one hard disks mounting them in subdirs of /localhome.
I created subdirs 1 to 3 in /localhome, defined a local home for user mark as /home/gauss/1/mark and put it physically in gauss:/localhome/gauss/1/mark.
This is mounted correctly on every client except gauss. On gauss /home/gauss/1 is empty as the subdir mount is not propagated.
So these mounts seem not to be propagated by local automount but only by remote NFS.

The problem for me lies in the local automount daemon which only mounts main dir /localhome/[client]/ but not its subdirs /1 to /3.
(adding line
/localhome/gauss/1 /nfs4/localhome/gauss/1 none defaults,bind 0 0
to fstab didn’t change anything)

I read somewhere about overriding this mount problem with symlinks but have no idea what to symlink where.
As /home is empty (and needs to be in this config) until clients login I can’t symlink anything there.