HTGWA: Create a Samba (SMB) share on a Raspberry Pi

This is a simple guide, part of a series I'll call 'How-To Guide Without Ads'. In it, I'm going to document how I create Samba (SMB) shares in Linux on a Raspberry Pi.

Install Samba

This is important, for obvious reasons:

$ sudo apt install -y samba samba-common-bin

Create a shared directory

$ sudo mkdir /mnt/mydrive/shared
$ sudo chmod -R 777 /mnt/mydrive/shared

I won't deal with permissions in this post; read the Samba docs for that.

Configure Samba to share that directory

Edit the Samba config file with sudo nano /etc/samba/smb.conf, and add the following:

[shared]
path=/mnt/mydrive/shared
writeable=Yes
create mask=0777
directory mask=0777
public=no

Restart Samba so the new shared directory is available:

$ sudo systemctl restart smbd

Create a password for Samba access

The user must already exist on the system; in this example, I'll use the default pi user:

$ sudo smbpasswd -a pi
<enter password as prompted>
Added user pi.

Connect to the share

From another computer, access: smb://[hostname-or-ip-of-pi]/, and enter the username and password you just configured.

Comments

Hi Jeff,
with kernel 5.15 there is the new SMB V3 in-kernel server. Expectation is a performance improvement. Would it be worthwhile to try this out for your "Fastest NAS on Pi" project?

For posterity, Windows computers will have a much easier time accessing the samba share if you also install WSDD from https://github.com/christgau/wsdd

Since SMB 1.0 deprication on Windows 10, auto-discovery of Raspi systems wasn't working very well for me until I found this solution.