Thursday, August 5, 2010

How not to mount a particular server with autofs

There are a couple servers that I use the fancy new (to me at least) autofs scripts to mount on my Ubuntu 9.10 client machine. You know, the ones that let you just cd /net/servername/exportname and it automagically turns that into the command to mount that export from that server at that mountpoint (so cool). To test something out though, I wanted to make sure one of the servers was not auto-mounted by autofs. The simple way to tell autofs to ignore that server (let's call it, foobarbaz) is to edit /etc/ and put this snippet right after the key="$1" line:

# don't mount foobarbaz, for now:
if [ $key = "foobarbaz" ]; then

Then restart autofs:

sudo /etc/init.d/autofs restart

And autofs automagically mounts any nfs server except foobarbaz.


mtk said...

except i think the recent releases of autofs have migrated the '/net' map from /etc/ into something that runs directly in the automount process (the "-hosts" map).

Bryan said...

Hmm, good point, mtk. I should point out that this was on my Ubuntu 9.10 system. I suppose I should upgrade to 10.04 before 10.10 comes out :-)