Once you have all the necessary equipment, the Raspberry is running and you are connected in SSH, you can start by updating your Raspberry Pi.
sudo apt update
sudo apt upgrade
Once the updates are complete, create the folder that will be accessible on the samba server.
$> mkdir /home/pi/shares
So we will start by installing Samba on the Raspberry Pi with the following command.
$> sudo apt install samba samba-common-bin
After that, we will edit the configuration file.
$> sudo nano /etc/samba/smb.conf
In order to manage the private storage spaces, go now in the game [homes]. If you want to be able to write (send files) to your NAS, make sure that the file contains the following line.
read only = no
Close the file by saving it and restart samba
$> sudo /etc/init.d/samba restart
Now we will add a user to samba. In our example we will add the user pi.
$> sudo smbpasswd -a pi
Get the media name sda but this can change especially if you have several devices connected.
$> lsblk
NAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINT
sda 8:0 0 465.8G 0 disk
mmcblk0 179:0 0 14.9G 0 disk
├─mmcblk0p1 179:1 0 43.2M 0 part /boot
└─mmcblk0p2 179:2 0 14.8G 0 part /
Your device must be formatted with a Linux file system, such as ext3 or ext4. If it does not, you can format it by using the following command (replacing sda with the name of your device if it is different).
$> umount /dev/sda
$> sudo mkfs.ext4 /dev/sda
The name of the folder (shares in the example) does not matter, put the one you want to be able to find it easily on the network. Once done, mount the device in this folder.
$> sudo mount /dev/sda /home/pi/shares
At this stage of the installation, there is indeed a problem. When restarting the raspberry pi, peripherals do not necessarily mount. To correct this, edit the fstab file.
$> sudo nano /etc/fstab
Add at the bottom of the file the following line (being careful not to be mistaken about the name of the device and the directory in which it must be mounted).
/dev/sda /home/pi/shares auto noatime,nofail 0 0
Change the folder (shares) permission where the device will be mounted for access, read and write rights.
$> sudo chown -R pi:pi /home/pi/shares
To log in from Windows, go to the This PC window, click the Computer tab, and then click Map network drive.
The drive letter does not matter, but you need to know where the raspberry pi is on the network (IP).
In the exemple this is the path for the shares folder.
\\<ip_raspberry>\pi\shares
Add the credential for the pi user you added for the samba server.
Create a NAS with your Raspberry Pi and Samba
Learn how to use SSH to remote control your Raspberry Pi
How to List Unmounted partition of a harddisk and Mount them?