hengreer
Posts: 5
Joined: Wed Aug 21, 2019 10:18 am

Installing Samba [SOLVED]

Wed Aug 21, 2019 10:48 am

Hi all, relatively new to the raspberry pi. Using version 3b.
I'm trying to set up a plex server on the pi, I've got the server up and running and I now just need to put things on it. To do this I wanted to share a folder on a HDD mounted to the pi to be able to transfer files from my windows pc to the pi without having to unplug the HDD. I've got it mounted I believe and am trying to install samba.

I ran this

Code: Select all

$ sudo apt-get install samba samba-common-bin
It ran fine until I came upon the problem below. (This is the same errors just from an apt upgrade)

Code: Select all

pi@raspberrypi:/ $ sudo apt-get upgrade
Reading package lists... Done
Building dependency tree       
Reading state information... Done
Calculating upgrade... Done
0 upgraded, 0 newly installed, 0 to remove and 0 not upgraded.
1 not fully installed or removed.
After this operation, 0 B of additional disk space will be used.
Do you want to continue? [Y/n] y
Setting up samba (2:4.5.16+dfsg-1+deb9u1) ...
Failed to preset unit: Unit file /etc/systemd/system/samba-ad-dc.service is masked.
/usr/bin/deb-systemd-helper: error: systemctl preset failed on samba-ad-dc.service: No such file or directory
Job for smbd.service failed because the control process exited with error code.
See "systemctl status smbd.service" and "journalctl -xe" for details.
invoke-rc.d: initscript smbd, action "start" failed.
● smbd.service - Samba SMB Daemon
   Loaded: loaded (/lib/systemd/system/smbd.service; enabled; vendor preset: enabled)
   Active: failed (Result: exit-code) since Wed 2019-08-21 11:15:57 BST; 37ms ago
     Docs: man:smbd(8)
           man:samba(7)
           man:smb.conf(5)
  Process: 4623 ExecStart=/usr/sbin/smbd $SMBDOPTIONS (code=exited, status=127)
 Main PID: 4623 (code=exited, status=127)

Aug 21 11:15:57 raspberrypi systemd[1]: Starting Samba SMB Daemon...
Aug 21 11:15:57 raspberrypi smbd[4623]: /usr/sbin/smbd: error while loading shared libraries:…ctory
Aug 21 11:15:57 raspberrypi systemd[1]: smbd.service: Main process exited, code=exited, statu…7/n/a
Aug 21 11:15:57 raspberrypi systemd[1]: Failed to start Samba SMB Daemon.
Aug 21 11:15:57 raspberrypi systemd[1]: smbd.service: Unit entered failed state.
Aug 21 11:15:57 raspberrypi systemd[1]: smbd.service: Failed with result 'exit-code'.
Hint: Some lines were ellipsized, use -l to show in full.
dpkg: error processing package samba (--configure):
 subprocess installed post-installation script returned error exit status 1
Processing triggers for libc-bin (2.24-11+deb9u4) ...
Errors were encountered while processing:
 samba
E: Sub-process /usr/bin/dpkg returned an error code (1)


Anyone have any ideas how to fix this?

Thanks,
Hengreer
Last edited by hengreer on Thu Aug 22, 2019 12:11 pm, edited 1 time in total.

hortimech
Posts: 753
Joined: Wed Apr 08, 2015 5:52 pm

Re: Installing Samba

Wed Aug 21, 2019 11:07 am

Yes :)



OH, you mean how do I fix this :D

Run these commands:

Code: Select all

sudo systemctl start smbd
sudo systemctl start nmbd

sudo systemctl enable smbd
sudo systemctl enable nmbd

hengreer
Posts: 5
Joined: Wed Aug 21, 2019 10:18 am

Re: Installing Samba

Wed Aug 21, 2019 3:31 pm

Hi,
I've tried running all 4 of those commands as suggested, As you can see below it came up with the error

Code: Select all

pi@raspberrypi:/ $ sudo systemctl start smbd
Job for smbd.service failed because the control process exited with error code.
See "systemctl status smbd.service" and "journalctl -xe" for details.
pi@raspberrypi:/ $ sudo systemctl start nmbd
Job for nmbd.service failed because the control process exited with error code.
See "systemctl status nmbd.service" and "journalctl -xe" for details.
pi@raspberrypi:/ $ sudo systemctl enable smbd
Synchronizing state of smbd.service with SysV service script with /lib/systemd/systemd-sysv-install.
Executing: /lib/systemd/systemd-sysv-install enable smbd
pi@raspberrypi:/ $ sudo systemctl enable nmbd
Synchronizing state of nmbd.service with SysV service script with /lib/systemd/systemd-sysv-install.
Executing: /lib/systemd/systemd-sysv-install enable nmbd
For good measure I had a look at the 1st file:

Code: Select all

pi@raspberrypi:/ $ systemctl status smbd.service
● smbd.service - Samba SMB Daemon
   Loaded: loaded (/lib/systemd/system/smbd.service; enabled; vendor preset: enabled)
   Active: failed (Result: exit-code) since Wed 2019-08-21 16:12:53 BST; 9s ago
     Docs: man:smbd(8)
           man:samba(7)
           man:smb.conf(5)
  Process: 10033 ExecStart=/usr/sbin/smbd $SMBDOPTIONS (code=exited, status=127)
 Main PID: 10033 (code=exited, status=127)

Aug 21 16:12:53 raspberrypi systemd[1]: Starting Samba SMB Daemon...
Aug 21 16:12:53 raspberrypi smbd[10033]: /usr/sbin/smbd: error while loading shared libraries: libs
Aug 21 16:12:53 raspberrypi systemd[1]: smbd.service: Main process exited, code=exited, status=127/
Aug 21 16:12:53 raspberrypi systemd[1]: Failed to start Samba SMB Daemon.
Aug 21 16:12:53 raspberrypi systemd[1]: smbd.service: Unit entered failed state.
Aug 21 16:12:53 raspberrypi systemd[1]: smbd.service: Failed with result 'exit-code'.
Checked the fiile /usr/sbin/smbd $SMBDOPTIONS and it doesn't exist? Not sure what happened their but I've no idea which package to reinstall to generate that file.

Suggestions welcome.

hortimech
Posts: 753
Joined: Wed Apr 08, 2015 5:52 pm

Re: Installing Samba

Wed Aug 21, 2019 4:12 pm

You can ignore that variable, if it isn't set, it will be blank and so ignored.

Does /etc/samba/smb.conf exist and if so, what does it contain ?

hengreer
Posts: 5
Joined: Wed Aug 21, 2019 10:18 am

Re: Installing Samba

Wed Aug 21, 2019 4:19 pm

It does indeed exist

Code: Select all

cat /etc/samba/smb.conf 
# NOTE: Whenever you modify this file you should run the command "testparm"
# to check that you have not made any basic syntactic errors.
#
#---------------
# SELINUX NOTES:
#
# If you want to use the useradd/groupadd family of binaries please run:
# setsebool -P samba_domain_controller on
#
# If you want to share home directories via samba please run:
# setsebool -P samba_enable_home_dirs on
#
# If you create a new directory you want to share you should mark it as
# "samba-share_t" so that selinux will let you write into it.
# Make sure not to do that on system directories as they may already have
# been marked with othe SELinux labels.
#
# Use ls -ldZ /path to see which context a directory has
#
# Set labels only on directories you created!
# To set a label use the following: chcon -t samba_share_t /path
#
# If you need to share a system created directory you can use one of the
# following (read-only/read-write):
# setsebool -P samba_export_all_ro on
# or
# setsebool -P samba_export_all_rw on
#
# If you want to run scripts (preexec/root prexec/print command/...) please
# put them into the /var/lib/samba/scripts directory so that smbd will be
# allowed to run them.
# Make sure you COPY them and not MOVE them so that the right SELinux context
# is applied, to check all is ok use restorecon -R -v /var/lib/samba/scripts
#
#======================= Global Settings =====================================

[global]
	workgroup = workgroup
	security = user
	idmap uid = 16777216-33554431
	idmap gid = 16777216-33554431
;	template shell = /bin/false
	winbind use default domain = false
	winbind offline logon = false

# ----------------------- Network Related Options -------------------------
#
# workgroup = NT-Domain-Name or Workgroup-Name, eg: MIDEARTH
#
# server string is the equivalent of the NT Description field
#
# netbios name can be used to specify a server name not tied to the hostname
#
# Interfaces lets you configure Samba to use multiple interfaces
# If you have multiple network interfaces then you can list the ones
# you want to listen on (never omit localhost)
#
# Hosts Allow/Hosts Deny lets you restrict who can connect, and you can
# specifiy it as a per share option as well
#
	server string = Samba Server %v

;	netbios name = MYSERVER

;	interfaces = lo eth0 192.168.12.2/24 192.168.13.2/24
;	hosts allow = 127. 192.168.12. 192.168.13.

# --------------------------- Logging Options -----------------------------
#
# Log File let you specify where to put logs and how to split them up.
#
# Max Log Size let you specify the max size log files should reach

	# logs split per machine
;	log file = /var/log/samba/%m.log
	# max 50KB per log file, then rotate
;	max log size = 50

# ----------------------- Standalone Server Options ------------------------
#
# Security can be set to user, share(deprecated) or server(deprecated)
#
# Backend to store user information in. New installations should
# use either tdbsam or ldapsam. smbpasswd is available for backwards
# compatibility. tdbsam requires no further configuration.

	passdb backend = tdbsam

# ----------------------- Browser Control Options ----------------------------
#
# set local master to no if you don't want Samba to become a master
# browser on your network. Otherwise the normal election rules apply
#
# OS Level determines the precedence of this server in master browser
# elections. The default value should be reasonable
#
# Preferred Master causes Samba to force a local browser election on startup
# and gives it a slightly higher chance of winning the election
;	local master = no
;	os level = 33
;	preferred master = yes

#----------------------------- Name Resolution -------------------------------
# Windows Internet Name Serving Support Section:
# Note: Samba can be either a WINS Server, or a WINS Client, but NOT both
#
# - WINS Support: Tells the NMBD component of Samba to enable it's WINS Server
#
# - WINS Server: Tells the NMBD components of Samba to be a WINS Client
#
# - WINS Proxy: Tells Samba to answer name resolution queries on
#   behalf of a non WINS capable client, for this to work there must be
#   at least one	WINS Server on the network. The default is NO.
#
# DNS Proxy - tells Samba whether or not to try to resolve NetBIOS names
# via DNS nslookups.

;	wins support = yes
;	wins server = w.x.y.z
;	wins proxy = yes

;	dns proxy = yes

# --------------------------- Printing Options -----------------------------
#
# Load Printers let you load automatically the list of printers rather
# than setting them up individually
#
# Cups Options let you pass the cups libs custom options, setting it to raw
# for example will let you use drivers on your Windows clients
#
# Printcap Name let you specify an alternative printcap file
#
# You can choose a non default printing system using the Printing option

;	load printers = yes
	cups options = raw

;	printcap name = /etc/printcap
	#obtain list of printers automatically on SystemV
;	printcap name = lpstat
;	printing = cups

# --------------------------- Filesystem Options ---------------------------
#
# The following options can be uncommented if the filesystem supports
# Extended Attributes and they are enabled (usually by the mount option
# user_xattr). Thess options will let the admin store the DOS attributes
# in an EA and make samba not mess with the permission bits.
#
# Note: these options can also be set just per share, setting them in global
# makes them the default for all shares

;	map archive = no
;	map hidden = no
;	map read only = no
;	map system = no
	username map = /etc/samba/smbusers
	encrypt passwords = yes
	guest ok = yes
;	guest account = nobody
;	store dos attributes = yes

#============================ Share Definitions ==============================

[homes]
	comment = Home Directories
	browseable = no
	writable = yes
	valid users = %S
;	valid users = MYDOMAIN\%S

[printers]
	comment = All Printers
	path = /var/spool/samba
	browseable = no
;	guest ok = no
;	writable = No
	printable = yes

# Un-comment the following to provide a specific roving profile share
# the default is to use the user's home directory
;	[Profiles]
;	path = /var/lib/samba/profiles
;	browseable = no
;	guest ok = yes


# A publicly accessible directory, but read only, except for people in
# the "staff" group
;	[public]
;	comment = Public Stuff
;	path = /home/samba
;	public = yes
;	writable = yes
;	printable = no
;	write list = +staff

[downloads]
	path = /root/downloads
	writeable = yes
	browseable = yes
	valid users = root
	public = no


hortimech
Posts: 753
Joined: Wed Apr 08, 2015 5:52 pm

Re: Installing Samba

Wed Aug 21, 2019 6:40 pm

Well, after removing all the comments and default lines, this is the effective smb.conf:

Code: Select all

[global]
	workgroup = workgroup
	idmap uid = 16777216-33554431
	idmap gid = 16777216-33554431
	winbind use default domain = false
	winbind offline logon = false
	username map = /etc/samba/smbusers
	guest ok = yes

	security = user
	server string = Samba Server %v
	cups options = raw

[homes]
	comment = Home Directories
	browseable = no
	read only = no
	valid users = %S

[printers]
	comment = All Printers
	path = /var/spool/samba
	browseable = no
	printable = yes

[downloads]
	path = /root/downloads
	read only = no
	valid users = root
	public = no
Which is interesting because it is neither one thing or another, it is basically a standalone server, but lots of it would only make sense if it was a Unix domain member. If you are trying to set up a standalone server, remove the first block of lines from the smb.conf above (the ones between [global] and 'security = user') with the possible exception of the 'workgroup' line, if 'workgroup' is a replacement for the real workgroup name, leave it in, if it isn't, remove it.
I should also point out that, the supplied smb.conf isn't the default, it has been heavily modified.
The next question is, do you have a root user, because this is the only user that can really connect.

hengreer
Posts: 5
Joined: Wed Aug 21, 2019 10:18 am

Re: Installing Samba

Thu Aug 22, 2019 7:57 am

Right due to the fact you say it's a heavily modified version I've decided the best thing to do is uninstall everything and try again, however I still have the same error as above, and this time there is no smb.conf file.

Part of the installation process below

Code: Select all

Samba is not being run as an AD Domain Controller, masking samba-ad-dc-service.
Please ignore the following error about deb-systemd-helper not finding samba-ad-dc-service.
Created symlink /etc/systemd/system/multi-user.target.wants/nmbd.service → /lib/systemd/system/nmbd.service.
Failed to preset unit: Unit file /etc/systemd/system/samba-ad-dc.service is masked.
/usr/bin/deb-systemd-helper: error: systemctl preset failed on samba-ad-dc.service: No such file or directory
Created symlink /etc/systemd/system/multi-user.target.wants/smbd.service → /lib/systemd/system/smbd.service.
Job for smbd.service failed because the control process exited with error code.
See "systemctl status smbd.service" and "journalctl -xe" for details.
invoke-rc.d: initscript smbd, action "start" failed.
● smbd.service - Samba SMB Daemon
   Loaded: loaded (/lib/systemd/system/smbd.service; enabled; vendor preset: enabled)
   Active: failed (Result: exit-code) since Thu 2019-08-22 08:34:20 BST; 30ms ago
     Docs: man:smbd(8)
           man:samba(7)
           man:smb.conf(5)
  Process: 19370 ExecStart=/usr/sbin/smbd $SMBDOPTIONS (code=exited, status=127)
 Main PID: 19370 (code=exited, status=127)

Aug 22 08:34:19 raspberrypi systemd[1]: Starting Samba SMB Daemon...
Aug 22 08:34:19 raspberrypi smbd[19370]: /usr/sbin/smbd: error while loading…ory
Aug 22 08:34:20 raspberrypi systemd[1]: smbd.service: Main process exited, c…n/a
Aug 22 08:34:20 raspberrypi systemd[1]: Failed to start Samba SMB Daemon.
Aug 22 08:34:20 raspberrypi systemd[1]: smbd.service: Unit entered failed state.
Aug 22 08:34:20 raspberrypi systemd[1]: smbd.service: Failed with result 'ex…e'.
Hint: Some lines were ellipsized, use -l to show in full.
dpkg: error processing package samba (--configure):
 subprocess installed post-installation script returned error exit status 1
Processing triggers for libc-bin (2.24-11+deb9u4) ...
Processing triggers for systemd (232-25+deb9u11) ...
Errors were encountered while processing:
 samba
E: Sub-process /usr/bin/dpkg returned an error code (1)

hortimech
Posts: 753
Joined: Wed Apr 08, 2015 5:52 pm

Re: Installing Samba

Thu Aug 22, 2019 10:47 am

What OS are you using ?
If it is raspbian, the default smb.conf, with all commented lines removed (lines that start with '#' or ';') looks like this:

Code: Select all

[global]
   workgroup = WORKGROUP
   log file = /var/log/samba/log.%m
   max log size = 1000
   logging = file
   panic action = /usr/share/samba/panic-action %d
   server role = standalone server
   obey pam restrictions = yes
   unix password sync = yes
   passwd program = /usr/bin/passwd %u
   passwd chat = *Enter\snew\s*\spassword:* %n\n *Retype\snew\s*\spassword:* %n\n *password\supdated\ssuccessfully* .
   pam password change = yes
   map to guest = bad user
   usershare allow guests = yes

[homes]
   comment = Home Directories
   browseable = no
   read only = yes
   create mask = 0700
   directory mask = 0700
   valid users = %S

[printers]
   comment = All Printers
   browseable = no
   path = /var/spool/samba
   printable = yes
   guest ok = no
   read only = yes
   create mask = 0700

[print$]
   comment = Printer Drivers
   path = /var/lib/samba/printers
   browseable = yes
   read only = yes
   guest ok = no
Which makes it a standalone server.
Check your smb.conf now, if it looks like the above it should work, so try starting the 'smbd' & 'nmbd' deamons.

Code: Select all

sudo systemctl start smbd
sudo systemctl start nmbd
Or

Code: Select all

sudo service smbd start
sudo service nmbd start
Or

Code: Select all

sudo /etc/init.d/smbd start
sudo /etc/init.d/nmbd start
Or, if all else fails

Code: Select all

sudo /usr/sbin/smbd -i
The last one will log to screen

hengreer
Posts: 5
Joined: Wed Aug 21, 2019 10:18 am

Re: Installing Samba

Thu Aug 22, 2019 11:15 am

I think I've solved that problem. I cleared it all out, purged it again, went and found the conf file and deleted it. Then whilst googling I found the advise to install the following.

Code: Select all

pi@raspberrypi:/ $ sudo apt-get install libsmbclient libwbclient0 python-dnspython python-samba python3-smbc samba-common samba-common-bin samba-dsdb-modules samba-libs samba-vfs-modules
Reading package lists... Done
Building dependency tree       
Reading state information... Done
The following packages were automatically installed and are no longer required:
  attr libfile-copy-recursive-perl tdb-tools update-inetd
