From charlesreid1

automounting network shares via /etc/fstab

With the usual caveats to be careful editing the /etc/fstab file, as you can disable your ability to boot with a single typo...

fstab

Start with your existing /etc/fstab file. Here is a sample:

# root filesystem
UUID=9f60d333-5a92-4e27-a83a-52f4a033cebf       /                   ext4            errors=remount-ro           0 1
# swap
UUID=c9139e0a-19b0-4478-a86e-a5d0ee4f74a4       none                swap            sw                          0 0

adding nfs to fstab

Add the files to include the NFS share:

10.5.5.5:/share/documents /mnt/documents  nfs  users,rw,auto,nolock,x-systemd.automount,x-systemd.device-timeout=10 0 0

This accesses the NFS shares at the IP address 10.5.5.5, specifically the ones at /share/documents, and mounts them locally at /mnt/documents.

The various options do things like telling to keep the drive mounted if possible, not to wait longer than 10 seconds for the share if it is unavailable on the network, and end the line with 0 to indicate no consistency check is needed on boot. (systemd is required for the x-systemd.automount option to be understood).

adding samba to fstab

Samba shares can be added to /etc/fstab similarly:

//10.5.5.5/Documents  /samba  cifs  username=asdfasdfasdfasdf  0  0

manually mounting network shares

perhaps you don't want network shares to AUTOMATICALLY mount. in that case, you can add the noauto option, like this:

NFS

For NFS:

10.5.5.5:/share/documents /mnt/documents nfs users,rw,noauto,nolock,x-systemd.device-timout=10, 0 0 0

Now, if you want to mount your documents, you just run the command

$ mount /mnt/documents

which replaces the more awkward

$ mount -t nfs 10.5.5.5:/exports/documents /mnt/documents

Samba

for Samba:

//10.5.5.5/documents  /samba/documents  cifs  noauto,username=asdfasdfasdfasdf  0  0

Now you can type

$ mount /samba/documents


Related

Linux/Networking

Linux/File Server

Linux/SSH