WelcomeWelcome | FAQFAQ | DownloadsDownloads | WikiWiki

Author Topic: samba4 not working  (Read 1494 times)

Offline DrRob

  • WikiUser
  • *
  • Posts: 37
samba4 not working
« on: July 01, 2017, 12:40:19 AM »
Hi,

I'm trying to set up samba4 server, but it's not working.  Here are my steps:
  • Download and flash piCore-9.0.3 to an SD card
  • Transfer SD card to Pi (an original model B) and boot
  • Find out the IP address of the Pi
  • ssh to the pi (user: tc, password: piCore)
  • resize the second partition (see the README)
  • filetool.sh -b (to save the generated ssh host key)
  • sudo reboot (so the kernel can see the enlarged partition)
  • ssh in again
  • resize the filesystem (see the README)
  • add "mount /mnt/sda1" to /opt/bootlocal.sh (the files I want to share are on a USB memory stick)
  • mount /mnt/sda1
  • tce-load -wi samba4
  • install my smb.conf to /usr/local/etc/samba (it makes a directory from /mnt/sda1 available via a share)
  • add /usr/local/etc/samba to /opt/.filetool.lst
  • sudo adduser and sudo smbpasswd -a for a couple of users that are referenced in the smb.conf
  • filetool.sh -b (to save the setup so far)
  • sudo reboot (just in case...)
  • how are you supposed to set up the samba service to run automatically?  For now I'm running it manually, with debugging on...
  • sudo smbd -i -d20
  • ...results in lots of debug, ending with "waiting for connections".  So far, so good.
  • Attempt to connect to the share from a Macbook, using the IP address of the Pi
  • A pause of a couple of seconds, then more debug output from samba, ending with "Server exit (failed to receive smb request)" and "Terminated" twice.  :-(

I'll attach a gzip'd file containing the debug output.

What am I doing wrong?

Thanks,
Rob.

Offline Misalf

  • Hero Member
  • *****
  • Posts: 1597
Re: samba4 not working
« Reply #1 on: July 01, 2017, 01:13:25 AM »
Code: [Select]
sudo /usr/local/etc/init.d/samba start
Download a copy and keep it handy: Core book ;)

Offline DrRob

  • WikiUser
  • *
  • Posts: 37
Re: samba4 not working
« Reply #2 on: July 01, 2017, 01:34:36 AM »
/usr/local/etc/init.d/samba doesn't exist...

Offline Misalf

  • Hero Member
  • *****
  • Posts: 1597
Re: samba4 not working
« Reply #3 on: July 01, 2017, 01:57:15 AM »
Oh, you're right. I modified my copy to include that script.
What it basically does is
Code: [Select]
mkdir -p /var/lib/samba
mkdir -p /usr/local/etc/samba/private
/usr/local/sbin/nmbd -D
/usr/local/sbin/smbd -D
Download a copy and keep it handy: Core book ;)

Offline DrRob

  • WikiUser
  • *
  • Posts: 37
