You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
That's probably because the service command requires upstart, which isn't working. So anything that uses upstart or service likely fails with the same message.
You could always look at /etc/init.d/smbd or the smbd docs (whatever they are called) to see if it is possible to launch the daemon manually, that is, without using the service command. (You could, for example, try to launch it in one window, then minimize that window.)
Otherwise what you are reporting is that no service works, and no program will continue running when you close the window or log out, which we already knew.
rodrymbo thanks for the comment, but where is the issue reported that says no service will start? The link you provided is a feature request to let services run after windows is closed, which is not what I have asked about.
Yeah, I looked briefly for UserVoice entries about service or upstart, and finally just used the "continue running" entry, since that is a prerequisite for services anyway, and getting it running sort of implies getting all services and daemons working. But you'd be justified in starting your own UserVoice entry for upstart. ;-)
I'm pretty sure upstart expects to be started by init at boot time, and I haven't figured out a way to do that from bash in WSL manually, though I haven't tried very hard.
For reference, sshd doesn't start with the normal sudo service ssh start command (which I think uses upstart), but it does from sudo /etc/init.d/ssh start, which is just a bash script. Maybe samba can start the same way?
Samba might also fail if it does not recognize the filesystem (which it won't, at least right now). Samba uses filesystem information to determine if unix permissions (or other linux-only features) can be assigned or not.
Blocking on #468here. Guessing smbd will hit inotify soon after that. Anyway, once #468 is addressed, starting another CIFS server on the same IP and port as the one already running there is going to be somewhat problematic.
There's inotify which is fixed, but it also needs #468, which is still in the works. I am assuming here that people understand there is already something somewhat important occupying localhost:139/445 on your Windows machine. You can pick a different port, but I have to wonder about the glaring absence of people mentioning that when they "try samba".
I've managed to get as far as smbd running, but it can't seem to bind to the port (despite using a seemingly unused one). As a start, I've just tried to get it to accept guest connections with the following smb.conf:
Last bit of log:
open_socket_in(): setsockopt: SO_REUSEPORT = true on port 65500 failed with error = Invalid argument
open_socket_in(): setsockopt: SO_REUSEPORT = true on port 65501 failed with error = Invalid argument
open_socket_in(): setsockopt: SO_REUSEPORT = true on port 65500 failed with error = Invalid argument
smbd_open_one_socket: open_socket_in: Address already in use
open_socket_in(): setsockopt: SO_REUSEPORT = true on port 65501 failed with error = Invalid argument
smbd_open_one_socket: open_socket_in: Address already in use
reloading printcap cache
cups_pcap_load_async: already waiting for a refresh event
reload status: error
waiting for connections <------ Neato
It seems that the Linux subsystem does not like 0600 permissions (on reopen possibly) and so I went through the code and set it to 0660 + deleted the old tdb files.
After disabling the ipv6 handling code I've managed to establish a local connection within bash. Still trying to determine if the share is visible outside of bash.
~/samba$ sudo bin/smbclient -L localhost -p 1234 --option='interfaces = lo'
sudo: unable to resolve host DESKTOP-C8HLOCF
WARNING: no network interfaces found
Enter root's password:
tdb(/usr/local/samba/var/lock/gencache_notrans.tdb): tdb_open_ex: tdb_new_database failed for /usr/local/samba/var/lock/gencache_notrans.tdb: Invalid argument
tdb(/usr/local/samba/var/lock/gencache_notrans.tdb): tdb_open_ex: tdb_new_database failed for /usr/local/samba/var/lock/gencache_notrans.tdb: Invalid argument
tdb(/usr/local/samba/var/lock/gencache_notrans.tdb): tdb_open_ex: tdb_new_database failed for /usr/local/samba/var/lock/gencache_notrans.tdb: Invalid argument
Domain=[WORKGROUP] OS=[Windows 6.1] Server=[Samba 4.6.0pre1-DEVELOPERBUILD]
Sharename Type Comment
--------- ---- -------
mapped Disk
IPC$ IPC IPC Service (Samba 4.6.0pre1-DEVELOPERBUILD)
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)
There's a read-only Ext4 FUSE implementation here. It was done for OSX but a Windows port should be possible in theory (anything is "possible"). Ext4 is a different animal than SMB/NFS though, as you are dealing with the block layer, say on a USB device. If one were to do that users/permissions aren't an issue because it's a real Ext4 filesystem. [Incidentally there is a USB over IP project.]
Anyway what I was referring to was that one should be able to do a SMBNetFS port to Windows with some effort. With SMB/NFS you just need a socket API, which Mingw-w64 is happy to provide. A CLI been done before. There's a userspace NFS server for Linux, although I don't think anyone has tried it on WSL yet. The open source NFS 4 client for Windows is a little stale but I assume could be resurrected. And then of course the is the native windows NFS client for Windows 10 Enterprise.
Which is to say, sooner or later someone is going to mount a WSL VolFs (/home) on Windows.
As for permissions, that's on Dokany's TODO list. Not that I suspect anyone probably cares a lot, as I mentioned in another thread. People have been mounting SMB/NFS shares as 'user whatever' for 25 years.
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?
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, Jason Lin (@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.
Reacted by waqarz, Jack Hammons, Kris Bot, Garming Sam and Sean Newell
Thanks therealkenc for the detailed overview. I am now also trying to move/keep all my data in Windows filesystem as suggested by the MS post; symbolic links also seem to be fully functioning as well, so may be this solution addresses all my use cases.
waqarz - junctions, sorta; symbolic links, no. You'll still find yourself in a state of grief if you try to, for example, clone a git repo with symlinks in WSL and use them in Windows, and visa-versa. But I gather they are looking at it (#1475).
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).
therealkenc Could there not also be the possibility of forcing Windows to share the CIFS port with WSL instead of forcing Windows to recognize a non-default port? Some type of QoS/Load balancing that determines what needs the port more and ability to set certain apps within WSL to a higher priority than something in Windows that's not being utilized 100% of the time. Perhaps also another possibility is allowing ports such as CIFS and SSH to accept simultaneous use from both Windows and WSL? This would seem to me to be the better solution than using a non-default port that could potentially be compromised by anybody wanting to a run a port-scan against your computer/network and noticing an unusual port being open. Pen testers would have a field day with the non-default ports being utilized for services that don't belong there.
Could there not also be the possibility of forcing Windows to share the CIFS port with WSL instead of forcing Windows to recognize a non-default port?
The problem here is Windows CIFS hogs listening address 0.0.0.0. Even if you could convince the greater Windows group to "share", which let's just cut to the chase and concede isn't in the cards, you have no priority (differentiation) to hang your psudo-QoS hat on. WSL localhost is Windows localhost.
If you differentiate "WSL localhost" and "Win32 localhost", well, that's pretty much the definition an address namespace; in other words option (a). It isn't really a load balancing analogy. If I fire up smbclient on WSL targeting destination localhost, those packets need to be routed with specificity. I might want WSL Samba listening on 445. I might want Windows CIFS on 445. That isn't "sharing". That's routing.
But yes, in short, if WSL supported all the routing/filter goodness of Real Linux, we'd be golden.
This would seem to me to be the better solution than using a non-default port that could potentially be compromised by anybody wanting to a run a port-scan against your computer/network and noticing an unusual port being open.
No; whatever the port scanning attackers think they intend to do on port 3445 they can do on port 445. 127.0.0.1:3445 can't be compromised any easier or harder than Samba running in a VM on 192.168.0.123:445 on the same machine. Ditto goes for ssh on 2222 or apache2 on 8080.
therealkenc There's actually a way to disable the Windows CIFS server. I don't know what the implications are, but it could be useful. The Samba team seem to have played around with it a little. It's probably of most use to you to figure out what to do with it. Do you have somewhere I can send it?
Yeah I almost mentioned forgoing Windows CIFS as a possible scenario, but we were already straying from actionable WSL territory with respect to the OP and I thought better to leave that implied. Link whatever you got here if you like; no harm in that (shrug). But folks will overall probably get better service from being involved with the Samba community, as with any other target platform.
Activity
rodrymbo commentedon Aug 4, 2016
That's probably because the service command requires upstart, which isn't working. So anything that uses upstart or service likely fails with the same message.
You could always look at /etc/init.d/smbd or the smbd docs (whatever they are called) to see if it is possible to launch the daemon manually, that is, without using the service command. (You could, for example, try to launch it in one window, then minimize that window.)
Otherwise what you are reporting is that no service works, and no program will continue running when you close the window or log out, which we already knew.
waqarz commentedon Aug 4, 2016
rodrymbo thanks for the comment, but where is the issue reported that says no service will start? The link you provided is a feature request to let services run after windows is closed, which is not what I have asked about.
rodrymbo commentedon Aug 4, 2016
Yeah, I looked briefly for UserVoice entries about service or upstart, and finally just used the "continue running" entry, since that is a prerequisite for services anyway, and getting it running sort of implies getting all services and daemons working. But you'd be justified in starting your own UserVoice entry for upstart. ;-)
I'm pretty sure upstart expects to be started by init at boot time, and I haven't figured out a way to do that from bash in WSL manually, though I haven't tried very hard.
For reference, sshd doesn't start with the normal sudo service ssh start command (which I think uses upstart), but it does from sudo /etc/init.d/ssh start, which is just a bash script. Maybe samba can start the same way?
fpqc commentedon Aug 4, 2016
Samba might also fail if it does not recognize the filesystem (which it won't, at least right now). Samba uses filesystem information to determine if unix permissions (or other linux-only features) can be assigned or not.
therealkenc commentedon Aug 5, 2016
Blocking on #468 here. Guessing
smbdwill hit inotify soon after that. Anyway, once #468 is addressed, starting another CIFS server on the same IP and port as the one already running there is going to be somewhat problematic.dreyks commentedon Aug 8, 2016
/var/log/samba/log.smbdsaysERROR: Could not determine network interfaces, you must use a interfaces config line. This may be caused bySettings interfaces in
smb.confdoes not do a thingdrrob1 commentedon Oct 8, 2016
I just want to add that I cannot get samba to work either, on bash on windows10. I'm getting the same error.
Is there any work-around that has been developed since August 4?
fpqc commentedon Oct 8, 2016
Rob Solomon (@drrob1) Not sure, but the latest build added more Inotify-related features. Try 14942?
therealkenc commentedon Oct 8, 2016
There's
inotifywhich is fixed, but it also needs #468, which is still in the works. I am assuming here that people understand there is already something somewhat important occupying localhost:139/445 on your Windows machine. You can pick a different port, but I have to wonder about the glaring absence of people mentioning that when they "try samba".GSam commentedon Oct 13, 2016
I've managed to get as far as smbd running, but it can't seem to bind to the port (despite using a seemingly unused one). As a start, I've just tried to get it to accept guest connections with the following smb.conf:
[global]
map to guest = bad user
[mapped]
path = /tmp/
guest ok = yes
readonly = false
Command: sudo bin/smbd -i --option='smb ports = 65500 65501' --option='interfaces = eth0' -s /tmp/smb.conf -d3
Last bit of log:
open_socket_in(): setsockopt: SO_REUSEPORT = true on port 65500 failed with error = Invalid argument
open_socket_in(): setsockopt: SO_REUSEPORT = true on port 65501 failed with error = Invalid argument
open_socket_in(): setsockopt: SO_REUSEPORT = true on port 65500 failed with error = Invalid argument
smbd_open_one_socket: open_socket_in: Address already in use
open_socket_in(): setsockopt: SO_REUSEPORT = true on port 65501 failed with error = Invalid argument
smbd_open_one_socket: open_socket_in: Address already in use
reloading printcap cache
cups_pcap_load_async: already waiting for a refresh event
reload status: error
waiting for connections <------ Neato
It seems that the Linux subsystem does not like 0600 permissions (on reopen possibly) and so I went through the code and set it to 0660 + deleted the old tdb files.
https://github.com/GSam/samba/tree/bash
GSam commentedon Oct 13, 2016
After disabling the ipv6 handling code I've managed to establish a local connection within bash. Still trying to determine if the share is visible outside of bash.
~/samba$ sudo bin/smbclient -L localhost -p 1234 --option='interfaces = lo'
sudo: unable to resolve host DESKTOP-C8HLOCF
WARNING: no network interfaces found
Enter root's password:
tdb(/usr/local/samba/var/lock/gencache_notrans.tdb): tdb_open_ex: tdb_new_database failed for /usr/local/samba/var/lock/gencache_notrans.tdb: Invalid argument
tdb(/usr/local/samba/var/lock/gencache_notrans.tdb): tdb_open_ex: tdb_new_database failed for /usr/local/samba/var/lock/gencache_notrans.tdb: Invalid argument
tdb(/usr/local/samba/var/lock/gencache_notrans.tdb): tdb_open_ex: tdb_new_database failed for /usr/local/samba/var/lock/gencache_notrans.tdb: Invalid argument
Domain=[WORKGROUP] OS=[Windows 6.1] Server=[Samba 4.6.0pre1-DEVELOPERBUILD]
No idea what putting files on this share will do.
GSam commentedon Oct 13, 2016
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)
therealkenc commentedon Oct 15, 2016
I see Dokany 1.0 was released recently. There should be just enough pieces here to do something really silly with a little effort...
fpqc commentedon Oct 15, 2016
therealkenc So I'm not clear on this, but does dokany allow a relatively easy port of ext4 for Windows? Also, how does it handle Windows ACLs?
therealkenc commentedon Oct 15, 2016
There's a read-only Ext4 FUSE implementation here. It was done for OSX but a Windows port should be possible in theory (anything is "possible"). Ext4 is a different animal than SMB/NFS though, as you are dealing with the block layer, say on a USB device. If one were to do that users/permissions aren't an issue because it's a real Ext4 filesystem. [Incidentally there is a USB over IP project.]
Anyway what I was referring to was that one should be able to do a SMBNetFS port to Windows with some effort. With SMB/NFS you just need a socket API, which Mingw-w64 is happy to provide. A CLI been done before. There's a userspace NFS server for Linux, although I don't think anyone has tried it on WSL yet. The open source NFS 4 client for Windows is a little stale but I assume could be resurrected. And then of course the is the native windows NFS client for Windows 10 Enterprise.
Which is to say, sooner or later someone is going to mount a WSL VolFs (/home) on Windows.
As for permissions, that's on Dokany's TODO list. Not that I suspect anyone probably cares a lot, as I mentioned in another thread. People have been mounting SMB/NFS shares as 'user whatever' for 25 years.
6 remaining items
waqarz commentedon Jan 13, 2017
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:
Thanks!
therealkenc commentedon Jan 13, 2017
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, Jason Lin (@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.
waqarz commentedon Jan 13, 2017
Thanks therealkenc for the detailed overview. I am now also trying to move/keep all my data in Windows filesystem as suggested by the MS post; symbolic links also seem to be fully functioning as well, so may be this solution addresses all my use cases.
dreyks commentedon Jan 13, 2017
except all of the files are seen as executables which may not be desired
therealkenc commentedon Jan 13, 2017
waqarz - junctions, sorta; symbolic links, no. You'll still find yourself in a state of grief if you try to, for example, clone a git repo with symlinks in WSL and use them in Windows, and visa-versa. But I gather they are looking at it (#1475).
rlabrecque commentedon Apr 19, 2017
Some improvements are coming: https://blogs.msdn.microsoft.com/wsl/2017/04/18/file-system-improvements-to-the-windows-subsystem-for-linux/
fpqc commentedon Apr 19, 2017
Wow, neat!
therealkenc commentedon Nov 15, 2017
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
smbclientworks too, probably for ages. Mounting native Samba shares would require FUSE per User Voice.Note that although
smbdis operable, that doesn't make it especially useful for interop with Windows onlocalhost, which is what a lot of people really want here. But this is because the CIFS port is already spoken for by Windows, not becausesmbdis broken on WSL. But if you fire upsmbdon 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).WSLUser commentedon Nov 15, 2017
therealkenc Could there not also be the possibility of forcing Windows to share the CIFS port with WSL instead of forcing Windows to recognize a non-default port? Some type of QoS/Load balancing that determines what needs the port more and ability to set certain apps within WSL to a higher priority than something in Windows that's not being utilized 100% of the time. Perhaps also another possibility is allowing ports such as CIFS and SSH to accept simultaneous use from both Windows and WSL? This would seem to me to be the better solution than using a non-default port that could potentially be compromised by anybody wanting to a run a port-scan against your computer/network and noticing an unusual port being open. Pen testers would have a field day with the non-default ports being utilized for services that don't belong there.
therealkenc commentedon Nov 15, 2017
The problem here is Windows CIFS hogs listening address
0.0.0.0. Even if you could convince the greater Windows group to "share", which let's just cut to the chase and concede isn't in the cards, you have no priority (differentiation) to hang your psudo-QoS hat on. WSL localhost is Windows localhost.If you differentiate "WSL localhost" and "Win32 localhost", well, that's pretty much the definition an address namespace; in other words option (a). It isn't really a load balancing analogy. If I fire up
smbclienton WSL targeting destination localhost, those packets need to be routed with specificity. I might want WSL Samba listening on 445. I might want Windows CIFS on 445. That isn't "sharing". That's routing.But yes, in short, if WSL supported all the routing/filter goodness of Real Linux, we'd be golden.
No; whatever the port scanning attackers think they intend to do on port 3445 they can do on port 445.
127.0.0.1:3445can't be compromised any easier or harder than Samba running in a VM on192.168.0.123:445on the same machine. Ditto goes forsshon 2222 orapache2on 8080.GSam commentedon Nov 16, 2017
therealkenc There's actually a way to disable the Windows CIFS server. I don't know what the implications are, but it could be useful. The Samba team seem to have played around with it a little. It's probably of most use to you to figure out what to do with it. Do you have somewhere I can send it?
therealkenc commentedon Nov 16, 2017
Yeah I almost mentioned forgoing Windows CIFS as a possible scenario, but we were already straying from actionable WSL territory with respect to the OP and I thought better to leave that implied. Link whatever you got here if you like; no harm in that (shrug). But folks will overall probably get better service from being involved with the Samba community, as with any other target platform.
GSam commentedon Nov 17, 2017
https://github.com/GSam/samba-scripts/releases/download/temp/Free445.tgz