Skip to content

Instantly share code, notes, and snippets.

@BlackMaria
Last active December 17, 2015 02:59
Show Gist options
  • Save BlackMaria/5540227 to your computer and use it in GitHub Desktop.
Save BlackMaria/5540227 to your computer and use it in GitHub Desktop.
Here is a quick script to get you started using AutoFS, with some minor explanation.
#!/bin/sh
#
#
# The following will Install autofs and create an AutoFS config that
# will mount SERVER:/EXPORT on MOUNT_POINT/$MOUNTNAME
#
# OPTION:
# You can also add all subdirs of a mount by adding a trailing "&"
# The following will mount each dir under /nfs/disks/ discreetly
# disks -rw server:/nfs/disks/&
#
# ls $MOUNT_POINT/disks/$SOME_SUB_DIR
#
$(yum -y install autofs ) || $(apt-get install autofs )
MOUNT_POINT=/nfs_disks
EXPORT=/install
# nota bene: if using IB or other you must specify the correct address for that medium!
SERVER=xcat-01
MOUNTNAME=xcat_install
cat <<EOF >>/etc/auto.master
#base mount point config file global arguments for file
$MOUNT_POINT /etc/AutoFS/${SERVER}.cf -fstype=nfs,hard,intr,nodev
EOF
mkdir -p /etc/AutoFS
cat <<EOF >/etc/AutoFS/${SERVER}.cf
$MOUNTNAME -rw ${SERVER}:/${EXPORT}
# $MOUNTNAME -ro ${SERVER}:/${EXPORT}
EOF
service autofs restart
ls -l $MOUNT_POINT/$MOUNTNAME
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment