Compiling and Configuring Samba4 from Scratch


Software • von Sven Reifschneider • 26. Mai 2014 • 1 Kommentar
#linux #howto
info
Dieser Beitrag ist auch auf Deutsch verfügbar. Auf Deutsch lesen
This article may be outdated. As of October 2022, current Samba versions are generally available on all major Linux distributions. Debian 11 uses Samba 4.14, while Arch Linux has 4.17. Thus, manually compiling Samba is no longer necessary.

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.

Compiling Samba required researching various forums and sources. Below are some links that might be helpful for further details or specific needs:


Teile diesen Beitrag

Wenn dir dieser Artikel gefallen hat, teile ihn doch mit deinen Freunden und Bekannten! Das hilft mir dabei, noch mehr Leute zu erreichen und motiviert mich, weiterhin großartige Inhalte für euch zu erstellen. Nutze einfach die Sharing-Buttons hier unten, um den Beitrag auf deinen bevorzugten sozialen Medien zu teilen. Danke dir!

Sharing Illustration
Donating Illustration

Unterstütze den Blog

Falls du meine Arbeit und diesen Blog besonders schätzen solltest, würde ich mich riesig freuen, wenn du mich unterstützen möchtest! Du kannst mir zum Beispiel einen Kaffee spendieren, um mich bei der Arbeit an neuen Artikeln zu erfrischen, oder einfach so, um den Fortbestand des Blogs zu fördern. Jede noch so kleine Spende ist herzlich willkommen und wird sehr geschätzt!

Bitcoin (Segwit):3FsdZmvcwviFwq6VdB9PZtFK827bSQgteY
Ethereum:0x287Ffa3D0D1a9f0Bca9E666a6bd6eDB5d8DB9400
Litecoin (Segwit):MD8fMGDYtdeYWoiqMeuYBr8WBPGKJxomxP
Dogecoin:DTA6gkDCp1WncpoFJghzxCX7XPUryu61Vf
Sven Reifschneider
Über den Autor

Sven Reifschneider

Herzliche Grüße! Ich bin Sven, ein technischer Innovator und begeisterter Fotograf aus der malerischen Wetterau, in der Nähe des lebendigen Frankfurt/Rhein-Main-Gebiets. In diesem Blog verbinde ich mein umfangreiches technisches Wissen mit meiner künstlerischen Leidenschaft, um Geschichten zu erschaffen, die fesseln und erleuchten. Als Leiter von Neoground spreng ich die Grenzen der KI-Beratung und digitalen Innovation und setze mich für Veränderungen ein, die durch Open Source Technologie Widerhall finden.

Die Fotografie ist mein Portal, um die flüchtige Schönheit des Lebens auszudrücken, die ich nahtlos mit technologischen Einsichten verbinde. Hier trifft Kunst auf Innovation, jeder Beitrag strebt nach Exzellenz und entfacht Gespräche, die inspirieren.

Neugierig, mehr zu erfahren? Folge mir in den sozialen Medien oder klicke auf "Mehr erfahren", um das Wesen meiner Vision zu erkunden.


Ein Kommentar

Kommentar hinzufügen

In deinem Kommentar kannst du **Markdown** nutzen. Deine E-Mail-Adresse wird nicht veröffentlicht. Mehr zum Datenschutz findest du in der Datenschutzerklärung.

01. Februar 2014, 03:48 Uhr
Gebenedeit

Perfekt, genau was ich gesucht habe. Dank dir.