WSL: Samba does not work

  • A brief description

After installation, samba server fails to start/restart:

username@DESKTOP-123:~/test$

sudo service smbd restart initctl: Unable to connect to Upstart: Failed to connect to socket /com/ubuntu/upstart: Connection refused * Stopping SMB/CIFS daemon smbd [ OK ] * Starting SMB/CIFS daemon smbd [fail]

I have one very simple share directory, and no shared directory appears on exploring after this fail.

  • Expected results

a. Fail should not appear. b. Directory sharing should start working.

  • Actual results (with terminal output if applicable)

sudo service smbd restart initctl: Unable to connect to Upstart: Failed to connect to socket /com/ubuntu/upstart: Connection refused * Stopping SMB/CIFS daemon smbd [ OK ] * Starting SMB/CIFS daemon smbd [fail]

  • Your Windows build number

Version 1607 (OS Build 14393.10)

  • Steps / commands required to reproduce the error

Fresh WSL install

sudo apt-get install samba sudo smbpasswd -a username mkdir test sudo nano /etc/samba/smb.conf

Add in the end:

[share] path = /home/username/test valid users = username read only = no

Then run the command:

sudo service smbd restart

  • Strace of the failing command

log.txt

  • Required packages and commands to install

samba

See our contributing instructions for assistance.

About this issue

  • Original URL
  • State: closed
  • Created 10 years ago
  • Comments: 34

Most upvoted comments

Samba has worked out of the box since ipv6 (#982) and inotify (#216) were added. There is no such thing as officially supported or unsupported in WSL.

The problem is not WSL or Samba, but that Windows hogs port 445 on all interfaces. To compound matters, there is no such thing as net use L: smb://localhost:3445/myshare. Which is just sad. So very very sad.

I have tried to redirect smb, but this SO post and this SF post are not encouraging. I went so far as to try using a loopback OpenVPN tunnel, but long story short, failed miserably. I am pretty sure it can be done one way or another with Windows Packet Filter, but having been defeated once already I haven’t pursued it. I am sure a Windows networking guru would know how to make this work (looking at you, @JasonLinMS).

I have looked a little into doing it with dokany and libsmbclient (message), but that route does smack of “effort”.

Anyway, in the mean time WebDAV might hold you over. Screencap 'cause why not. And you can vote for editing WSL files in Windows on User Voice here.

webdav

I initially opened up this issue quite some time ago, now we have moved to Ubuntu 16.04 with added support for networking. Samba installs and starts now fine (compared to errors noted initially), but shares never appear and/or get mapped.

Given that its not possible to edit WSL files in Windows, Samba could have been one way to be able to edit the Linux files (other options as WinSCP do work but its not well integrated in Windows Explorer as Samba). What I would like to understand is:

  • Is Samba currently officially not supported?
  • Is it expected to be supported in future releases?

Thanks!

The original request here was for smbd, which has been working for some time now since #982 #468 #216 and some other stuff was addressed. Let’s call it Creators Update (15063) or thereabouts.

Mounting SMB/CIFS client shares (a different request) was addressed with the filesystem improvements noted a couple of posts back. Commandline smbclient works too, probably for ages. Mounting native Samba shares would require FUSE per User Voice.

Note that although smbd is operable, that doesn’t make it especially useful for interop with Windows on localhost, which is what a lot of people really want here. But this is because the CIFS port is already spoken for by Windows, not because smbd is broken on WSL. But if you fire up smbd on a custom port on WSL, you could for example connect to it over the wire with a Samba client using native Linux. Connecting over localhost would require either (a) WSL supporting it’s own network space like Docker and other VMs, or (b) Windows supporting connecting to CIFS shares on a non-default port (like WebDAV allows).

The OP in this thread is about running a CIFS server on WSL, which “works” per @GSam (comment), but isn’t especially useful at the moment because a CIFS server on WSL will collide with the CIFS server running on Windows unless you use a nonstandard port.

You just tried running a Samba client on WSL, which won’t work right now because no FUSE. User Voice is here.

@krisbulman It looks like it still needs some code removed (for SO_REUSEPORT, or implemented on their side). I’ll see if you can disable it without any code changes, but you’d probably still need to recompile regardless.

It seems to exist outside the bash terminal. Just transferred a file from my Samba server in bash to an Ubuntu VM in Virtualbox, no corruption or anything.

(Accessing shares on Windows natively seems to require 445, so some redirector is probably required)