In early January 2014, Samba released version 4.1.4. This version introduced several advantages and fixes over older ones, proving to be more stable, especially with large data transfers. One might assume that updating Samba on Debian-like systems is as simple as running apt-get update && apt-get upgrade
. However, I found myself stuck with Samba 3.x, despite wanting the features of Samba 4.
Why Samba 4?
While Samba 3 served me well, issues arose when I changed my external hard drive (proving the adage "Never touch a running system"). With larger data transfers, Samba 3 would lose connection and even deny access to the external drive. This led me to consider Samba 4 as a potential solution. Despite finding Samba 4 in the repositories, the available version was an older beta release, not the stable version I was looking for. As of January 21, 2014, Debian Packages still listed version 4.0.0 beta2. Therefore, the only option was to compile Samba 4 myself.
> "because samba 4 is a very powerful full featured needed monster." - Naaano, ubuntuforums.org
This quote encapsulates my motivation well. Let's dive into building our own Samba 4!
Who Is This Guide For?
This guide is aimed at anyone looking to compile the latest version of Samba. It should work on any system with the necessary packages for compilation (make, build-essentials, gcc, etc.). The deinstallation of the current version may vary, but in principle, this method should work on systems like the Raspberry Pi.
Downloading, Compiling, Installing
First, remove the old Samba version, in my case, Samba 3.x, which on Debian/Ubuntu systems is straightforward:
$ apt-get remove samba*
This command uninstalls all Samba packages but retains configuration files, which is my preferred approach. Next, download the latest Samba version:
$ mkdir /home/sven/samba
$ cd /home/sven/samba
$ wget http://ftp.samba.org/pub/samba/samba-latest.tar.gz
$ tar -xzvf samba-latest.tar.gz
$ cd samba-4.1.4
The typical Linux sequence follows: ./configure
, make
, and make install
. ./configure
checks all dependencies and sets up the system for a smooth run. make
compiles the software, which might take a while. Finally, make install
places all files where they belong:
$ make install
The installation process might take around two hours on low-powered systems, so it's a good time to take a break. The working path created is /usr/local/samba
, where all necessary files are located.
Setting Up
Key files and scripts are located in /usr/local/samba
. I created startsmb
and stopsmb
scripts for easy administration of the Samba server.
In the old source those two scripts were missing:
# Writing the start script. Open vim and press "i" to insert the following code
$ vim /usr/local/samba/startsmb
#!/bin/sh
/usr/local/samba/sbin/smbd -D
/usr/local/samba/sbin/winbindd -D
/usr/local/samba/sbin/nmbd -D
# Save and quit vim (Esc, type :wq)
# Make script executable
$ chmod +x startsmb
# Writing the stop script. Open vim and press "i" to insert the following code
$ vim /usr/local/samba/stopsmb
#!/bin/sh
killall smbd
killall winbindd
killall nmbd
# Save and quit vim (Esc, type :wq)
# Make script executable
$ chmod +x stopsmb
Additionally, I made the Samba commands globally accessible by editing the $PATH
variable in the .bashrc
file:
PATH=$PATH:/usr/local/samba/bin
PATH=$PATH:/usr/local/samba/sbin
Starting Samba
With testparm
, we can test our Samba configuration file smb.conf
. If everything checks out, start Samba with /usr/local/samba/startsmb
. To verify successful connections, use smbstatus
:
$ smbstatus
Samba version 4.1.4
PID Username Group Machine
-------------------------------------------------------------------
31755 smbusr smbusr workstation (ipv4:192.168.0.9:63067)
Service pid machine Connected at
-------------------------------------------------------
IPC$ 31755 workstation Sat Jan 18 20:16:06 2014
share 31755 workstation Sat Jan 18 20:16:06 2014
Conclusion
Setting up Samba is not overly complex, but attention to detail is key. This method allows you to compile and install Samba on any Linux machine, independent of distribution packages. Samba 4 runs more efficiently for me, and the effort was worthwhile.
I hope this guide assists others. In theory, this method could also be applied to set up Samba on a Raspberry Pi, making this guide broadly applicable beyond Ubuntu/Debian.
Useful Links
Compiling Samba required researching various forums and sources. Below are some links that might be helpful for further details or specific needs:
One comment
Reply to comment
01 Feb 2014, 03:48
GebenedeitPerfekt, genau was ich gesucht habe. Dank dir.