Super Pi Part 8: Samba

Posted on June 10, 2021

I admit that this part of Super Pi probably isn't the best use of resources. When I first got a Pi, I set up a Samba share as my first project. I actually had kind of a hard time getting it working. I later set up a NAS on my router when I got one that supported it. That worked well until I recently moved to OpenWRT, which is more than capable of hosting a NAS, but I have a much easier time customizing a Raspberry Pi than a router. Plus, it's also a lot lower risk for me. If my Pi goes down, no one notices, but if the router goes out I have another person to answer to, and she does not like being without internet. Given my situation, the path forward was clear. There are more tutorials on setting up Samba now, the config I used came from here. I pretty much ignored everything else. The first step is to install Samba:

sudo apt install samba

The installation creates a file called /etc/samba/smb.conf. I replaced its contents with the following:

workgroup = SAMBA
security = user
client min protocol = SMB2

path = /home/samba/share
comment = Samba Shared Folder
browsable = yes
writeable = yes
only guest = no
public = yes
Guest ok = no

Samba uses its own user-password store, so add a new user by running . If ufw is installed, whitelist Samba by running . With this done, finding my Samba share on Pop!_OS was relatively painless. I just opened the "Files" app, went to "Other Locations", saw that the share popped up, and I was able to browse and modify files anonymously.

On Android, I was able to access the Samba share using the "My Files" app. There's a "Network Storage" section, and from there I added a "Network Drive (SMB)", provided the IP of the Pi, and set the port to . There is a radio checkbox to sign in anonymously which I was expecting to work, but for some reason it doesn't, and I had to enter the username and password of the user owning the share.

On a Linux computer, I like to mount Samba shares via fstab, which requires the samba package. Create a credential file in /etc/samba/credentials/share with a username and password:


Alter the permissions:

sudo chmod 700 /etc/samba/credentials
sudo chmod 600 /etc/samba/credentials/share
sudo chown root:root -R/etc/samba/credentials