Using AutoFS utility on Debian

February 18, 2025

AutoFS is a nice little utility for managing automounting of network (and local) storage in Linux. The syntax and the amount of "--" needed in config files is tricky. This post captures the basics of my working configuration, auto-mounting Samba network shares on Linux.

I'm using Debian, to setup autofs for mounting network shares, two packages are needed. Server, folder names and the text between {}, those should be your own.

apt-get install autofs cifs-utils

Next, in the /etc/auto.master at the bottom add

/opt/{your-share-folder} /etc/auto.cifs --timeout=60 --ghost

Then create the above mentioned file /etc/auto.cifs with chmod 600 and following content

{share-sub-folder} -fstype=cifs,rw,username={username},password={password},uid={username},gid={username} ://{samba-server}/{samba-share}
Additional network shares can be listed per line in the same /etc/auto.cifs file.

To test, use automount -f -v command, the Samba shared folder should be mounted under /opt/{your-share-folder}/{share-sub-folder}

Then use systemd to auto run it
systemctl enable autofs
systemctl start autofs