Linux mount remote filesystems automatically at boot time

Now you know how to mount a NFS or Windows/Samba remote file system. It is time to mount remote filesystems automatically at boot time using /etc/fstab (another possibility is mount local and remote file system on demand using autofs service).

ADVERTISEMENTS

Mount Remote NFS File system

The file /etc/fstab – stores static information about the filesystems. It contains descriptive information about the various file systems. fstab is only read by programs, and not written; it is the duty of the system administrator to properly create and maintain this file. Each filesystem is described on a separate line; fields on each line are separated by tabs or spaces. Lines starting with ‘#’ are comments. Use following syntax to mount NFS fs:
{NFSServer}:{/remote/path/2/export} {/mnt/nfs} nfs {NFS-Options} 0 0

For example:
# mkdir /mnt/sales
# vi /etc/fstab

Append following line:
nfsserver.nixcraft.in:/data/sales /mnt/sales nfs defaults 0 0

Save and close the file.

Where,

  • nfsserver.nixcraft.in: Remote NFS server name (you can use IP address or FQDN)
  • /data/sales: Remote shared (exported) directory
  • /mnt/sales: Local mount point
  • nfs: File system type

You can specify comma separated list of NFS options as described in mount and fstab man pages. For example:
nfsserver.nixcraft.in:/data/sales /mnt/sales nfs nocto, rsize=32768,wsize=32768 0 0

Mount Remote Windows server /Samba (CIFS) File system

Please refer earlier article.

🐧 If you liked this page, please support my work on Patreon or with a donation.
🐧 Get the latest tutorials on SysAdmin, Linux/Unix, Open Source & DevOps topics via:
CategoryList of Unix and Linux commands
File Managementcat
FirewallAlpine Awall CentOS 8 OpenSUSE RHEL 8 Ubuntu 16.04 Ubuntu 18.04 Ubuntu 20.04
Network Utilitiesdig 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 jobs killall kill pidof pstree pwdx time
Searchinggrep 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

ADVERTISEMENTS
1 comment… add one
  • Czar Oct 3, 2006 @ 12:49

    In this brief blog entry I will note the steps it took for me to use the Network File System (NFS) protocol to share files between another Linux computer.

Leave a Reply

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

Use HTML <pre>...</pre>, <code>...</code> and <kbd>...</kbd> for code samples.