Use 'sudo apt autoremove' to remove them.
0 upgraded, 0 newly installed, 10 reinstalled, 0 to remove and 0 not upgraded.
Need to get 0 B/7,292 kB of archives.
After this operation, 0 B of additional disk space will be used.
Preconfiguring packages ...
(Reading database ... 159157 files and directories currently installed.)
Preparing to unpack .../0-libwbclient0_2%3a4.5.16+dfsg-1+deb9u1_armhf.deb ...
Unpacking libwbclient0:armhf (2:4.5.16+dfsg-1+deb9u1) over (2:4.5.16+dfsg-1+deb9u1) ...
Preparing to unpack .../1-libsmbclient_2%3a4.5.16+dfsg-1+deb9u1_armhf.deb ...
Unpacking libsmbclient:armhf (2:4.5.16+dfsg-1+deb9u1) over (2:4.5.16+dfsg-1+deb9u1) ...
Preparing to unpack .../2-samba-common_2%3a4.5.16+dfsg-1+deb9u1_all.deb ...
Unpacking samba-common (2:4.5.16+dfsg-1+deb9u1) over (2:4.5.16+dfsg-1+deb9u1) ...
Preparing to unpack .../3-python-dnspython_1.15.0-1+deb9u1_all.deb ...
Unpacking python-dnspython (1.15.0-1+deb9u1) over (1.15.0-1+deb9u1) ...
Preparing to unpack .../4-python-samba_2%3a4.5.16+dfsg-1+deb9u1_armhf.deb ...
Unpacking python-samba (2:4.5.16+dfsg-1+deb9u1) over (2:4.5.16+dfsg-1+deb9u1) ...
Preparing to unpack .../5-python3-smbc_1.0.15.6-1_armhf.deb ...
Unpacking python3-smbc (1.0.15.6-1) over (1.0.15.6-1) ...
Preparing to unpack .../6-samba-common-bin_2%3a4.5.16+dfsg-1+deb9u1_armhf.deb ...
Unpacking samba-common-bin (2:4.5.16+dfsg-1+deb9u1) over (2:4.5.16+dfsg-1+deb9u1) ...
Preparing to unpack .../7-samba-dsdb-modules_2%3a4.5.16+dfsg-1+deb9u1_armhf.deb ...
Unpacking samba-dsdb-modules (2:4.5.16+dfsg-1+deb9u1) over (2:4.5.16+dfsg-1+deb9u1) ...
Preparing to unpack .../8-samba-vfs-modules_2%3a4.5.16+dfsg-1+deb9u1_armhf.deb ...
Unpacking samba-vfs-modules (2:4.5.16+dfsg-1+deb9u1) over (2:4.5.16+dfsg-1+deb9u1) ...
Preparing to unpack .../9-samba-libs_2%3a4.5.16+dfsg-1+deb9u1_armhf.deb ...
Unpacking samba-libs:armhf (2:4.5.16+dfsg-1+deb9u1) over (2:4.5.16+dfsg-1+deb9u1) ...
Setting up python-dnspython (1.15.0-1+deb9u1) ...
Setting up libwbclient0:armhf (2:4.5.16+dfsg-1+deb9u1) ...
Setting up samba-libs:armhf (2:4.5.16+dfsg-1+deb9u1) ...
Setting up samba-vfs-modules (2:4.5.16+dfsg-1+deb9u1) ...
Setting up python-samba (2:4.5.16+dfsg-1+deb9u1) ...
Setting up samba-common (2:4.5.16+dfsg-1+deb9u1) ...
Not replacing deleted config file /etc/samba/smb.conf
Install/upgrade will fail. To recover, please try:
 sudo cp /usr/share/samba/smb.conf /etc/samba/smb.conf
 sudo dpkg --configure -a
Setting up libsmbclient:armhf (2:4.5.16+dfsg-1+deb9u1) ...
Processing triggers for libc-bin (2.24-11+deb9u4) ...
Processing triggers for man-db (2.7.6.1-2) ...
Setting up samba-common-bin (2:4.5.16+dfsg-1+deb9u1) ...
Setting up samba-dsdb-modules (2:4.5.16+dfsg-1+deb9u1) ...
Setting up python3-smbc (1.0.15.6-1) ...
I noticed the error, ran the 2 lines it told me to, then tired to install samba again.

Code: Select all

pi@raspberrypi:/ $  sudo cp /usr/share/samba/smb.conf /etc/samba/smb.conf
pi@raspberrypi:/ $  sudo dpkg --configure -a
pi@raspberrypi:/ $ sudo nano /etc/samba/smb.conf
pi@raspberrypi:/ $ sudo apt-get install samba
It appears to have fixed the issue.

hortimech
Posts: 753
Joined: Wed Apr 08, 2015 5:52 pm

Re: Installing Samba [SOLVED]

Fri Aug 23, 2019 8:19 am

Bit lost now, If you now install winbind, I could talk you through provisioning a Samba AD DC, or to put it another way, you do not need most of the packages you installed.

By installing the 'samba' package, you should get these packages installed as well:

python-dnspython python-samba samba-common samba-common-bin samba-libs

So this just leaves (out of the packages you installed) : libsmbclient libwbclient0 python3-smbc samba-dsdb-modules samba-vfs-modules

Ignoring 'python3-smbc', these are:

libsmbclient: for client applications to talk to SMB servers using the SMB/CIFS protocol.

libwbclient0; for client applications to interact with the winbind pipe

samba-dsdb-modules: support for various Active Directory features

samba-vfs-modules: Virtual FileSystem modules

None of which have anything to do with a Samba standalone server.

So congratulations on fixing it, but I just do not see how ;-)

Return to “Beginners”