Ordinarily I use “static” references in /etc/fstab to mount NFS shares to a server. Doing this on a Rocks Cluster however is a bit “hacky” and adapting every node can be automated by using rocks run host however there is a alternative way. (not sure if its better 😉 ) but Rocks uses Autofs to load NFS mounts when they are required. So I felt brave and wanted to learn something new. This is the documentation on that journey.  

Add key map to auto.master

In order to make a new “mapping file” we need to add a directory to the server where AutoFS will be boss, note that it cannot be root (/). So in /etc/auto I added :

# ghost creates empty dir
/storage /etc/auto.mounts --ghost --timeout=1200

Interesting to note here is –ghost is creating the directory’s if it fails to mount. In Rocks this is the default file :

# cat /etc/auto.master
/share /etc/auto.share --timeout=1200
/home  /etc/auto.home  --timeout=1200

So homes are automatically mounted when a user runs a job.

Create the mapping file

Now we need to make a “key” based mount files; Since in last step I added /etc/auto.mounts, that is the name of the file, I don’t know if  auto.* is a requirement, but I think its a good way, since they are located in /etc as loose files.

To add a NFS share, the template is :

on_server_dir -nfs_options server:/share

So a pretty simple example would be :

data  -rw,hard,intr,rsize=32768,wsize=32768,nfsvers=3 svennd.be/data

However, if you like me export multiple shares from one server, and you want them in a separate directory, the template is :

on_server_dir -nfs_options /subdir server:/share /subdir2 server:/share2 /subdir3 server2:/share

Useful to know is that lines can be split using “\” however make sure nothing is after this backslash, otherwise you will have errors. Talking about errors, debugging AutoFS can be done by stopping the service and manually run the AutoFS daemon :

# stop the service
service autofs stop

# run service manually and verbose
automount -f -v
Push to the nodes

Since I don’t want to make all the changes to the nodes manually we need to run :

rocks sync users

This will sync all the auto.master and some other files, sadly it does not pick up auto.mounts; So that we have to do manually :

/opt/rocks/sbin/411put /etc/auto.mounts

This will push the /etc/auto.mounts file to all nodes. After that we can just restart the server (reload won’t work)

rocks run host "service autofs restart"

And voila it works 🙂

Resources :