While building my new NAS, I came across the question how to install a fileserver based on Samba on FreeBSD. Here’s how…
Kernel options tuning
First, let’s tune some kernel settings to optimize handling of many files. Edit
/etc/sysctl.conf and add the following
kern.maxfiles=25600 kern.maxfilesperproc=16384 net.inet.tcp.sendspace=65536 net.inet.tcp.recvspace=65536
Also, we should enable asynchronous I/O. This can be accomplished by adding the following line to the file
To get it working without restarting, additionally execute the following command:
Then we can install Samba. I’m using prebuilt binaries, so we’re using
pkg install samba41
Sadly, the package does not provide a default configuration file, so running
testparm, which is Samba’s config test
tool results in an error stating that the configuration file does not exist.
So we need to create a file called
/usr/local/etc/smb4.conf. Here’s mine, just change it to match your needs:
[global] workgroup = MYGROUP realm = mygroup.local netbios name = NAS [davd data] path = /home/davd public = no writable = yes printable = no guest ok = no valid users = davd
Then just enable Samba and start it:
sysrc samba_server_enable=YES service samba_server start
Now that the server is running, you can’t still access your files because you got no credentials to log in with. By default
Samba relies on system users, so after you created your system user using
adduser, enable it for Samba:
pdbedit -a -u davd
You are prompted to enter a password which will be used to authenticate against Samba.
I run this site without advertisement of any kind. All information is free and my only goal is to give back something to the amazing free software development community. If you find some value in this, please consider donating me a cup of coffee using PayPal. Thank you so much!