The Surgery | The doctor is IN

TAG | Samba

Another self-indulgent blog post, so next time I have this problem, I don’t waste hours trying to fix something I’ve successfully tackled in the past. Hopefully this helps someone else.

The mysterious, magical Samba service is great when it works. When it doesn’t, it can be extraordinarily frustrating.

Problem

You can’t add Samba users at your Linux console. You get this error; for example, by issuing an “smbpasswd -a” command:

Unable to modify TDB passwd: NT_STATUS_UNSUCCESSFUL!
Failed to add entry for user xyz.
Failed to modify password entry for user xyz

The username is a valid Linux user, and the account is unlocked.

I also tried deleting the Samba user with an “smbpasswd -x”, but to no avail. Stopping and starting the SMB and NMB services does not resolve the problem.

My system details

OS / Kernel: Fedora 9 – 2.6.27.25-78.2.56.fc9.i686
Samba package: samba-3.2.11-0.28.fc9.i386

Solution

** WARNING **!!  This solution worked for me, but obviously, no warranties are made  for any other systems. Make backups and proceed at own risk.

A post on a Debian forum suggested that the Samba password file might be corrupt. The password file is a binary called “passdb.tdb” and will be re-created, if it doesn’t exist, when SMB and NMB are restarted.

Note that you’ll need to re-add all your Samba users and passwords!

  • Locate passdb.tdb
  • Make a backup of passdb.tdb
  • Remove passdb.tdb
  • Stop the SMB and NMB daemons
  • Start the SMB and NMB daemons

At this point you should see that a new, much smaller passdb.tdb has been created.

Try adding your user again with an “smbpasswd -a” command. Add your other Samba users with the same command.

It worked for me. Good luck.

· · · · ·

I recently blogged about Western Digital’s new WD TV Live Media Streamer.

It’s going great guns, but I had some difficulty setting up Samba shares on my Linux server, and seeing these shares from the WD TV Live.

“Samba” is an implementation of the Server Message Block (SMB) networking protocol. Samba shares look like Windows shares to a Windows workstation, and behave the same way. Samba can also be setup to do clever things like emulate a Windows Primary Domain Controller, so the Windows workstations on the network think they’re talking to a Windows PDC, when in actual fact they’re talking to a Linux system emulating a PDC, providing enormous flexibility and saving thousands of dollars in Microsoft licensing.  Pretty cool, huh?

But I digress.  At home, I have a Windows workgroup. I also have a Linux server running Fedora 9 which I use for my internet gateway, firewall, DHCP, Network Address Translation (NAT) and other stuff. For most people, all this stuff is done by their ADSL router or similar device. But I’m not like normal people. And I’m running a business from home and I need the flexibility which a Linux server affords.

I wanted to have all my media on an external (portable) drive, connected to the Linux server, which is always on. Then I wanted to “share” this drive on the network, so I could access it from the new WD TV Live.

This is not a tutorial in connecting USB devices and mounting external drives in Linux. Also, this isn’t a tutorial in setting Linux file and directory permissions. For help doing that, you’ll need to hit Google.

Anyway, my new drive was mounted in my Linux file system at “/home/ron/elements”. (Co-incidentally it’s a Western Digital ‘Elements’ external hard disk.) I didn’t have Samba installed, so I installed it like this:

yum install samba

“Yum” is the Yellow-Dog Updater which is an easy and safe way to install commonly-used Fedora packages via the internet. I added my username “ron” to the SMB users’ file, like this:

/usr/bin/smbpasswd -a ron

…and added a new, browsable share in the Samba config file, like this:

[elements]
comment = WD Elements Share
path = /home/ron/elements
public = yes
writable = yes
createmask = 0777
directorymask = 0777
browseable = yes
printable = no

Then I started Samba, and added it to the correct startup runlevels like this:

service smb start
service nmb start
chkconfig smb on
chkconfig nmb on

All good! I could see the share by browsing on a Windows machine to the IP address, like this:

\\192.168.2.2\elements

…BUT a hit a brick wall at this point.  There were two problems which I couldn’t resolve. The second, I suspected, was directly related to the first:

  1. I couldn’t browse the machine by its NetBIOS name, “derek”, which I’d specified in the smb.conf file, and
  2. The WD TV Live couldn’t see the Samba share.

Graeme Callaghan helped me over this hurdle; with another 5 minutes fiddling, I had the problem solved.

Graeme’s Fix for Samba – NetBIOS problems – don’t forget your DHCP daemon!

There were two settings in the Samba config file which I had left as the default, being “remmed out”.  These were:

wins support = yes
dns proxy = yes

I un-remarked these.

Then, I un-remarked a critical setting in my DHCP server’s configuration file, which was also on the same machine:

option netbios-name-servers  192.168.2.2;

This setting controls NetBIOS name visibility on your network. If your Samba server is on a different physical machine, point the IP address in your DHCP config file to the Samba machine’s IP address.

Then I restarted dhcpd, smb & nmb. Low-and-behold, my Fedora server was suddenly browsable by its NetBIOS name; e.g.

\\derek\elements

Even better, The WD TV Live picked up the changes straight away.  The server “DEREK” was now available in my list of “Shared Folders” on the WD TV Live menu.

I needed to *turn off* a setting in the WD TV Live called Settings / Network Setting / Auto login to network share. Then I browsed to DEREK in the Video / Shared Folders list, entered my network credentials (which I had created earlier with the “smbpasswd” command) and verified I could see all the folders correctly and access the media OK. I then reset the Auto login to network share to ON so I wasn’t prompted for a username and password every time I tried to access this network resource.

There seems to be a lot of consternation on message boards about WD TV Live connecting to Samba shares. It’s easy when you know how (thanks again Graeme). Hopefully this is useful to someone.

For info, package versions are:

  • samba-3.2.11-0.28.fc9.i386
  • dhcp-4.0.0-22.fc9.i386

· · · · · ·

Theme Design by devolux.nh2.me