EMZETT.
Login

Samba and NFS: Sharing files on the network

In short: Samba provides Linux folders as Windows shares (SMB), NFS mounts folders between Linux/Unix systems; both belong in a trusted home network, not on the internet.

In more detail: Two protocols share files on the LAN: SMB/CIFS (Windows, macOS, Linux, Samba) and NFS (Unix/Linux). For NAS and home servers they are standard.

In Depth

Samba (SMB)

# /etc/samba/smb.conf
[global]
   workgroup = WORKGROUP
   server min protocol = SMB2
   map to guest = never
[data]
   path = /srv/data
   valid users = mia
   read only = no
   create mask = 0660
   directory mask = 0770
sudo smbpasswd -a mia      # Samba user (separate password)
sudo systemctl restart smbd nmbd
testparm

Access: Windows \\server\data, Linux mount -t cifs //server/data /mnt -o username=mia, macOS “Connect to Server”. Use SMB 2/3, no SMB1 (insecure), no guest unless necessary. Firewall: open port 445 only on the LAN.

NFS

# /etc/exports (server)
/srv/data  192.168.1.0/24(rw,sync,no_subtree_check)
sudo exportfs -ra
# client
sudo mount -t nfs server:/srv/data /mnt/data
# permanently in /etc/fstab: server:/srv/data /mnt/data nfs defaults,_netdev 0 0

NFS (v4) is fast and simple, by default uses IP/UID-based trust rules (Kerberos possible). Only in a sealed-off network; UID/GID must match between client and server (root_squash).

Comparison and notes

  • SMB: Windows compatibility, user login, recycle bin/versions (shadow copies), printers.
  • NFS: Unix permissions, low load, good for server-to-server.
  • Permissions twice: file-system permissions and share permissions.
  • Performance: gigabit LAN ≈ 110 MB/s; Wi-Fi slower. SMB multichannel possible.
  • Security: updates, weak passwords, open shares (ransomware also encrypts network drives → backups/snapshots offline).
  • Alternatives: Nextcloud, SFTP/rsync, WebDAV, Syncthing.

Troubleshooting

smbclient -L server, showmount -e server, logs (/var/log/samba), check name resolution/IP, permissions (ls -l), SELinux (setsebool -P samba_enable_home_dirs on), firewall, time (with Kerberos). Delete entries in the Windows credential manager if old passwords stick.

See also: NAS server, Firewall on Linux, Backup strategy, Homelab and self-hosting