Autofs - subdirectory under mount-point of another map

Hello,
I'm wanting to convert our environment from static fstab entries to autofs.

One of the problems I ran into while testing things is I can't change any existing paths in use by the company today - the pipeline code has paths hard coded in, along with other legacy reasons.

Currently with fstab, under /mnt we statically mount 3 main directories:

/mnt/editorial
/mnt/library
/mnt/projects

We want to change these to be controlled by automount.

The editorial and library base dirs operate as expected with automount, and have no special requirements. Mounting the base of them is what we want and works.

If we were to cd into /mnt/projects (while statically mounted via fstab) we would see our project directories, example:

/mnt/projects/apple_vex
/mnt/projects/starwars
/mnt/projects/ironman23

We want to change this behaviour, so only the project dir accessed will mount. (similar to how the homedirs map only mounts the user dir, not the base of user dirs) But the "legacy" path is causing this not to work.

auto.master:

/usr/people /etc/auto.home
/mnt/projects /etc/auto.projects
/mnt	 /etc/auto.production 

auto.production

editorial	-fstype=nfs,rw		storage1.work.com:/editorial
library     -fstype=nfs,rw		storage1.work.com:/library

auto.projects

 *	-fstype=nfs,rw		storage1.work.com:/projects/&

auto.home

*   -fstype=nfs,rw,vers=3,sec=sys        homedirs.work.com:/usr/people/&

The above auto.projects doesn't work as the directory /mnt/projects doesn't exist and you can't make it, which makes sense. This is what we are trying to solve, if its solvable.

[root@lnx-greg ~]# mkdir /mnt/projects
mkdir: cannot create directory ‘/mnt/projects’: Permission denied

And autofs can't help us if we try to cd into a project dir:

[root@lnx-greg ~]# cd /mnt/projects/testshow
-bash: cd: /mnt/projects/testshow: No such file or directory

/mnt <-- auto.production
/mnt/projects <-- auto.projects

In summary my question is: Are you aware of a way or workaround so a dir under an existing autofs mount-point can be the mount-point of another autofs map? We want to be able to cd into /mnt/projects/starwars and only have the sub dir starwars mount instead of the /mnt/projects directory itself (/mnt/projects vs /mnt/projects/starwars).

I understand you can't mount over an existing mount normally, but thought there may be some autofs magic we could use.

hope i'm making sense here. :slight_smile:

thanks,
-greg

The autofs vnodes, the left column in auto.master, may not be nested:

/usr/people /etc/auto.home
/mnt	 /etc/auto.production 

But you should be able to do it in your auto.production map:

editorial	-fstype=nfs,rw		storage1.work.com:/editorial
library     -fstype=nfs,rw		storage1.work.com:/library
projects/*	-fstype=nfs,rw		storage1.work.com:/projects/&

Thanks again MadeInGermany, appreciate your replies.

Unfortunately that doesn't seem to be working with this version. I'll do some more research using your idea though, got excited when I seen your reply thinking it was the solution.

thank you,
-g

[root@lnx-greg etc]# dnf info autofs | grep ^V
Version      : 5.1.7
[root@lnx-greg etc]# uname -r
5.14.0-284.25.1.el9_2.x86_64
[root@lnx-greg etc]# cat /etc/auto.production 
editorial	        -fstype=nfs,rw		storage1.work.com:/editorial
library		-fstype=nfs,rw		storage1.work.com:/library
projects/*	-fstype=nfs,rw		storage1.work.com:/projects/&

[root@lnx-greg etc]# cat /etc/auto.master
/usr/network   -hosts
/usr/people /etc/auto.home
/mnt	 /etc/auto.production
[root@lnx-greg log]# ls /mnt/projects/foxhole
ls: cannot access '/mnt/projects/foxhole': No such file or directory

syslog :
 Sep  5 19:03:17 lnx-greg automount[3058]: key "projects" not found in map source(s).

Try /projects/*
with a leading slash.
Run the automount daemon with -v option, and watch the system messages.
(
If you have systemd then run
systemctl cat autofs
edit the given file and put the -v
)

Good day - sorry for the delay. We received some equipment last week that keep us busy in the DC most of the week.

Doesn't look like autofs likes that either, which is a bummer. Looks logical.

I am going to talk to the TD department and see if I can convince them to rewrite paths, in my mind they should be using a variables to set them, so may not be a big ask. I hope. The other idea was to offer the other 2 mounts (library and editorial) in the same way, so library/* and editorial/*.. Will have to test to make sure Avid and friends are ok with that.

thanks again for your time with this MadeInGermany, if you've any more thoughts, happy to give them a go!

 [root@lnx-greg log]# ls /mnt/projects/itll
ls: cannot access '/mnt/projects/itll': No such file or directory
[root@lnx-greg log]# 

*syslog >* Sep 11 12:31:43 lnx-greg automount[11701]: key "projects" not found in map source(s).

[root@lnx-greg log]# cat /etc/auto.production 
editorial	-fstype=nfs,rw		        storage1.work.com:/editorial
library		-fstype=nfs,rw		storage1.work.com:/library
/projects/*	-fstype=nfs,rw		storage1.work.com:/projects/&
[root@lnx-greg log]# 

Take care,
-greg

Obviously the * can only be used as the full key. (And nothing more is mentioned in the documentation.)

As an alternative, you can go for a direct map where each key in the 1st column is a autofs vnode:

/etc/auto.master

/usr/people /etc/auto.home
/mnt/projects /etc/auto.projects
/-  /etc/auto.direct

/etc/auto.direct

# production mounts
/mnt/editorial	-fstype=nfs,rw		storage1.work.com:/editorial
/mnt/library     -fstype=nfs,rw		storage1.work.com:/library

/etc/auto.projects

 *	-fstype=nfs,rw		storage1.work.com:/projects/&

The auto.direct can have all direct mounts in the 1st column, but no * wildcard.

1 Like

Once again - sorry for the delay.

I gave the last suggestion a go, and it works as I was hoping! Thanks very much MadeInGermany! Now that I see how you did it, seems logical...

Appreciate your time spent with this. Next time I'm in Germany I'll buy you a beer!

-greg

2 Likes

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.