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...


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: /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, 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:

//  /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:


For NFS: /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 /mnt/documents


for Samba:

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

Now you can type

$ mount /samba/documents



Linux/File Server