How do I access NAS server using automount?

Network-attached storage commonly used to store backup and other shared files over TCP/IP network. For example:

i) Corporate e-mail system with multiple, load-balanced webmail servers
ii) Load-balanced web servers access the same contents from NAS storage
iii) Backup files or dumps to NAS storage from all other servers using FTP/NFS/CIFS.

Autofs is a automounter for Linux. It allows:

a) Mount your directory on demand i.e. when you type command cd /backup it will mount NAS server share.
b) Useful to transparently mount your backup directory as you need it
c) Mail or web server can use to store mails/files
d) Compare files on the different servers (snapshots)
e) Give user a common home directory server for all users to login and be authenticated and able to work from and workstation using any server in the network.
f) Reliability – Increase the reliability of your LAN by removing the dependecies on a single server etc

Assuming that:

  • NAS Server IP: / (FQDN)
  • NAS CIFS username: nixcraft
  • NAS CIFS password: mySecret
  • NAS CIFS sharename: :// or ://

Make sure you have autofs installed. Now you will need to configure your filesystem to mount automatically. Edit file /etc/auto.master using vi text editor:

# mkdir /backup
# vi /etc/auto.master

Append following line:

/backup /etc/auto.backup

Save the file and open /etc/auto.backup file:

# vi /etc/auto.backup

Append following line /etc/auto.backup:

smb -fstype=smbfs,username=nixcraft,password=mySecret ://

Save the file. Restart autofs:

# /etc/init.d/autofs restart

Make sure that autofs is starting on boot (after reboot). If you are using RedHat/Fedora Linux:

# chkconfig autofs on

If you are using other Linux distribution use old good soft link method:

# ln -s /etc/init.d/autofs /etc/rc2.d/S80autofs
# ln -s /etc/init.d/autofs /etc/rc2.d/K80autofs

🐧 Get the latest tutorials on Linux, Open Source & DevOps via RSS feed or Weekly email newsletter.

🐧 1 comment so far... add one

CategoryList of Unix and Linux commands
Disk space analyzersdf duf ncdu pydf
File Managementcat cp mkdir tree
FirewallAlpine Awall CentOS 8 OpenSUSE RHEL 8 Ubuntu 16.04 Ubuntu 18.04 Ubuntu 20.04
Modern utilitiesbat exa
Network UtilitiesNetHogs dig host ip nmap
OpenVPNCentOS 7 CentOS 8 Debian 10 Debian 8/9 Ubuntu 18.04 Ubuntu 20.04
Package Managerapk apt
Processes Managementbg chroot cron disown fg glances gtop jobs killall kill pidof pstree pwdx time vtop
Searchingag grep whereis which
User Informationgroups id lastcomm last lid/libuser-lid logname members users whoami who w
WireGuard VPNAlpine CentOS 8 Debian 10 Firewall Ubuntu 20.04
1 comment… add one
  • Jesus Guevara Jan 11, 2021 @ 15:24

    Hi, thank you for write this article. I suggest please explain how configure autofs in smart way (characters substitution) with * and & (Ubuntu Autofs Wiki), for this scenary:
    One Laptop (Client) and Two Home Servers Server01 and Server02 multiple samba shares (public, user01, user02, user03 directories) and same samba users (guest, user01,user03,user03). Same usernames and samba shares for both serves.
    Wish you can write about this.
    I suggest “Browse Mode = yes” or maybe –ghosht options.

Leave a Reply

Your email address will not be published.

Use HTML <pre>...</pre> for code samples. Still have questions? Post it on our forum