A Raspberry Pi is an inexpensive computer that runs Linux. You can use it to run programs or play games. This article shows how to set up a Raspberry Pi as a file server that you can see on your Windows computer.
What Is Samba?
Samba is an open source software program that allows you to share files across networks. You can use Samba to transfer files between two or more computers connected to the same network. You could also use Samba so users can access each other’s home directories.
This tutorial assumes that you’ll be using a keyboard, mouse, monitor, and file server to set up your file system. You can alternatively enable SSH and log into your file server remotely from another computer on the same local network.
We also expect you’re using a 32 GB or smaller microSD card, which provides enough storage space without requiring any additional steps to make it available. However, if you want more storage space, it’s easy to attach an external USB drive and add a Samba share for it.
We recommend using a wired Ethernet cable for stability and fast transfer rates. The project will still function even if you use a wireless connection, but performance will be affected.
How To Set Up Samba On Linux
Samba is available in Raspian’s standard software repositories. Our operating system is fully updated. We’ll use apt-get to install Samba. First we need to open up a terminal window and type:
sudo apt update.
Then we’ll run the command:
sudo apt upgrade. Finally we’ll use the command:
sudo apt install samba samba-common-bin.
Now we’ve installed Samba, let’s create our shared folder. Type:
Now that Samba has been installed, and the folder that we wish to share has been created,it is time to edit some configuration files. First, we need to find the location of the config directory.
In order to do this, we first need to know what share group we are going to be working with. We can figure this out by looking at /etc/samba/smb.conf. If we look at the bottom of the file, we can see that there is a line like this:
guest ok yes
read only no
create mask 0600
directory mask 0700
force create mode 0660
force directory mode 0770
If you’re not familiar with Samba terminology, here’s a quick explanation. Path specifies where the shared folders are located. Browsable allows people to view them from other computers. Writable allows people to write to them. Guest ok lets people who aren’t logged in as root access the shares. Read only prevents anyone but root from writing to the shares.
Create mask tells Samba which permissions to apply when creating directories. Directory mask tells Samba which permission to apply when creating subdirectories. Force creates directories with specific permissions. Force directory creates subdirectories with specific permissions.
The last two lines above tell us that we want to place all of our shared folders under /home/pi/shared.
So now that we know where the config directory is, we can change its permissions. Let’s go ahead and make sure that we have write access to it.
sudo chmod 777 -R /etc/samba
We don’t want everyone to be able to access the config directory. Instead, we just want to give ourselves and the sudo user write access. To do this, we’ll add our username to the list of those allowed to modify the contents of the config directory.
sudo chown -R $USER:$USER /etc/samba/$USER
Let’s test if everything worked by running ls. If we did everything correctly, we should see something like this: drwxrwsr-x 10 root smbd 4096 Oct 6 17:30 /etc/samba.$USER
After changing the permissions, we need to restart the Samba service so that they take effect.
sudo service smbd restart
Now that Samba is configured, we can move on to setting up Windows networking.
Configure Windows Networking
First, we need to download and install the necessary software. On a Windows machine, we would open the Control Panel and click on “Network and Internet”. Then we would select “Windows Firewall” and then “Turn Windows Firewall off or on”. Next, we would click on “Properties”, then “Internet Options”, and finally “Connections Tab”.
Here, we would check the box next to “Automatically detect settings” and then click “Apply”. Now, we need to set up the IP address for the Raspberry Pi. You can either use DHCP (automatic) or static IP addresses. For simplicity, let’s assume that we will be using DHCP. To do this, follow these steps:
1. This will bring up an interface that looks similar to this:
Click on “Use a different DNS server” and enter 18.104.22.168.
2. Select “Obtain an IP Address automatically” and press OK.
3. Press Apply.
4. Wait until your Raspberry Pi has successfully connected to the internet.
5. The default port number is 8080, but you can change it if you want.
6. You should now be able to visit the Raspberry Pi through any computer on your local area network.
Find Your Pi On The Network
You will see a Raspberry Pi file server named Raspberry Pi. This is the default name given to the Raspberry Pi when you first install it. If you need to find out what the IP address of your Raspberry Pi is, you can use this command in the terminal on the Pi:
This will give you the IP address of your Raspberry Pi, if that’s how you want to connect to it.
To find your Pi’s IP address from Windows, press the Windows button and type cmd. Press enter. This opens the command prompt.
We’ll use the nslookup command for this task.
You’ll need to know the name that your Raspberry Pi has on the network. For example, if it’s called Raspberry Pi, then the command we’d enter would be:
nslookup Raspberry Pi
Pros And Cons Of Samba
- The limitations you will encounter will likely be the technical difficulties of the skills and knowledge that you have.
- It’s fun to tinker with open source stuff.
- The folks on the mailing list are generally nice and helpful.
- The examples on the Samba Wiki are good.
- Kerberos is one of the most important parts of Active Directory but luckily it is seamlessly integrated into SAMBA.
- Samba works well in large environments.
- Lack of manufacturer support.
- Active Directory support is lacking in many areas.
- Active Directory administrative center doesn’t work with Samba.
- File replication isn’t automatic.
Tips / Things To Check – How To See Raspberry Pi On Windows Network
Make sure that both systems are connected to the same network. Make certain that the Samba daemon isn’t blocked by a firewall on either system.
Check that you don’t have a firewall blocking connectivity from your Raspberry Pi to your Windows machine. This may be a firewall on the windows host, on the Raspberry Pi, or on the network.
You may also need to check that you’re running the latest version of Raspbian or the latest version of whatever distribution you’re using. On your Windows machine, make sure that network discovery is enabled.
That’s it! You can navigate the Raspberry Pi file systems through your standard machine’s file navigation systems. This makes it so easy to use. Hopefully this tutorial has helped you!