Automount listing

At work we have a slew of directories automounted.  Te problem is that unless you know the name of a subdir under the mount point, you can’t navigate to it.  Since we use nis to list the mount points, you can’t even find a local list to see what is automounted.  However, the init script for autofs shows the way to get the listing.  It is a two step process.  First, use ypcat -k auto.master to see the list of top level mount points.  For each entry there that has a yp: in it, run another ypcat -k to see the actual top level directories:

Here it is in bash:

#!/bin/sh

for MOUNT in `ypcat -k auto.master \
| grep yp | awk ‘{gsub(“yp:”,””,$2) ; print $1 “:” $2  }’`
do
MDIR=`echo $MOUNT | cut -d ‘:’ -f 1`
YPNAME=`echo $MOUNT | cut -d ‘:’ -f 2`
ypcat -k $YPNAME | cut -d ‘ ‘ -f1 | sed “s!^!$MDIR/!”
done

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.