What's new

[RT-N66U] samba disconnects / enabling samba logging

  • SNBForums Code of Conduct

    SNBForums is a community for everyone, no matter what their level of experience.

    Please be tolerant and patient of others, especially newcomers. We are all here to share and learn!

    The rules are simple: Be patient, be nice, be helpful or be gone!

plaut

Occasional Visitor
Running 3.0.0.4.374.38_2 on an RT-N66U with a 3T ext3 drive shared via samba (to a Seagate FreeAgent Theater+ client). Works fine, but after a day or two the client fails to connect and I have to restart the samba service on the router (smbd is still running, just not working). There's nothing in syslog and /var/log.samba is empty, presumably because "log level = 0" in /etc/smb.conf. Editing smb.conf and restarting doesn't help because it is overwritten on restart (even if set to read-only).

Two questions: 1) how do I enable samba logging? and 2) any idea what might be causing the disconnects?
 
Samba logging:
1) Edit the configuration:
# vi /etc/smb.conf
(log level = 2 is pretty chatty, 3 is very verbose, I have not tried anything above 3)
2) Restart just the smb service:
#service smb
 
Thanks for the suggestion, but as I mentioned, even if I edit /etc/smb.conf to change "log level", when I restart samba those changes are lost and the original smb.conf file has been regenerated somehow. If that's not true for others than something really strange is going on.

[btw, I have to run "service stop_samba" and "service start_samba" to start/stop the smbd/nmdb daemons.]
 
ok, it appears that "log level = 0" is hard-coded in /sbin/write_smb_conf (which apparently is called whenever samba is started). If write_smb_conf is "replaced" with an empty but executable dummy script (by "mount -o bind /root/dummy.sh /sbin/write_smb_conf"), /etc/smb.conf is deleted and not regenerated, so samba fails to start. Making progress though....
[update: if, however, the script creates /etc/smb.conf by copying it from somewhere else, samba does start.... :) ]
 
Last edited:
You need a postconf script to manipulate smb.conf. Use sed to replace the loglevel line with a new one that has a higher loglevel.
 
Was something actually written to the log file?

Were you able to see anything in /var/log.samba? I've have "log file = /var/log.samba" and "log level = 5" in smb.conf. A zero length log.samba file is created.

Did you need to do anything other than make the same changes I did? With those settings is something written to the log file when you start/stop samba?

Thanks
 
To be honest, I never got samba logging to work - even using the postconf script to set log level = 2, the log file was still zero length. I've taken to restarting samba daily with a cron script.
 
Last edited:
To be honest, I never got samba logging to work - even using the postconf script to set log level = 2, the log file was still zero length.

Oh well! I was hoping you had discovered the secret. It's obviously possible to do so as Merlin was able to suggest log level settings.

When I first started using the RT-AC66R about a year ago, I found that my Kodak printer was unable to access the Samba share. I spent quite a while trying to get the log file with no luck. I went so far as to use wireshark to examine the packets on the LAN. I could see the see the error message being reported but not the reason for it

Would anyone have an idea if there's another Samba distribution that would integrate with the Merlin build?

Mike
 
To be honest, I never got samba logging to work - even using the postconf script to set log level = 2, the log file was still zero length. I've taken to restarting samba daily with a cron script.
Same here. Anyone got any idea how to get samba logging to work on RT-N66U?
 
Same here. Anyone got any idea how to get samba logging to work on RT-N66U?
This is easy.
Create /jffs/scripts/smb.postconf

And add to it to your liking, find values you want to change in in /tmp/etc/smb.conf
Samples are:
Increase Log Level to 10 (max) --> pc_replace "log level = 0" "log level = 10" $CONFIG
Logfile on sda1/logs --> pc_replace "log file = /var/log.samba" "log file = /tmp/mnt/sda1/logs/log.samba" $CONFIG
Biger Logfile (500 KB) --> pc_replace "max log size = 5" "max log size = 500" $CONFIG

This would look like so:
Code:
#!/bin/sh
CONFIG=$1
source /usr/sbin/helper.sh
pc_replace "log level = 0" "log level = 10" $CONFIG
pc_replace "log file = /var/log.samba" "log file = /tmp/mnt/sda1/logs/log.samba" $CONFIG
pc_replace "max log size = 5" "max log size = 500" $CONFIG
make the file executable:
Code:
chmod a+rx /jffs/scripts/smb.postconf
Reboot and good luck with your troubleshooting!
 
Last edited:
Yeah, we know that. The trouble is that it doesn't work. At least not on the RT-N66U.
Or to be more specific, whatever you set for "log level", either in smb.conf or on the command line, is ignored. Only log level 0 events are logged.
 
my solution

was to buy a WD MyCloud 2TB NAS for $150. I wish I'd done it in the beginning, I spent a lot more than $150 of my time on trying to get it going.
 
Well after much trial and error I have come to the following conclusions regarding samba logging:

1) I had assumed that the "log level" parameter was being ignored. This is not the case. Setting it to 100 for example will produce lots of output. The parameter is recognised in smb.conf as well as on the command line.

2) Despite the above, log level messages >0 and <=10 are being supressed.

3) Having trawled through the source code, my best guess is that it is supressed in src/router/samba3/source/include/local.h (for later reference in debug.h)
Code:
/* the maximum debug level to compile into the code. This assumes a good
   optimising compiler that can remove unused code
   for embedded or low-memory systems set this to a value like 2 to get
   only important messages. This gives *much* smaller binaries
*/
#ifndef MAX_DEBUG_LEVEL
#define MAX_DEBUG_LEVEL 0
#endif
Now my knowledge of C programming is extremely limited so I could well be wrong about this. Could someone check my theory out?

If this is the case then my question to RMerlin would be: can we try building samba with "MAX_DEBUG_LEVEL 2" or "MAX_DEBUG_LEVEL 3" and see how that goes?
 
Last edited:
Well after much trial and error I have come to the following conclusions regarding samba logging:

1) I had assumed that the "log level" parameter was being ignored. This is not the case. Setting it to 100 for example will produce lots of output. The parameter is recognised in smb.conf as well as on the command line.

2) Despite the above, log level messages >0 and <=10 are being supressed.

3) Having trawled through the source code, my best guess is that it is supressed in src/router/samba3/source/include/local.h (for later reference in debug.h)
Code:
/* the maximum debug level to compile into the code. This assumes a good
   optimising compiler that can remove unused code
   for embedded or low-memory systems set this to a value like 2 to get
   only important messages. This gives *much* smaller binaries
*/
#ifndef MAX_DEBUG_LEVEL
#define MAX_DEBUG_LEVEL 0
#endif
Now my knowledge of C programming is extremely limited so I could well be wrong about this. Could someone check my theory out?

If this is the case then my question to RMerlin would be: can we try building samba with "MAX_DEBUG_LEVEL 2" or "MAX_DEBUG_LEVEL 3" and see how that goes?
RMerlin: Any thoughts on doing this?
 
No idea, not really a Samba expert.
 

Latest threads

Support SNBForums w/ Amazon

If you'd like to support SNBForums, just use this link and buy anything on Amazon. Thanks!

Sign Up For SNBForums Daily Digest

Get an update of what's new every day delivered to your mailbox. Sign up here!
Top