5

I'm trying to share a folder between my main OS (openSUSE 42.1) to a guest Windows 7 virtual machine, but I'm unable to set it up properly.

I access the VM from virt-manager, and I've read that the best way to accomplish this is to use Samba.

I've added this section to my /etc/samba/smb.conf

[shared]
    comment = my shared folder
    guest ok = Yes
    inherit acls = Yes
    path = /home/user/shared
    read only = No
    browseable = Yes

and I set the permissions of /home/user/shared to drwxrwxrwx, and made sure that smb.service is up and running.

But when I run the Windows VM and I try to connect to the shared folder, I can't neither access or even see it.

How can I solve this?

  • can you navigate to the samba share using a web browser? Try opening a web browser and as the URL use: smb://[hostname of Linux host]. If you don't have a DNS then you can use the IP of the Linux host instead. – Centimane Jun 29 '16 at 15:39
  • No, I can't navigate to it from the Web browser. I was trying to mount it from the file browser not from the console – Sekhemty Jun 29 '16 at 16:06
  • If you cannot navigate to it using the web browser the issue is the smb server. Your conf file looks fine, so check out the status of the smb service. What does service smb status tell you? Can you also post your full smb.conf? The [global] section may be the culprit (though I doubt it) – Centimane Jun 29 '16 at 16:18
  • I can access smb://MyLinuxHost from a web browser inside Linux, does it make any difference? – Sekhemty Jun 29 '16 at 16:20
  • 1
    I tried to disable the firewall and now it works. I've added the required exceptions and now it is all correctly set up. Thank you! – Sekhemty Jun 29 '16 at 16:35
3

The problem was that the Firewall was blocking the connections on the ports used by Samba.

I had to add the necessary exceptions and now it works as expected.

| improve this answer | |
0

I needed to access an older Windows 7 VM (from PopOS 19.04, though I have no doubt it would work with Ubuntu too) and ran into the same problem. Dozens of websites were consulted, including this one. I setup the smb.conf with a shared resource, no problem. Then from the windows side I repeatedly tried to map a drive, using instructions from those sites, all of which said to use my Linux account name (correct), the virbr0 IP address of the KVM manager (also correct, e.g., 192.168.122.1. This is NOT the normal IP address of the Linux machine itself, of course), and to check the box saying "Connect using different credentials" - WRONG. After many tries, I decided to see what would happen if I did not check this box. Imagine my surprise when the drive mapped correctly, and I was able to read and write to it!

To the OP, be sure that you have enabled Samba, using:

systemctl enable smb.service

so that it will restart the next time you reboot your machine.

Also note that no firewall changes were needed, also contrary to what a number of websites had suggested. In this case, the use of the virbr0 connection from the Linux host to the Windows VM provides isolation from the main house network.

When creating the samba connection from the Windows side it is also unnecessary to select "Reconnect at logon"; to test this, I shutdown the VM, then restarted it, and clicked on a link I had made pointing to drive Z: (which is where I had the Samba shared mapped), and it immediately reconnected without adding the credentials all over again.

I can now share files between the Linux side and the Windows side with ease. Note: this is with Samba 4.10.0, which is the version from the PopOS and Ubuntu repositories; older versions may require other tweaks.

| improve this answer | |
  • Now 2 months later I had to install MS Teams on Win7 VM, 2 weeks ago. It worked (for a while) but broke Samba sharing. Today Teams broke too. I can ping virbr0 (from Linux and Windows), nmbd/smbd servers are running, testparm has no errors. Windows side mostly fails -- can ping external sites (google) from CLI but not a browser. On Linux it all works; netstat --inet -nlp shows virbr0 to VM (port 139, 445) in Listen. Been debugging for hours, no luck. Nothing was changed in smb.conf when it broke - errors are on Windows side, and only post-Teams. Uninstalling Teams didn't fix it. Ideas? – johnd Mar 25 at 1:44

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.