Setting up an NFS client with autofs

My previous post was on setting up an NFS server.  In this one, I will describe how I setup an NFS client.

My first decision was to use “autofs” (the automounter).  With “autofs”, the NFS network share is not mounted until there is an attempt to access it.

Without autofs, you can get into a situation where you cannot boot the client computer unless the NFS server is running.  So I prefer auto-mounting to avoid that kind of difficulty.


Everything that I needed seemed to be already installed on opensuse.  That included the packages for NFS client, the yast configuration of NFS client and the autofs.  I never actually used the yast NFS client configuration, since I was doing it with autofs.


The automounting uses files with names of the form “auto.*” in “/etc”.  The primary file for this is “auto.master”.

I added a line

/nfsmounts       /etc/auto.nfs

to the “auto.master” file.  That tells the automounter that it should consult the file “auto.nfs” to find what to mount on the directory “/nfsmounts”.

Note that I did not create a directory “/nfsmounts”.  That’s a virtual directory created by the automounter.

Next, I created the file “auto.nfs” containing the line:

shared -fstype=nfs homebase:/shared

That tells the outmounter that the nfs file system from machine “homebase” and path “/shared” should be mounted as directory “shared” under “/nfsmounts”.

My server machine name is not actually “homebase”.  That’s an alias that I decided to use.  So I next added an entry to “/etc/hosts” giving the IP address of my server a hostname of “homebase”.  The idea here, is that I might want to move the NFS server to a different machine.  To do that, I need only change that alias IP.  I won’t have to rename the machines.

Starting the service

The final step was to start the automounter service.  For that, I started Yast –> System –> Services Manager.  That gave me a list of services.  I needed to make sure that both “rpcbind” and “autofs” were running.  So, for each of those, I selected that line.  And then I set it to be active (click the “Start/Stop” button to toggle the active status), and to be enabled (click the “Enable/Disable” button to toggle the enabled status.

And a note here.  “Active” means that the service is running in this session.  “Enabled” means that it will be automatically started on future system startup.

Finally, I clicked “OK”.

And then I tried

ls /nfsmounts/shared

to check whether it was all working (it was).

Note that instead of using Yast services manager, I could have done that at the command line with:

# systemctl enable rpcbind.service
# systemctl start rpcbind.service
# systemctl enable autofs.service
# systemctl start autofs.service

An extra step

As an optional extra step, I did

# cd /
# ln -s nfsmounts/shared shared

This allows me to access the NFS shared files at “/shared” instead of at “/nfsmounts/shared”.  However, if I ever want to manually unmount, I’ll have to use the “/nfsmounts/shared” path name.



About Neil Rickert

Mathematician and computer scientist who dabbles in cognitive science.

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: