Samba error code 22

I configured my /etc/samba/smb.conf for a standalone server, removed all the printer stuff and checked its contents with testparm. It shows the following service definitions:

# Global parameters
[global]
	log file = /var/log/samba/log.%m
	logging = file
	map to guest = Bad User
	max log size = 1000
	obey pam restrictions = Yes
	pam password change = Yes
	panic action = /usr/share/samba/panic-action %d
	passwd chat = *Enter\snew\s*\spassword:* %n\n *Retype\snew\s*\spassword:* %n\n *password\supdated\ssuccessfully* .
	passwd program = /usr/bin/passwd %u
	server role = standalone server
	server string = %h server (Samba, Manjaro)
	unix password sync = Yes
	usershare allow guests = Yes
	workgroup = ARMINUX
	idmap config * : backend = tdb


[achat-mj-jaro]
	path = /home/jaro
	read only = No
	valid users = jaro


[achat-mj-ad]
	path = /home/AD@achat
	read only = No
	valid users = jaro


[achat-mj-bifimu]
	path = /mnt/bifimu
	read only = No
	valid users = jaro

In my pcmanfm network folder “network:///” I should see my Manjaro PC “achat” and the defined shares, however, there is nothing besides the Windows network.

In the samba log file I see:

######### 2022 03 26 1513 ### test mit neuem smb.conf

[2022/03/26 15:16:26.626809,  0] ../../source4/samba/server.c:626(binary_smbd_main)
  samba version 4.15.5 started.
  Copyright Andrew Tridgell and the Samba Team 1992-2021
[2022/03/26 15:16:26.627151,  0] ../../lib/util/become_daemon.c:150(daemon_status)
  daemon_status: daemon 'samba' : Starting process...
[2022/03/26 15:16:26.675359,  0] ../../source4/samba/server.c:861(binary_smbd_main)
  At this time the 'samba' binary should only be used for either:
  'server role = active directory domain controller' or to access the ntvfs file server with 'server services = +smb' or the rpc proxy with 'dcerpc endpoint servers = remote'
  You should start smbd/nmbd/winbindd instead for domain member and standalone file server tasks
[2022/03/26 15:16:26.675415,  0] ../../lib/util/become_daemon.c:119(exit_daemon)
  exit_daemon: daemon failed to start: Samba detected misconfigured 'server role' and exited. Check logs for details, error code 22

I do not understand why the samba service is not started, what is wrongly configured and would appreciate help.

Additional observation: I can enter the following commands

sudo smbd start
sudo nmbd start

After that the pcmanfm network folder shows achat and within achat my shares:

What is the explanation for all that?

Looking at the the log above I wonder if not mentioning the server role variable changes the result. It might be the default anyway.

Have you definitely enabled the smbd/nmbd services?

You can check their status with sudo systemctl status smbd.service and sudo systemctl status nmbd.service

You can start the service on the current run by substituting status in the above with start, and to have them start up automatically each boot, replace it with enable - i.e. sudo systemctl enable smbd.service and sudo systemctl enable nmbd.service

Apologies if that’s teaching grandmother to suck eggs.

I looked at your sharenames and noticed the locations in /home and /mnt

Those locations is begging for problems.

Use a dedicated structure outside the /home and /mnt and /run - so you can control the permissions without worrying the system inherit system permissions onto the shares making them inaccessible.

@lukewhite:

[jaro@achat ~]$ sudo -i
[sudo] Passwort... 
[achat ~]# systemctl status smbd.service 
Unit smbd.service could not be found.
[achat ~]# systemctl status nmbd.service 
Unit nmbd.service could not be found.

### so I tried to enable. I already knew those commands, however ...

[achat ~]# systemctl enable  smbd.service 
Failed to enable unit: Unit file smbd.service does not exist.
[achat ~]# systemctl enable  nmbd.service 
Failed to enable unit: Unit file nmbd.service does not exist.

Why do the services not exist?

Well, I do understand that I cannot enable a non-existing service for the next system start.

You say that the locations in /home and /mnt are likely to cause (permission) problems? I would like to understand your statement:

“Use a dedicated structure outside the /home and /mnt and /run - so you can control the permissions without worrying the system inherit system permissions onto the shares making them inaccessible.”

The link to “Basic Samba Setup and Troubleshooting 1” does not help me; it is like Chinese to me.

When I edited my smb.conf file I started from the template and modified as few lines as possible according to the instructions I read in the template. What was wrong with my approach?

You are of course free to do as you please.

I have been a system adminstrator on numerous sites and what I recommend is based by personal experience on how to administer shared resources using a predicatable structure to simplify maintenance and permissions.

Example

  • /data/smb/share1
  • /data/smb/share2

Set permissions on /data/smb using either ownership to your username or set readwrite to everyone.

/mnt is for temporary mounts and /home is for users home and is and the mount on boot sets inherited permissions and is thus readonly for everyone but root.

That is why it is wiser to create a dedicated structure like the /data tree example mentioned above.

I have written numerous topics on the topic of sharing and mounting both devices and remote shares - just search for [root tip].

On my systems running samba the command to start samba is systemctl start smb nmb not smbd nmbd .

Samba works, however, the error code 22 persists!

@ straycat
I believe you have got the solution to my question why my Manjaro won’t start the daemon processes. Naming of the services! Now, after the start of my Manjaro system, pcmanfm / network shows my PC “achat”. See the following #log1#.

My intended sharing works now and I might close this thread. However, I still do not understand why error 22 persists. For the sake of spreading Linux knowhow I would welcome additional comments. In particular I note this line in /var/log/samba/log.%m:

“You should start smbd/nmbd/winbindd instead for domain member and standalone file server tasks”

Yes, what I need is a standalone file server on my PC to serve in my home network and therefore I specified “server role = standalone server” in my above smb.conf file. The error 22 seemingly tells me what to do. Possibly I am too stupid to understand the instruction. Does it mean that the commands

“systemctl enable smb.service” and
“systemctl enable nmb.service”

are wrong to start a standalone server and instead of that I should invoke

“start sbmd” and
“start nmbd”

after login?

#log1#:

[achat ~]# systemctl status smb.service
○ smb.service - Samba SMB Daemon
     Loaded: loaded (/usr/lib/systemd/system/smb.service; disabled; vendor preset: disabled)
     Active: inactive (dead)
       Docs: man:smbd(8)
             man:samba(7)
             man:smb.conf(5)
[achat ~]# systemctl status nmb.service
○ nmb.service - Samba NMB Daemon
     Loaded: loaded (/usr/lib/systemd/system/nmb.service; disabled; vendor preset: disabled)
     Active: inactive (dead)
       Docs: man:nmbd(8)
             man:samba(7)
             man:smb.conf(5)

achat ~]# systemctl enable nmb.service
Created symlink /etc/systemd/system/multi-user.target.wants/nmb.service → /usr/lib/systemd/system/nmb.service.
[achat ~]# systemctl enable smb.service
Created symlink /etc/systemd/system/multi-user.target.wants/smb.service → /usr/lib/systemd/system/smb.service.

######################################### after reboot:

[jaro@achat ~]$ systemctl status smb.service
● smb.service - Samba SMB Daemon
     Loaded: loaded (/usr/lib/systemd/system/smb.service; enabled; vendor preset: disabled)
     Active: active (running) since Sat 2022-04-02 10:00:15 CEST; 3min 31s ago
       Docs: man:smbd(8)
             man:samba(7)
             man:smb.conf(5)
   Main PID: 1090 (smbd)
     Status: "smbd: ready to serve connections..."
      Tasks: 4 (limit: 18840)
     Memory: 16.1M
        CPU: 89ms
     CGroup: /system.slice/smb.service
             ├─1090 /usr/bin/smbd --foreground --no-process-group
             ├─1092 /usr/bin/smbd --foreground --no-process-group
             ├─1093 /usr/bin/smbd --foreground --no-process-group
             └─1094 /usr/lib/samba/samba/samba-bgqd --ready-signal-fd=46 --parent-watch-fd=12 --deb>

Apr 02 10:00:15 achat systemd[1]: Starting Samba SMB Daemon...
Apr 02 10:00:15 achat systemd[1]: Started Samba SMB Daemon.
Apr 02 10:00:15 achat systemd[1]: smb.service: Got notification message from PID 1094, but receptio>
[jaro@achat ~]$ systemctl status nmb.service
● nmb.service - Samba NMB Daemon
     Loaded: loaded (/usr/lib/systemd/system/nmb.service; enabled; vendor preset: disabled)
     Active: active (running) since Sat 2022-04-02 10:00:15 CEST; 3min 51s ago
       Docs: man:nmbd(8)
             man:samba(7)
             man:smb.conf(5)
   Main PID: 1088 (nmbd)
     Status: "nmbd: ready to serve connections..."
      Tasks: 1 (limit: 18840)
     Memory: 8.3M
        CPU: 98ms
     CGroup: /system.slice/nmb.service
             └─1088 /usr/bin/nmbd --foreground --no-process-group

Apr 02 10:00:15 achat systemd[1]: Starting Samba NMB Daemon...
Apr 02 10:00:15 achat systemd[1]: Started Samba NMB Daemon.

/var/log/samba/log.%m:

### 2022 04 02 2032 after enable of smb and nmb ###################
[2022/04/02 10:49:47.502358,  0] ../../source4/samba/server.c:626(binary_smbd_main)
  samba version 4.15.5 started.
  Copyright Andrew Tridgell and the Samba Team 1992-2021
[2022/04/02 10:49:47.502549,  0] ../../lib/util/become_daemon.c:150(daemon_status)
  daemon_status: daemon 'samba' : Starting process...
[2022/04/02 10:49:47.531474,  0] ../../source4/samba/server.c:861(binary_smbd_main)
  At this time the 'samba' binary should only be used for either:
  'server role = active directory domain controller' or to access the ntvfs file server with 'server services = +smb' or the rpc proxy with 'dcerpc endpoint servers = remote'
  You should start smbd/nmbd/winbindd instead for domain member and standalone file server tasks
[2022/04/02 10:49:47.531516,  0] ../../lib/util/become_daemon.c:119(exit_daemon)
  exit_daemon: daemon failed to start: Samba detected misconfigured 'server role' and exited. Check logs for details, error code 22

I don’t know about the error code but if you have samba working that’s good.You might check out Using Samba in your File Manager - Manjaro and see if you missed something setting it up.