Skip to content

LocalServerSambaConfig

Luca Finzi Contini edited this page Jul 26, 2024 · 8 revisions

Samba Configuration on the Local Server

You will want to access your local nas server easily via Samba from your home Windows PCs or whatever. Here is how to configure it as an example.

Example Samba Configuration

Edit your /etc/samba/smb.conf file as follows:

[global]
workgroup = WORKGROUP
# workgroup
local master = yes
preferred master = yes
domain master = yes
# /workgroup
netbios name = NAS
wins support = 1
log level = 1
max log size = 1000
read only = no
server string = %h, the nicest ZFS-based server ever
security = USER
smb passwd file = /etc/samba/smbpasswd
encrypt passwords = YES
max protocol = SMB3
min protocol = SMB2

min receivefile size = 16384
getwd cache = true

use sendfile = yes

[Documents]
comment = ZFS raidz disks vdev Documents folder
path=/mnt/raid/Documents
valid users = user
read only = no
vfs objects = shadow_copy2
shadow:localtime = yes
shadow:format = %Y.%m.%d-%H.%M.%S
shadow:sort = desc
shadow:basedir = /mnt/raid/Documents
shadow:snapdir = /mnt/raid/Documents/.zfs/snapshot

Restart Samba services to make it available:

sudo systemctl restart smbd
sudo systemctl restart nmbd

Here we will use the simplest way to access Samba, which is creating a user with smbpasswd and assigning a password to it; more compelx security configuration is outside the purpose of this document. Let's create the user user also within samba with a password of your choice:

user@nas:/etc/samba$ sudo smbpasswd -a user
New SMB password:
Retype new SMB password:
Added user user.

Let's check that we are able to access it on Windows:

  • open your Windows Explorer and point to \\nas
  • A popup shall open to ask you for username and password; enter the username and password just supplied to smbpasswd
  • you will then be presented with the new Samba share Documents:

NAS new share 'Documents'

  • Copy some documents on your brand new share drive from your PC:

NAS new share with some files

All of this is pretty awesome, isn't it?

Simpler scenario with no backup server

This scenario allows for some user (Thanks, Francesco!) to just use the system even without having a remote server, if they wish.

One could simply set up a nas machine and have it hold their precious files and perform snapshots as desired, keeping that old version of that script you desperately need but you deleted in some distant past... and you just do not think you need backups (are you really sure about that?!).

On with the instructions

Let's proceed with normal, backup-aware installation, by performing our first backup!

Clone this wiki locally