NAS setup with Samba
Introduction
Section titled “Introduction”Samba is an implementation of SMB (Server Message Block) protocol. It allows Linux machines to integrate Microsoft’s active directory.
CIFS (Common Internet File System) is an implementation of the SMB protocol. CIFs or SMB is used interchangeably nowadays, but most people will use the term SMB. By using Samba on the Raspberry Pi, you can easily share directories in a way that they can be accessed on almost every operating system.
Samba Installation & Setup
Section titled “Samba Installation & Setup”Install the following apt libraries:
sudo apt install samba samba-common-binCreate a directory to share:
mkdir ~/sharedYou could also attach an external diver to the Raspberry Pi, and point Samba to that drive.
Then edit smb.conf file:
sudo nano /etc/samba/smb.confAdd this at the bottom of the file:
[myshared]path = /home/pit/sharedwriteable = yesbrowseable = yespublic = noLet’s analyze the content of the configuration:
[myshared]: this block defines the start of a new Samba share. The text between the square brackets ([...]) is the name that will be assigned to your share. You should access this by going to:\\192.168.xxx.xxx\myshare.pathuse this option to specify the path of the directory you want to share using Samba on your Raspberry Pi.writeable: when the option is set toyes, it will allow the folder to be writable. If you want to block users from being able to write to this share, set this tono.browseable: allows you to control whether this share will be viewable by others on your network. Setting this option toyeswill allow others to find this share on your network. By setting this option tono, you will be required to enter the share path to connect to it.public: if this is set tono, the Pi will require a connection to have a valid user to access the Samba share.
Next, set up a user for your Samba share on the Raspberry Pi. Without it, we won’t be able to make a connection to the shared network drive.
To assign a Samba password to your user, you need to utilize the smbpassword tool.
Use the command below to set a password for your current user:
sudo smbpasswd -a $(echo $USER)It will prompt you to enter the password.
Restarting Samba on your Raspberry Pi:
sudo systemctl restart smbdNAS as Network Unit in Windows
Section titled “NAS as Network Unit in Windows”To connect to your Samba on Windows, open File Explorer. Click the Computer tab, then click Map network drive.
Within the Folder textbox, enter the following \\192.168.xxx.xxx\myshare.
Replace 192.168.xxx.xxx with the actual address of the Raspberry Pi.
Once done, click the Finish button to finalize the connection.
Eventually, you will be asked to enter your login details to be able to finish the connection.
Enter the username and password you set using the smbpasswd tool earlier on in the tutorial.
Once done, click the OK button to continue.
That’s it! You’re now connected to your Raspberry Pi-powered NAS.
Conclusion
Section titled “Conclusion”Links used: