Samba troubleshooting
Samba can be a real pain when it wants to be, occasionally, for seemingly no reason at all it stops working (after service restart), and then maybe 30min later, with no configuration changes it just starts working again. Below are some of the ways that I have (very unscientifically) gotten around it.
Troubleshooting Tools
iftop show network activity on interface nfsstat show r/w operations on NFS filesystems cifsstat show r/w operations on CIFS filesystems smbclient list shares on ip-addr (see usage)
sudo smbclient \ -L //127.0.0.1 \ -U login-user \ --list
Debugging Error Codes
NOTE:
understanding not confirmed
Mount errors are visible in
dmesg
.
The error code produced combines bitwise OR flags.
# man mount RETURN CODES mount has the following return codes (the bits can be ORed): 0 success 1 incorrect invocation or permissions 2 system error (out of memory, cannot fork, no more loop devices) 4 internal mount bug 8 user interrupt 16 problems writing or locking /etc/mtab 32 mount failure 64 some mount succeededSay we get the error:
[ 10.361390] CIFS: Attempting to mount //192.168.1.220/audiobooks [ 10.361439] CIFS: VFS: Error connecting to socket. Aborting operation. [ 10.361442] CIFS: VFS: cifs_mount failed w/return code = -101We can deconstruct the error-code into specific errors
# error code was '-101' bin(101) >>> 0b1100101 # \\ \ \ # \\ \ +-- incorrect invocation or permissions # \\ +-- internal mount bug # \+-- mount failure # +-- some mount succeded
Large File Copy Hangs
explicitly set SMB protocol version to 3.0 fixed this entirely for me.
mount //server/mount /mnt/mounted -o vers=3.0
No Write Permissions
There are a few possible causes:
- writing files is not allowed in smb.conf
- directories/files on server not writable by samba's login user
- directories/files on client not owned by user/assigned appropriate permissions
Frozen following Sleep/Suspend
Use systemd sleep hooks to unmount remote filesystems on sleep.
# /etc/systemd/system/unmount-remotefs.service [Unit] Description=unmount remote filesystems before sleep Before=sleep.target StopWhenUnneeded=yes [Service] Type=oneshot RemainAfterExit=yes ExecStart=umount -a -t cifs ExecStop=mount -a -t cifs [Install] WantedBy=sleep.target
For windows to load a .dll, it needs 'rw' permissions.
You can manually adjust the real file permissions (preferred), but if you are in an environment where this cannot be done, you can force the shares to mount as a user that has rw permissions on the file.
[your_share] force user=root # or preferably owner of shares