Re: samba4 not working
« Reply #4 on: July 01, 2017, 10:23:49 PM »
Thanks for that, but unfortunately smbd still crashes when I try to open the share.  :-( 

(nmbd is fine.)

Offline DrRob

  • WikiUser
  • *
  • Posts: 37
Re: samba4 not working
« Reply #5 on: July 01, 2017, 10:27:54 PM »
Ah, ok, apparently that's normal when running "smbd -i": https://lists.samba.org/archive/samba/2012-September/169099.html (which makes that mode kinda useless...).

Now I see a different error in /usr/local/var/log/samba/smbd.log:

  check_ntlm_password:  Authentication for user [recorder] -> [recorder] FAILED with error NT_STATUS_NO_SUCH_USER

so that's progress.

Offline Paul_123

  • Sr. Member
  • ****
  • Posts: 397
Re: samba4 not working
« Reply #6 on: July 02, 2017, 03:15:10 AM »
You have to create the samba user/password files.

smbpasswd -s -a tc

This will create everything needed for authentication..... the files are saved in /usr/local/var/lib/samba so be sure you add these to you backups.

I believe that the user name you use above has to be a username on the piCore system.

Offline DrRob

  • WikiUser
  • *
  • Posts: 37
Re: samba4 not working
« Reply #7 on: July 02, 2017, 12:59:59 PM »
Thanks Misalf and Paul_123, I have it working now.  Tomorrow I'll post the working bullet-list of steps in case anyone else needs to do this.

Offline DrRob

  • WikiUser
  • *
  • Posts: 37
Re: samba4 not working
« Reply #8 on: July 03, 2017, 07:21:04 AM »
So, here's a verified list of steps to set up piCore as a Samba server:
  • Download and flash piCore-9.0.3 to an SD card
  • Transfer SD card to Pi (an original model B) and boot
  • Find out the IP address of the Pi
  • ssh to the pi (user: tc, password: piCore)
  • resize the second partition (see the README)
  • filetool.sh -b (to save the generated ssh host key)
  • sudo reboot (so the kernel can see the enlarged partition)
  • ssh in again
  • resize the filesystem (see the README)
  • add "mount /mnt/sda1" to /opt/bootlocal.sh (the files I want to share are on a USB memory stick)
  • mount /mnt/sda1
  • tce-load -wi samba4
  • install my smb.conf to /usr/local/etc/samba (it makes a directory from /mnt/sda1 available via a share)
  • add the following to /opt/.filetool.lst:
Code: [Select]
/usr/local/etc/samba
/usr/local/etc/init.d/samba
/usr/local/var/lib/samba
  • sudo adduser and sudo smbpasswd -a for a couple of users that are referenced in the smb.conf (I see some output from smbpasswd on the first run that looks like errors, but it seems to be ok)
  • create file /usr/local/etc/init.d/samba containing:
Code: [Select]
mkdir -p /var/lib/samba
mkdir -p /var/log/samba
mkdir -p /usr/local/etc/samba/private
/usr/local/sbin/nmbd -D
/usr/local/sbin/smbd -D
  • sudo chmod +x /usr/local/etc/init.d/samba
  • add to the end of /opt/bootlocal.sh:
Code: [Select]
/usr/local/etc/init.d/samba start
  • filetool.sh -b
  • sudo reboot
  • The network share should be available now, by IP address or by share name

Offline Misalf

  • Hero Member
  • *****
  • Posts: 1597
Re: samba4 not working
« Reply #9 on: July 03, 2017, 07:56:49 AM »
Code: [Select]
/usr/local/etc/init.d/samba start
If the script you created (/usr/local/etc/init.d/samba) doesn't use any arguments, the  start  option can (or should?) be omitted.
Download a copy and keep it handy: Core book ;)

Offline DrRob

  • WikiUser
  • *
  • Posts: 37
Re: samba4 not working
« Reply #10 on: July 04, 2017, 12:49:57 PM »
True, it's a very minimalistic version of the init script.

I'm wondering if there's a package containing a service management tool that would look after starting up samba and restarting it if it dies.  Something to add to the to-do list...

Offline njs

  • WikiUser
  • *
  • Posts: 25
Re: samba4 not working
« Reply #11 on: October 09, 2017, 07:49:43 PM »
So, here's a verified list of steps to set up piCore as a Samba server:
  • install my smb.conf to /usr/local/etc/samba (it makes a directory from /mnt/sda1 available via a share)

Where do we find your smb.conf example?

Offline njs

  • WikiUser
  • *
  • Posts: 25
Re: samba4 not working
« Reply #12 on: October 09, 2017, 08:28:43 PM »
Also, I cannot seem to even create an smb.conf.  Even using "sudo" I get "-sh: can't create sbm.conf: Permission denied"

Offline DrRob

  • WikiUser
  • *
  • Posts: 37
Re: samba4 not working
« Reply #13 on: October 09, 2017, 11:05:08 PM »
Quote
Where do we find your smb.conf example?

SMB configuration is a bit out of scope of this discussion, but see the attached example.  Note that I have a USB stick plugged into the Pi with a "recordings" directory at its root, so the "path = /mnt/sda1/recordings" in this smb.conf is valid, and I've created a couple of users to match those quoted in smb.conf.

HTH,
Rob.

Offline DrRob

  • WikiUser
  • *
  • Posts: 37
Re: samba4 not working
« Reply #14 on: October 09, 2017, 11:05:40 PM »
Also, I cannot seem to even create an smb.conf.  Even using "sudo" I get "-sh: can't create sbm.conf: Permission denied"

Please post the command-line you're trying.