1

I am planning to build a small computation cluster at home. I need share /usr/local and /opt directory on server machine to several computation nodes. There are compiled computation programs and library files in these directories. I hope through sharing (mounted by computation nodes), all nodes can run these programs.

My question is, can autofs be used for this purpose? I was told that with autofs the shared directories are only available when it is requested. So if a shared library file is needed for a program on the fly, will it be a problem?

update:

I have NFS installed. Tried fstab but no luck.

1) ip:/usr/local /usr/local nfs rw,defaults 0 0 result: not mounted when the machine boots. However, it can be mounted correctly if I run "mount -a" using root account after the client machine started.

2) adding "_netdev" option did not make a difference;

3) adding "x-systemd.automount" option had a bad result: the machine cannot boot into OS (which is debian 9) from reboot: ip:/usr/local /usr/local nfs rw,auto,x-systemd.automount 0 0

After reading your suggestion, I tried "noauto", and it did not make a difference that the machine still cannot boot into os: ip:/usr/local /usr/local nfs rw,noauto,x-systemd.automount 0 0

I am using Debian 9 and it has systemd 232.

Any thought? Thanks.

closed as primarily opinion-based by Jeff Schaller, user88036, Romeo Ninov, JigglyNaga, Shadur Oct 17 '18 at 14:04

Many good questions generate some degree of opinion based on expert experience, but answers to this question will tend to be almost entirely based on opinions, rather than facts, references, or specific expertise. If this question can be reworded to fit the rules in the help center, please edit the question.

  • 1
    Autofs mounts a filesystem when a file on that filesystem is requested. It doesn't matter whether it's a library, an executable, or even a picture of a cat. – roaima Oct 17 '18 at 12:31
  • Please post more details, such as output of systemctl status usr-local.automount. Even output of mount (the relevant parts for the NFS mounts) would be useful. Also look at journalctl -b and see if you spot any helpful lines. You can also look at the logs of previous boots (without -b or using -b -1, -b -2 etc.) – filbranden Oct 18 '18 at 14:35
0

Yes, autofs (also known as "automount") is appropriate for this scenario where you want to share directories such as /usr/local and /opt between multiple compute nodes.

You also need a protocol for remote filesystem access from a server or distributed system, of which NFS is perhaps the simpler choice but there are many others. Autofs can help you with mounting these shares on your nodes.

If you're using a Linux distribution that uses systemd (which I'd say is likely the case), you can use systemd automount units to configure automount (= autofs) for the mounts of /usr/local and /opt, which you can actually configure from /etc/fstab directly.

For example, if you have an NFS server "fserv1" and are using these two read-only mounts from it:

# entries in /etc/fstab for shared directories:
fserv1:/export/usr_local  /usr/local  nfs  ro  0 0
fserv1:/export/opt        /opt        nfs  ro  0 0

You can then configure systemd to automount them by adding noauto,x-systemd.automount to the mount options, like so:

# entries in /etc/fstab for shared directories:
fserv1:/export/usr_local  /usr/local  nfs  ro,noauto,x-systemd.automount  0 0
fserv1:/export/opt        /opt        nfs  ro,noauto,x-systemd.automount  0 0

See this article in Arch Linux wiki for more details on configuring systemd to automount the directories. (None of it is specific to Arch Linux, their wiki is just a very good source for Linux documentation in general.)

Regarding your question about using shared libraries counting as access to trigger automount, yes that will work as expected. The autofs system is implemented inside the Linux kernel, so any access to any file under that directory will trigger the mount and only proceed with the file access once the mount has completed. Running a binary or loading a shared library are both normal file accesses that will trigger an automount as expected.

As mentioned, you still need to use a remote filesystem protocol such as NFS, so just mounting those at boot directly (skipping autofs altogether) is definitely an option... The main advantages of using autofs/automount are that booting the machine will not block until the mounts are ready, or fail if the mounts are unavailable (for example, if the server is down or the network is having an outage) and also autofs/automount will potentially retry mounting a filesystem that was previously unavailable, potentially improving reliability of the system.

  • I actually have NFS installed. Tried fstab but no luck. 1) ip:/usr/local /usr/local nfs rw,defaults 0 0 result: not mounted when the machine boots. However, it can be mounted correctly if I run "mount -a" using root account after the client machine started. 2) adding "_netdev" option did not make a difference; 3) adding "x-systemd.automount" option had a bad result: the machine cannot boot into OS (which is debian 9) from reboot: ip:/usr/local /usr/local nfs rw,auto,x-systemd.automount 0 0 – michael morgan Oct 17 '18 at 19:29
  • After reading your suggestion, I tried "noauto", and it did not make a difference that the machine still cannot boot into os: ip:/usr/local /usr/local nfs rw,noauto,x-systemd.automount 0 0 Any thought? Thanks. – michael morgan Oct 17 '18 at 19:29
  • @michaelmorgan Please update your question (instead of adding comments), describe what you tried, what worked and what doesn't. Can you mount the NFS shares with the system up? If so, what does the output of mount look like? What happens when you add the systemd flags to fstab? What does systemctl status usr-local.mount say? How about systemctl status usr-local.automount? What Linux distribution are you using and what version of systemd do you have? Do you see anything relevant in the logs? Check journalctl -b for logs simce last reboot... – filbranden Oct 18 '18 at 1:58

Not the answer you're looking for? Browse other questions tagged or ask your own question.