n this tutorial, we shall find step by step guide on setting up a “file sharing”/ “file server”/ NAS using samba.
For file sharing, we shall to CIFS/SMB also known as windows file sharing protocol implementation on Raspberry Pi.
Login to your Raspberry Pi console
If you haven’t done so, run the following to make your distribution up to date
Update and upgrade
sudo apt-get update
sudo apt-get upgrade -y
sudo apt-get install samba
sudo apt-get install samba-common-bin
We shall use the folder “/nas” in raspberry Pi we created from the
. We shall share “/nas” using SMB protocol. To do this, we shall need a samba account in our raspberry Pi. We shall use the user account “pi” in this case. you may use any other existing user of your choice. Enter the following command and type in a password to set the samba password for “ip” user :
sudo smbpasswd -a pi
once executed you shall be prompted as following:
New SMB password:
Retype new SMB password:
Added user pi
note down this new password, you shall be asked for it later on. Note: this password will not affect your login to Raspberry Pi over ssh.
Before we edit the samba configuration we shall create a backup file to recover from any unwanted changes
sudo cp /etc/samba/smb.conf /etc/samba/smb.conf.orig
Edit the /etc/samba/smb.conf file using nano by executing the following command
sudo nano /etc/samba/smb.conf
add the following section in to the smb.conf file
comment = Media share
path = /nas
force user = “root”
read only = no
guest ok = yes
public = yes
sudo /etc/init.d/samba restart
Client access to samba share
Check if samba service is enabled on startup, so that the service starts on reboot (usually it is)
sudo service --status-all | grep samba
This may take a few seconds, you shall expect an output such as
sudo service –status-all
The “[ + ]” indicates the service is active on startup
In case, the service name is followed by a “[ – ]” run the following commands to enable samba services on startup
sudo update-rc.d smbd defaults
This will enable samba on startup, which is set to by default.
Reboot and check client access
Client access to NAS
provided the raspberry pi is on the same network run the following in the “search program and files box” from your windows command prompt
or with ip address
search program and files box
When prompted for password, Enter user name “pi” and password you noted down earlier in this section then prompted for.
If you are a Linux user, this command should mount the NAS drive for you:
Enter user name “pi” and password you noted down earlier in this section then prompted for.
sudo mkdir /pishare
sudo smbmount -o username=pi,password=raspberry //ip.address.of.raspberry.pi/USB /pishare
on from google play store on your mobile
from the appliction go to options -> network -> search
you shall find the nas server and access files from it. for detailed how to follow this
Enter username “pi” and password you noted down earlier in this section then prompted for.
1. Update and upgrade the system
2. Install samba
3. Set samba password for the user “pi”
4. Edit /etc/samba/smb.conf to add a public share for the local network
5. Restart samba
6. Make sure samba service starts on reboot
7. Check clinet access on windows/mac/android etc.