Add Samba Shares on Raspberry Pi OS
Before installing new software it is always good to make sure the system is up to date, for that follow the instructions in page Update Raspberry Pi OS System.
First you need to install the samba server packages:
$ sudo apt-get install samba samba-common-bin
Set a password for the Samba users, in this case user “pi” but you add any user you want:
$ sudo smbpasswd -a pi
Edit the Samba configuration file to add the directories to be shared:
$ sudo nano /etc/samba/smb.conf
Add the share information at the end of the file. You need to add one share section beginning with its name in square brackets [USBHDD1] for each share you wish to add:
[USBHDD1]
path = /media/USBHDD1
writable = yes
read only = no
public = no
create mask=0777
directory mask=0777
The create mask and directory mask are need to enable Windows users to read, write and execute files. The last step is to restart the Samba service:
$ sudo systemctl restart smbd
The share should be available in Windows at \\RASPBERRYPI\USBHDD1.