PiBuilder can enable SMB services as an option.
PiBuilder assumes that you have a working configuration that you want to preserve across rebuilds. If you do not have a working configuration, you need to do that first. You may find the following tutorials helpful:
- KaliTut Samba on Raspberry Pi Guide – A To Z (April 2021)
- PiMyLifeUp Raspberry Pi SAMBA (Feb 2021)
- JUANMTECH SAMBA file sharing (Oct 2017)
Note:
-
Tutorials differ in the packages they tell you to install. You only need:
$ sudo apt install -y samba smbclient
The
samba
package includessamba-common
andsamba-common-bin
so you do not need to install those separately.
If you want to remote mount your Raspberry Pi's home directory onto another machine, the simplest approach is:
-
Use
sudo
and edit/etc/samba/smb.conf
-
Find the following:
[homes] comment = Home Directories browseable = no # By default, the home directories are exported read-only. Change the # next parameter to 'no' if you want to be able to write to them. read only = yes
-
Make it look like this:
[homes] comment = Home Directories browseable = yes # By default, the home directories are exported read-only. Change the # next parameter to 'no' if you want to be able to write to them. read only = no
-
Restart the service:
$ sudo service smbd restart
After you have SAMBA working on your Raspberry Pi, you need to preserve three files:
-
Your configuration:
$ cp /etc/samba/smb.conf $HOME
-
Any SAMBA credentials you may have set up:
$ touch $HOME/passdb.tdb $ sudo cp /var/lib/samba/private/passdb.tdb $HOME/passdb.tdb
-
Host-specific information generated when SAMBA is first installed on any given host:
$ touch $HOME/secrets.tdb@$HOSTNAME $ sudo cp /var/lib/samba/private/secrets.tdb $HOME/secrets.tdb@$HOSTNAME
@HOSTNAME
syntax is used becausesecrets.tdb
contains host-specific information. While you may use commonsmb.conf
andpassdb.tdb
files on several hosts, you should obtainsecrets.tdb
from the host on which it was created.
Next, navigate to the top level of your copy of PiBuilder and create two directories:
$ cd ~/PiBuilder
$ mkdir -p boot/scripts/support/etc/samba boot/scripts/support/var/lib/samba/private
Finally:
- Move
smb.conf
into~/PiBuilder/boot/scripts/support/etc/samba
; and - Move the
.tdb
files into~/PiBuilderboot/scripts/support/var/lib/samba/private
.
PiBuilder detects the presence of smb.conf
and uses it as a trigger to:
- Install SAMBA;
- Replace the default versions of the three files with your custom versions; and
- Create
$HOME/share
as a home for your SMB mount points.
The smb.conf
file can change across OS versions (eg Bullseye to Bookworm).
If you are planning to upgrade, is a good idea to install SAMBA and configure it by hand.