The Raspberry Pi is one of the most versatile and useful machines out there sporting a 4 core processor allowing us to
do some amazing things with a very small box. You can install many operating systems on the Pi, but the recommended one
is Raspbian, a derivative of Debian Linux. Linux and Windows are two completely different things. There are many good
things to say about each. One of the things that occurs to me in using Linux is that it came from a totally different
philosophy. The graphical user interface is an afterthought. The command line is really the most efficient way to
configure your Pi. This brings us to the reason why Mark and I want to provide you with this document. How much time
do you have to invest in learning Linux? Our estimation is, you would rather spend your time with your Pi projects and
let the Linux gurus handle the heavy lifting.
We started with Samba for a reason. I typed "samba" at the Pi's command prompt and a date appeared. The last revision
date for the very latest Raspbian distribution dated July 7, 2017 had a Samba distribution of 2014. This means that
the Raspbian Apt-Get system is sending you a Samba release that is 3 years old. Meanwhile, the guys over at Samba have
put out 16 releases since then. So I asked in the Pi Forums about it and the usual "You DARE to insult our fearless
leaders" responses ensued, but the truth is, they really didn't have a good response. I am sure the people responsible
are doing their level best to get the latest and greatest out there for its customers. Wait! NO, this is the entire
file and printer sharing vehicle for our Pi's. This is what is responsible for great programs like OctoPrint and many
others to do its job. If there are security patches, improvements to the software, better ways to streamline the program,
I want the latest!! I'm thinking you do too. Lets get started:
First, we should briefly talk about how to install the Distro version of Samba. Since a LOT of the work has been done for
us, this is really easy. (Part of the exasperation)
To install the old version of Samba on your Pi:
sudo apt-get update
sudo apt-get upgrade
sudo apt-get install samba samba-common-bin
sudo nano /etc/samba/smb.conf and add the following to the bottom of the file:
[RaspiShare]
comment = RaspiShare Folder
path = /home/pi/
browseable = Yes
writeable = Yes
only guest = no
create mask = 0777
directory mask = 0777
public = no
sudo reboot
The end. Now on your windows machine go to Networks and in the line at the top, type \\the.pis.IP.address and your share
will be visible.
Installing the Latest Version of Samba:
But this isn't about installing a 3 year old version on our Pi. This is about downloading the latest version from the
source. This is more difficult and requires more time. This has been tested over and over so we know you have a very good
chance at success. It's the best we can do if we want a newer version.
Lets start off making sure we have the latest Apt-Get updates and upgrades. These two lines ensure the Distribution is
'up to date'.
Now we go to see what the latest version of Samba is by visiting their web site: Samba.org
You will notice on their site on the right it has a link to the latest release download. Where it says "The source code can
be downloaded now." Hover over the word downloaded, right click and Copy Link Address. With the proper link address available,
in your Pi, type:
cd /home/Pi/Downloads (or wherever you choose to put the file so you know where it is), then:
sudo wget https://download.samba.org/pub/samba/stable/samba-4.8.0.tar.gz <-- substitute the latest filename. The above is the
example from the latest release as of this writing.
Now we need to unzip the file:
sudo tar -xvf samba-4.8.0.tar.gz
For the following steps we need to be in that directory so:
cd /home/pi/Downloads/samba-4.6.7
Once it's downloaded and unzipped into your Pi, we have some Dependencies we need to take care of:
Those are the Dependency Files that will error if you do the following before the previous step.
Next we need to configure:
sudo ./configure <-- takes about (5m39.736s) <-- Don't worry about all of the "not found" entries.
After ./configure you need to make the file. The below command cuts the make time in about a third.
-j 4 tells it to make using all four of the Raspberry Pi's processor cores.
sudo make -j 4 <-- takes about (19m29.890s)
then:
sudo make install <-- takes about (15m39.509s)
The next thing we need to do is to set the Path parameters permanently:
sudo nano /etc/profile
add to the very bottom of the file:
export PATH=/usr/local/samba/bin/:/usr/local/samba/sbin/:$PATH
The rest of this instruction I give many thanks to Mark Stanley. He took the time to test all of
these commands to get you up and running.
To make Samba work automatically from startup, we need to create a script. Put this script in
/etc.init.d/ and name it samba
sudo nano -w /etc/init.d/samba
place the following script in the file:
Once the script is safely in the file, we need to tell the Pi we want that script to be executable:
sudo chmod +x /etc/init.d/samba
Next we need to update the system to allow the script to run at startup:
sudo update-rc.d samba defaults
sudo reboot
Now let's talk a little about the Samba Main Configuration file located in /usr/local/samba/etc/smb.conf. Here is a typical working smb.conf file. To use the one that came with the package, do a sudo find -name smb.conf from the top directory. This config enables a share to be available in Windows 10.
To edit this file:
sudo nano /usr/local/samba/etc/smb.conf
NOTE: if the nano window is blank, copy the below script into your nano window or get one that comes with the package via sudo find -name smb.conf as mentioned earlier.
This is the configuration file for your Shares. If you do this one exactly as it is below, you will get one Share named RaspiShare with the directories allowed by the user Pi. If you wish to see all directories on the Pi, near the end of the file, change Path (under RaspiShare) to just a forward slash.
You will notice near the top the networks group name is WORKGROUP. This is because most Windows machines
use WORKGROUP for their network name. If yours is different, change it there. Other than that ONE possible
change, this configuration file is pretty much ready. No need to activate Wins Support, that does not apply
to most of us, The last 9 lines are the most important for your share. You can change the name within the
brackets from [RaspiShare] to anything you want. You can change the path to a simple / if you want access
to all of the files on the Pi. You can change permissions here as well. If everything is going good so far,
at the command prompt type:
testparm
If this command is successful, you are good to go. This is Samba's way of checking the smb.conf file for
human error.
You can also type:
samba
This will give you the revision number of the installation. Just to prove to yourself you have the latest
downloaded version.
To see the Share on the Windows machine is not very automatic. I wish it were, but this is a mystery that is
above my pay-grade. Go to the Network window on your Windows machine. In the command line near the top,
type \\IP.ADDRESS.OFYOUR.PI <-- be sure to use back slashes and the correct IP address of that specific Pi.
If all is well, your share will appear in the window. Why it doesn't see it automatically is a mystery of
the ages. But if you want that Pi to have a more Permanent Share, right click on the Share [RaspiShare] or
whatever you named it in the config file, and choose Map Network Drive. Choose a safe drive letter, I like
to use ones near the end of the alphabet so there are no conflicts and now that share will show up in your
File system as long as the Pi is turned on.
But, there is one thing you cannot do from this file..
Each of the files and directories on your Pi have permissions. Those permissions apply where-ever you see them.
So if you try to copy something from the Windows machine into the Pi and you did not set your file permissions
accordingly, Windows will tell you Permission Denied. For example, here is a common ls -l.
pi@raspberrypi:/ $ cd /home/pi
pi@raspberrypi:~ $ ls
Desktop Downloads Pictures python_games Videos
Documents Music Public Templates
pi@raspberrypi:~ $ ls -l
total 36
drwxr-xr-x 2 pi pi 4096 Jul 5 07:01 Desktop
drwxr-xr-x 5 pi pi 4096 Jul 5 06:29 Documents
drwxr-xr-x 3 pi pi 4096 Aug 12 14:16 Downloads
drwxr-xr-x 2 pi pi 4096 Jul 5 07:01 Music
drwxr-xr-x 2 pi pi 4096 Jul 5 07:01 Pictures
drwxr-xr-x 2 pi pi 4096 Jul 5 07:01 Public
drwxr-xr-x 2 pi pi 4096 Jul 5 06:29 python_games
drwxr-xr-x 2 pi pi 4096 Jul 5 07:01 Templates
drwxr-xr-x 2 pi pi 4096 Jul 5 07:01 Videos
You will see as a remote user, you do not have permission to even write to the Downloads directory! You can SEE
the directory on your Windows machine, you just cannot write to it. To change that:
sudo chmod 0777 Downloads
Now, Downloads has the correct permissions for the Windows machine to read, write and erase the files within.
drwxrwxrwx 3 pi pi 4096 Aug 12 14:16 Downloads
So that is all there is to it! If you see anything in this document that is incorrect or outdated,
please feel free to email deve@speedprint.com. For technical questions it is a very good idea to use the
Raspberry Pi Forums to ask your questions. This way more people can better explain things.