1

autofs

mounts my CIFS shares like this:

/mnt/server1/server1
/mnt/server2/server2

While I want it to be just:

/mnt/server1
/mnt/server2

I have in auto.master:

/mnt/server1 /etc/auto.server1 --timeout=6000 --ghost
/mnt/server2 /etc/auto.server2 --timeout=6000 --ghost

In auto.server1:

server1    -fstype=cifs,uid=1000,gid=1000,forceuid,forcegid,credentials=/etc/auto.auth    ://10.0.0.10/share

In auto.server2:

server2    -fstype=cifs,uid=1000,gid=1000,forceuid,forcegid,credentials=/etc/auto.auth    ://10.0.0.20/share

Keep in mind that everything works, except that it creates this server1/server1 structure. I've tried to just remove "server" from auto.server1, but that makes it fail to work. I've also tried to change "/mnt/server1" (and 2) in auto.master to just "/mnt", but that also makes it fail to work.

Is there some option or argument I need to enable or disable to stop it from making this extra directory? How do I tell autofs plain and simply to mount it without any additional directory being created?

1 Answers1

2

The configuration you have is called indirect maps:

Indirect maps, create-mount points as subdirectories inside the main mount-point.

in this configuration, you are telling autofs in the auto.master file:

/mnt/server /etc/auto.server --timeout=6000 --ghost

to look in /etc/auto.server and mount under the main mount point of /mnt/server (not /mnt) ... and in the auto.server file you have:

server    -fstype=cifs,uid=1000,gid=1000,forceuid,forcegid,credentials=/etc/auto.auth    ://10.0.0.10/share

server being the name(of this mount point) ... so you get the expected result of:

/mnt/server/server

Change your auto.master line to:

/mnt /etc/auto.server --timeout=6000 --ghost

and you will get what you want:

/mnt/server

Furthermore, why use two files autu.server1 and auto.server2 for the same main mount point and why two lines in auto.master for the same main mount point … combine the two files in one auto.server file with two lines like so:

server1    -fstype=cifs,uid=1000,gid=1000,forceuid,forcegid,credentials=/etc/auto.auth    ://10.0.0.10/share
server2    -fstype=cifs,uid=1000,gid=1000,forceuid,forcegid,credentials=/etc/auto.auth    ://10.0.0.20/share

and make the two lines in auto.master into just one line referencing auto.server like so:

/mnt /etc/auto.server --timeout=6000 --ghost

then, run :

sudo service autofs reload

to read the new changes.

Important notice:

Don't use any main mount-point that you specify in auto.master with another mount service e.g. the default Ubuntu Disk Manager udisks that is involved in user automatic(when connecting a USB disk) or manual(when clicking on the mount button in the GUI file manager or when issuing a mount ... command in the terminal).

automount is the program used to configure a mount point for autofs. When autofs is started, an automount daemon is spawned for each map.

As you can see these are two different system services/animal species(metaphorically speaking) ... if you point them at each others mount point/food(again metaphorically), they will fight and this would cause conflicts and casualties(metaphorically again) and one of them(or both) will loose ... and you don't want that.

Therefor, use a separate mount points for each of these services ... you can either use readily available mount points like /mnt and /media or create your own mount point/s with like mkdir ~/my_mnt and use it with like mount device ~/my_mnt ... everyone will be happier this way :)

Raffa
  • 32,237
  • I simplified my problem to give the minimal reproducible example (I didn't realize that my issue might be related to having two entries); I actually have two entries in auto.master, and when I change both to be just /mnt, only the first one works. For just one entry, your solution works though. – AlphaCentauri Jun 19 '22 at 22:23
  • 1
    @AlphaCentauri Why two files autu.server1 and auto. server2 on the same main mount point and why two lines in auto.master for the same main mount point … combine the two files in one auto.server file with two lines and make the two lines in auto.master into just one line referencing auto.server then run sudo service autofs reload to read the new changes. – Raffa Jun 20 '22 at 04:55
  • This almost works, the only problem now, is that all my other mount points disappear under /mnt. I do get /mnt/server1 and /mnt/server2 as I want, however, I no longer have /mnt/tmp /mnt/sdc /mnt/loop. – AlphaCentauri Jun 22 '22 at 14:29
  • 1
    @AlphaCentauri You probably have them in separate files e.g. auto.tmp, auto.sdc and auto.loop ... You need to add their contents as separate lines beneath the already existing two lines in auto.server and remove the old references to those files in auto.master then reload the autofs service and then you'll have them back again. – Raffa Jun 22 '22 at 14:39
  • No those I mount manually when I (rarely) need them. – AlphaCentauri Jun 22 '22 at 15:55
  • 1
    @AlphaCentaur That wold cause conflicts… ether add them to autofs to be automatically mounted or create a separate mount point like mkdir ~/my_mnt to manually mount them under it … you can also choose to change autofs main mount-point instead from /mnt to a new mount point so you can manually mount under /mnt … either choices will work fine. – Raffa Jun 22 '22 at 16:38
  • So basically, if you intend to use autofs under a particular directory, like /mnt, then make sure nothing else uses /mnt. – AlphaCentauri Jun 23 '22 at 00:50
  • 1
    @AlphaCentauri Updated the answer for that one – Raffa Jun 23 '22 at 06:20