# I have multiple versions of Samba covered below. I installed a few
# experiencing build issues, or needed to upgrade to the latest in the same
# on a few diferent machines, so I'll just leave them here. The latest
# of 4.19.x, 4.20.x, 4.21.x
# Samba 4.22.0 failed to build for me and I don't particularly need it,
# so I gave up on that for now. I'll try again when .1 comes out.
# This attempt was on a severely modified Slackware 14.2 (released in
# 2016), so who knows where the problem lies...
# The mount.cifs command that used to be packaged with Samba is cifs-utils
# now. There is a cifs-utils Slackware package starting with 14.0
# cifs-utils HOWTO
# If you are upgrading a source-installed version of Samba and want to clean
# up old files before installing the new version, back up everything, stop
# Samba (smbd, nmbd), then as root, run 'make uninstall' in the source
# directory.
# If you want to make sure that you have no conflicting old files and
# want to (re-)start with sample config files. Back up everything first,
# you may loose accounts and such by doing this, move old files in these
# locations elsewhere until everything is cleaned up and working.
# These options can be changed from their defaults in smb.conf, so
# make sure you review these to be sure where they are located:
#
# state directory
# cache directory
# lock directory
# pid directory
#
# Default examples with --prefix=/usr --sysconfdir=/etc
#
# /etc/samba
# /usr/lib/samba
# /usr/lib64/samba
# /usr/libexec/samba
# /usr/share/samba
# /var/cache/samba
# /var/lib/samba
# /var/log/samba
# /var/run/samba
# In some cases, file formats in /var/lock/samba/, /var/lib/samba/, etc. may
# need to (automatically) be updated when upgrading to a new version of
# Samba. Always best to back up those files if upgrading, in case it goes
# badly and you need to downgrade temporarily, and always best to shut down
# Samba all the way before starting up the new version.
# If you'd like to set up a fax printer that you can use through Samba,
# check out my HylaFAX HOWTO
# (not updated in a looooong time)
# If you have docbook-xsl 1.78.1 from the Slackware linuxdoc-tools package,
# apply this patch to it or it or Samba may fail to build with an error
# referring to man page smb.conf.5 and
# "A potential infinite template recursion was detected"
#
# More info here:
# https://bugzilla.samba.org/show_bug.cgi?id=9515
# https://bugs.gentoo.org/show_bug.cgi?id=488168
# https://src.fedoraproject.org/rpms/docbook-style-xsl/pull-request/1
# https://bugzilla.redhat.com/show_bug.cgi?id=1491307
# https://bugs.archlinux.org/task/54694
# https://www.linuxfromscratch.org/blfs/view/8.3/pst/docbook-xsl.html
# https://cdn.docbook.org/release/xsl/1.79.2/release-notes#V1.79.2
# https://github.com/docbook/xslt10-stylesheets/releases?q=1.79.2&expanded=true
#
# Do this as root
cd
wget -nc -O docbook-xsl-1.78.1.patch \
'https://bugs.debian.org/cgi-bin/bugreport.cgi?msg=66;filename=\
nonrecursive-string-subst.patch;att=1;bug=750593' &&
( cd /usr/share/xml/docbook/xsl-stylesheets-1.78.1
cp -a lib/lib.xsl ~/lib.xsl-$(date +%Y%m%d)
patch -p2 < ~/docbook-xsl-1.78.1.patch &&
rm ~/docbook-xsl-1.78.1.patch )
# Get the Samba tarball
cd
test -f installed/samba-4.19.9.tar.gz && mv installed/samba-4.19.9.tar.gz .
test ! -f samba-4.19.9.tar.gz &&
wget https://download.samba.org/pub/samba/stable/samba-4.19.9.tar.gz
# Verify tarball w/ sha256sum:
# (this came from my gpg-verified tarball)
echo "71ed406444714c90bb9d36c576d807b67af15449f297e91106d42b3ca2fa55\
49 samba-4.19.9.tar.gz" | sha256sum -c
# Extract the source
mkdir -p -m 0700 ~/src
cd ~/src
find -maxdepth 1 -type d -name "samba-*" -exec rm -r {} \;
tar xzvf ~/samba-4.19.9.tar.gz
cd samba-4.19.9
test $UID = 0 && chown -R root:root .
# Read at least ./README.md and if upgrading, ./WHATSNEW.txt
# See ./configure --help for lots of options like --with-ldap (default
# if you have it), --with-pam, --with-quotas, etc. It is not an autoconf
# configure, it is a waf one (waf.io).
# Configure the build for 64-bit
test $(uname -m) = 'x86_64' &&
./configure --enable-fhs --prefix=/usr --sysconfdir=/etc \
--libdir=/usr/lib64 --mandir=/usr/man --localstatedir=/var \
--without-ldap --without-pam --without-ads --without-ad-dc
# Configure the build for anything else
test $(uname -m) != 'x86_64' &&
./configure --prefix=/usr --sysconfdir=/etc --mandir=/usr/man \
--localstatedir=/var \
--without-ldap --without-pam --without-ads --without-ad-dc
# If you have your OpenSSL installed with the < 1.1.0 default prefix of
# /usr/local/ssl and make fails saying can't find -lssl, try this, adjusting
# for wherever yours actually is:
# make LDFLAGS="-L/usr/local/ssl/lib64"
# Build it
make
# Become root to install it
su
# Backup your existing Samba configuration file, if you have one
for bf in /etc/samba/smb.conf /usr/local/samba/lib*/smb.conf; do
test -f $bf &&
( mkdir -p -m 0700 ~/backup
cp -f $bf ~/backup/`basename $bf`-`date +%Y%m%d` )
done
# Shut it down if Samba is running, if you are able.
# If you do not already have a /etc/rc.d/rc.samba, the Slackware one
# is here:
# slackware64-current/source/n/samba/rc.samba
# One of mine is here:
# rc.samba
# There are some example scripts in the source here:
# packaging/sysv/samba.init
# packaging/Example/samba.init
# You can find the pid of smbd and nmbd by looking in /var/run/samba/*.pid
# If those are not there, and you did not change the path in smb.conf,
# you can always use 'killall smbd nmbd' if you must.
test -x /etc/rc.d/rc.samba && /etc/rc.d/rc.samba stop
# Remove the Slackware package, if there is one
test -x /sbin/removepkg && /sbin/removepkg samba
# Install it
make install
ldconfig
# If you install Samba with a prefix other than /usr, create a
# /etc/profile.d/samba.sh to update PATH and MANPATH to reflect where things
# are - e.g. /usr/local/samba/bin and /usr/local/samba/share/man
# If you have an old smb.conf backed up (~/backup/smb.conf-yyyymmdd),
# perhaps rename the sample Samba-distribution smb.conf to smb.conf.dist,
# then copy your backed up one to /etc/samba/smb.conf
# If you don't have a smb.conf Here's a simple sample one written for
# Samba 2.2.8a. It will probably work with this version, but I haven't
# tried it lately.
( cd /etc/samba
test ! -f smb.conf &&
wget https://englanders.us/pub/linux/misc/smb.conf )
# Here's another from the Samba source
cp -a examples/smb.conf.default /etc/samba/smb.conf.default
# If you're using LDAP, set the LDAP administrator's password in
# private/secrets.tdb:
# smbpasswd -w secret
#
# and install the samba.schema for OpenLDAP's use. Set slapd.conf to use it
# and restart slapd. Check out Samba's docs, there are several man pages
# and various other docs that cover setting up LDAP.
test -d /usr/local/etc/openldap/schema &&
cp ../examples/LDAP/samba.schema /usr/local/etc/openldap/schema/
# If you use prefix /usr/local/samba (we use /usr above), update
# /etc/ld.so.conf and then run ldconfig so building software that needs
# to be linked with libraries in /usr/local/samba/lib*/ will work
# Run 'man smb.conf' and see the sample configuration for guidance
# The Wiki and other docs are available on the Samba web site:
# https://www.samba.org/samba/docs/
# Run 'testparm' to verify that your config file is OK
# To start|stop|restart Samba, either set /etc/rc.d/rc.local to start it or
# create a rc.samba rc.M will call it on boot-up if it exists. If you have
# a rc.samba from the old Slackware-installed Samba, open it up in a text
# editor and verify that the paths of smbd, nmbd, and the config file are
# OK in there. If you just upgraded from Samba 2.x to 3.x, be aware that
# smbd and nmbd are in /usr/sbin now (they were in bin before).
#
# You can also find some example scripts in the source under packaging/
#
# This will install a rc.samba for you. If you already had one, and it's
# different than the new one, it'll be renamed rc.samba.old
cd /etc/rc.d
test -f rc.samba &&
( mv -f rc.samba rc.samba.old ; chmod 600 rc.samba.old )
wget https://englanders.us/pub/linux/misc/rc.samba
diff rc.samba.old rc.samba > /dev/null 2>&1 && rm rc.samba.old
chmod 700 rc.samba
chown root:root rc.samba
test -f rc.samba.old &&
( chmod 600 rc.samba.old ; chown root:root rc.samba.old )
# If you've got an old version running, stop it, then start the new Samba:
/etc/rc.d/rc.samba stop
/etc/rc.d/rc.samba start
# If everything goes to hell, you can revert back to the old version (not
# including databases that were converted and config files that you changed)
# by running 'make revert' from the source directory. If you want to
# uninstall Samba you can run 'make uninstall'.
# (I have not tested this)
# If you have a CUPS server running on this machine, create/update the "smb"
# symlink so you can print to printers that are attached to a Windows
# machine using the smb backend:
test -d /usr/lib/cups/backend &&
ln -sf /usr/bin/smbspool /usr/lib/cups/backend/smb
test -d /usr/lib64/cups/backend &&
ln -sf /usr/bin/smbspool /usr/lib64/cups/backend/smb
# Make sure your non-root user can remove the source later
chown -R $(logname) .
chmod -R u+w .
# Become yourself again
exit
# If you used the default prefix of /usr/local/samba (we use /usr above),
# add Samba's bin directory to your current (non-root) shell's PATH and it's
# man directory to MANPATH
test -f /etc/profile.d/samba.sh && . /etc/profile.d/samba.sh
# Save the source for later
cd
mkdir -p -m 0700 installed
rm -f installed/samba-*.tar.*
mv samba-4.19.9.tar.gz installed/
# Get the Samba tarball
cd
test -f installed/samba-4.20.8.tar.gz && mv installed/samba-4.20.8.tar.gz .
test ! -f samba-4.20.8.tar.gz &&
wget https://download.samba.org/pub/samba/stable/samba-4.20.8.tar.gz
# Verify tarball w/ sha256sum:
# (this came from my gpg-verified tarball)
echo "5afe8b66e612ab1c7e57c6146adfe98ec3ea9d40dee2962a2076a3d6d6973b\
78 samba-4.20.8.tar.gz" | sha256sum -c
# Extract the source
mkdir -p -m 0700 ~/src
cd ~/src
find -maxdepth 1 -type d -name "samba-*" -exec rm -r {} \;
tar xzvf ~/samba-4.20.8.tar.gz
cd samba-4.20.8
test $UID = 0 && chown -R root:root .
# Read at least ./README.md and if upgrading, ./WHATSNEW.txt
# See ./configure --help for lots of options like --with-ldap (default
# if you have it), --with-pam, --with-quotas, etc. It is not an autoconf
# configure, it is a waf one (waf.io).
# Configure the build for 64-bit
test $(uname -m) = 'x86_64' &&
./configure --enable-fhs --prefix=/usr --sysconfdir=/etc \
--libdir=/usr/lib64 --mandir=/usr/man --localstatedir=/var \
--without-ldap --without-pam --without-ads --without-ad-dc
# Configure the build for anything else
test $(uname -m) != 'x86_64' &&
./configure --prefix=/usr --sysconfdir=/etc --mandir=/usr/man \
--localstatedir=/var \
--without-ldap --without-pam --without-ads --without-ad-dc
# If you have your OpenSSL installed with the < 1.1.0 default prefix of
# /usr/local/ssl and make fails saying can't find -lssl, try this, adjusting
# for wherever yours actually is:
# make LDFLAGS="-L/usr/local/ssl/lib64"
# Build it
make
# Become root to install it
su
# Backup your existing Samba configuration file, if you have one
for bf in /etc/samba/smb.conf /usr/local/samba/lib*/smb.conf; do
test -f $bf &&
( mkdir -p -m 0700 ~/backup
cp -f $bf ~/backup/`basename $bf`-`date +%Y%m%d` )
done
# Shut it down if Samba is running, if you are able.
# If you do not already have a /etc/rc.d/rc.samba, the Slackware one
# is here:
# slackware64-current/source/n/samba/rc.samba
# One of mine is here:
# rc.samba
# There are some example scripts in the source here:
# packaging/sysv/samba.init
# packaging/Example/samba.init
# You can find the pid of smbd and nmbd by looking in /var/run/samba/*.pid
# If those are not there, and you did not change the path in smb.conf,
# you can always use 'killall smbd nmbd' if you must.
test -x /etc/rc.d/rc.samba && /etc/rc.d/rc.samba stop
# Remove the Slackware package, if there is one
test -x /sbin/removepkg && /sbin/removepkg samba
# Install it
make install
ldconfig
# If this was an upgrade and you already have a working smb.conf,
# start it up again
# If you install Samba with a prefix other than /usr, create a
# /etc/profile.d/samba.sh to update PATH and MANPATH to reflect where things
# are - e.g. /usr/local/samba/bin and /usr/local/samba/share/man
# If you have an old smb.conf backed up (~/backup/smb.conf-yyyymmdd),
# perhaps rename the sample Samba-distribution smb.conf to smb.conf.dist,
# then copy your backed up one to /etc/samba/smb.conf
# If you don't have a smb.conf Here's a simple sample one written for
# Samba 2.2.8a. It will probably work with this version, but I haven't
# tried it lately.
( cd /etc/samba
test ! -f smb.conf &&
wget https://englanders.us/pub/linux/misc/smb.conf )
# Here's another from the Samba source
cp -a examples/smb.conf.default /etc/samba/smb.conf.default
# If you're using LDAP, set the LDAP administrator's password in
# private/secrets.tdb:
# smbpasswd -w secret
#
# and install the samba.schema for OpenLDAP's use. Set slapd.conf to use it
# and restart slapd. Check out Samba's docs, there are several man pages
# and various other docs that cover setting up LDAP.
test -d /usr/local/etc/openldap/schema &&
cp ../examples/LDAP/samba.schema /usr/local/etc/openldap/schema/
# If you use prefix /usr/local/samba (we use /usr above), update
# /etc/ld.so.conf and then run ldconfig so building software that needs
# to be linked with libraries in /usr/local/samba/lib*/ will work
# Run 'man smb.conf' and see the sample configuration for guidance
# The Wiki and other docs are available on the Samba web site:
# https://www.samba.org/samba/docs/
# Run 'testparm' to verify that your config file is OK
# To start|stop|restart Samba, either set /etc/rc.d/rc.local to start it or
# create a rc.samba rc.M will call it on boot-up if it exists. If you have
# a rc.samba from the old Slackware-installed Samba, open it up in a text
# editor and verify that the paths of smbd, nmbd, and the config file are
# OK in there. If you just upgraded from Samba 2.x to 3.x, be aware that
# smbd and nmbd are in /usr/sbin now (they were in bin before).
#
# You can also find some example scripts in the source under packaging/
#
# This will install a rc.samba for you. If you already had one, and it's
# different than the new one, it'll be renamed rc.samba.old
cd /etc/rc.d
test -f rc.samba &&
( mv -f rc.samba rc.samba.old ; chmod 600 rc.samba.old )
wget https://englanders.us/pub/linux/misc/rc.samba
diff rc.samba.old rc.samba > /dev/null 2>&1 && rm rc.samba.old
chmod 700 rc.samba
.chown root:root rc.samba
test -f rc.samba.old &&
( chmod 600 rc.samba.old ; chown root:root rc.samba.old )
# If you've got an old version running, stop it, then start the new Samba:
/etc/rc.d/rc.samba stop
/etc/rc.d/rc.samba start
# If everything goes to hell, you can revert back to the old version (not
# including databases that were converted and config files that you changed)
# by running 'make revert' from the source directory. If you want to
# uninstall Samba you can run 'make uninstall'.
# (I have not tested this)
# If you have a CUPS server running on this machine, create/update the "smb"
# symlink so you can print to printers that are attached to a Windows
# machine using the smb backend:
test -d /usr/lib/cups/backend &&
ln -sf /usr/bin/smbspool /usr/lib/cups/backend/smb
test -d /usr/lib64/cups/backend &&
ln -sf /usr/bin/smbspool /usr/lib64/cups/backend/smb
# Make sure your non-root user can remove the source later
chown -R $(logname) .
chmod -R u+w .
# Become yourself again
exit
# If you used the default prefix of /usr/local/samba (we use /usr above),
# add Samba's bin directory to your current (non-root) shell's PATH and it's
# man directory to MANPATH
test -f /etc/profile.d/samba.sh && . /etc/profile.d/samba.sh
# Save the source for later
cd
mkdir -p -m 0700 installed
rm -f installed/samba-*.tar.*
mv samba-4.20.8.tar.gz installed/
# Get the Samba tarball
cd
test -f installed/samba-4.21.4.tar.gz && mv installed/samba-4.21.4.tar.gz .
test ! -f samba-4.21.4.tar.gz &&
wget https://download.samba.org/pub/samba/stable/samba-4.21.4.tar.gz
# Verify tarball w/ sha256sum:
# (this came from my gpg-verified tarball)
echo "50acf030db0ce6be1ee8a6c3a7636e54576c60a7f814e64becfa840f7b30ec\
ed samba-4.21.4.tar.gz" | sha256sum -c
# Extract the source
mkdir -p -m 0700 ~/src
cd ~/src
find -maxdepth 1 -type d -name "samba-*" -exec rm -r {} \;
tar xzvf ~/samba-4.21.4.tar.gz
cd samba-4.21.4
test $UID = 0 && chown -R root:root .
# Read at least ./README.md and if upgrading, ./WHATSNEW.txt
# See ./configure --help for lots of options like --with-ldap (default
# if you have it), --with-pam, --with-quotas, etc. It is not an autoconf
# configure, it is a waf one (waf.io).
# Configure the build for 64-bit
test $(uname -m) = 'x86_64' &&
./configure --enable-fhs --prefix=/usr --sysconfdir=/etc \
--libdir=/usr/lib64 --mandir=/usr/man --localstatedir=/var \
--without-ldap --without-pam --without-ads --without-ad-dc
# Configure the build for anything else
test $(uname -m) != 'x86_64' &&
./configure --prefix=/usr --sysconfdir=/etc --mandir=/usr/man \
--localstatedir=/var \
--without-ldap --without-pam --without-ads --without-ad-dc
# If you have your OpenSSL installed with the < 1.1.0 default prefix of
# /usr/local/ssl and make fails saying can't find -lssl, try this, adjusting
# for wherever yours actually is:
# make LDFLAGS="-L/usr/local/ssl/lib64"
# Build it
make
# Become root to install it
su
# Backup your existing Samba configuration file, if you have one
for bf in /etc/samba/smb.conf /usr/local/samba/lib*/smb.conf; do
test -f $bf &&
( mkdir -p -m 0700 ~/backup
cp -f $bf ~/backup/`basename $bf`-`date +%Y%m%d` )
done
# Shut it down if Samba is running.
# If you do not already have a /etc/rc.d/rc.samba, the Slackware one
# is here:
# slackware64-current/source/n/samba/rc.samba
# One of mine is here:
# rc.samba
# There are some example scripts in the source here:
# packaging/sysv/samba.init
# packaging/Example/samba.init
# You can find the pid of smbd and nmbd by looking in /var/run/samba/*.pid
# If those are not there, and you did not change the path in smb.conf,
# you can always use 'killall smbd nmbd' if you must.
test -x /etc/rc.d/rc.samba && /etc/rc.d/rc.samba stop
# Remove the Slackware package, if there is one
test -x /sbin/removepkg && /sbin/removepkg samba
# Install it
make install
ldconfig
# If this was an upgrade and you already have a working smb.conf,
# start it up again
# If you install Samba with a prefix other than /usr, create a
# /etc/profile.d/samba.sh to update PATH and MANPATH to reflect where things
# are - e.g. /usr/local/samba/bin and /usr/local/samba/share/man
# If you have an old smb.conf backed up (~/backup/smb.conf-yyyymmdd),
# perhaps rename the sample Samba-distribution smb.conf to smb.conf.dist,
# then copy your backed up one to /etc/samba/smb.conf
# If you don't have a smb.conf, refer to 'man smb.conf' and the Samba docs:
# https://wiki.samba.org/index.php/Main_Page
# https://www.samba.org/samba/docs/
#
# I have a possibly very outdated smb.conf example here:
# https://englanders.us/pub/linux/misc/smb.conf
#
# Here's an example smb.conf from the Samba source
# This will copy it as smb.conf.default and if you do not have a
# smb.conf, it will copy smb.conf.default to smb.conf
cp --preserve=timestamps examples/smb.conf.default \
/etc/samba/smb.conf.default
( cd /etc/samba
test ! -f smb.conf && cp -a smb.conf.default smb.conf )
# Run 'testparm' to verify that your config file is OK and
# 'testparm -v' to include defaults too
# If you're using LDAP, set the LDAP administrator's password in
# private/secrets.tdb:
# smbpasswd -w secret
#
# and install the samba.schema for OpenLDAP's use. Set slapd.conf to use it
# and restart slapd. Check out Samba's docs, there are several man pages
# and various other docs that cover setting up LDAP. If your OpenLDAP is
# installed with prefix /usr, change that to /etc/openldap
test -d /usr/local/etc/openldap/schema &&
cp ../examples/LDAP/samba.schema /usr/local/etc/openldap/schema/
# If you use prefix /usr/local/samba (we use /usr above), update
# /etc/ld.so.conf and then run ldconfig so building software that needs
# to be linked with libraries in /usr/local/samba/lib*/ will work
# To start|stop|restart Samba, either set /etc/rc.d/rc.local to start it or
# create a rc.samba (see above). rc.M will call it on boot-up if it exists.
# If you just upgraded from a very old version of Samba, confirm the
# location of smbd and nmbd and adjust rc.samba if needed.
# If everything goes to hell, you can revert back to the old version (not
# including databases that were converted and config files that you changed)
# by running 'make revert' from the source directory. If you want to
# uninstall Samba you can run 'make uninstall'.
# (I have not tested this)
# If you have a CUPS server running on this machine, create/update the "smb"
# symlink so you can print to printers that are attached to a Windows
# machine using the smb backend:
test -d /usr/lib/cups/backend &&
ln -sf /usr/bin/smbspool /usr/lib/cups/backend/smb
test -d /usr/lib64/cups/backend &&
ln -sf /usr/bin/smbspool /usr/lib64/cups/backend/smb
# Make sure your non-root user can remove the source later
chown -R $(logname) .
chmod -R u+w .
# Become yourself again
exit
# If you used the default prefix of /usr/local/samba (we use /usr above),
# add Samba's bin directory to your current (non-root) shell's PATH and it's
# man directory to MANPATH
test -f /etc/profile.d/samba.sh && . /etc/profile.d/samba.sh
# Save the source for later
cd
mkdir -p -m 0700 installed
rm -f installed/samba-*.tar.*
mv samba-4.21.4.tar.gz installed/
## Samba 4.22.0 would fail for me with this, only tried it on one machine
## running a severely modified Slackware 14.2 (in 2025):
# ../../lib/replace/replace.c: In function 'rep_copy_reflink':
# ../../lib/replace/replace.c:1098:26: error: storage size of 'cr' isn't known
#
# Here is the Slackware64-current source and package location (in 'n') for
# for the Samba 4.22.0 package:
# http://ftp.slackware.com/pub/slackware/slackware64-current/source/n/samba/
# http://ftp.slackware.com/pub/slackware/slackware64-current/slackware64/n/