In part of my process of installing Ubuntu 9.10, I needed to set up file sharing with my Windows XP machine. And as I started to get into it I forgot what a small pain in the butt it is to get this to work properly. After spending around 6 hours at it, I finally got it working.

First I had to make sure that I had Samba and sambfs installed. I checked the Synaptic package manager and made sure that I did.

Second was that I had an external USB and an second internal drive installed that I wanted to share. So I had to set those up to auto mount and to change the permissions on both of them. I did this by using PySDM. You can install it using Synaptic. Once it is installed go to System> Admin> Storage Device Manager. Make sure to select allow any user and I had to check the ownership and rename it from root to my user name. Also uncheck read only and DO check mount at startup.

Once that was done, in Nautilus I browsed to the file system> media> folder and right clicked on the drives and selected sharing. I also selected allow guest, so it does not ask for user name and password in windows.

From here I could see the drives on my Ubuntu machine from my Windows machines, but not the other way around. I spent hours racking my brain and searching until I came up with this post by dmizer which solved the problem.

I only had to go to #3 and my problems were solved. The original post link:

http://ubuntuforums.org/showthread.php?t=1169149

I sure hopes this helps anyone who needs it. Once again thanks to dmizer for his knowledge. / Mike

His post:

Howto: Fix Windows share browsing issues

Howto: Fix Windows share browsing issues

First of all, even though it’s more difficult, manually mounting shares via /etc/fstab gives many advantages including faster speeds, more reliability, and larger file transfer sizes. It is more difficult to get things working properly, but once it’s done you never have to think about it again. So, if you’re willing to put forth a bit of effort for greater rewards than this tutorial will provide, please see the second link in my signature.

Windows share browsing issues are somewhat complex in that even though your symptoms are exactly the same, the causes can be extremely different. In this howto, I will outline the four primary reasons for the problem, and provide fixes for each. Once you’re finished, you should be able to browse and connect to Windows shares by clicking on “places” > “connect to server”.

= = = = = = = = = = = = = = = = = = =

Problem 1:
Ubuntu is not able to browse shares in workgroups that it is not a member of. By default, Ubuntu is a member of the “WORKGROUP” workgroup, but not all Windows computers use this convention. In order to correct this problem, you’ll need to verify that all your Windows computers belong to the same workgroup. In order to check/change that, please see this Microsoft support document: http://support.microsoft.com/kb/295017

= = = = = = = = = = = = = = = = = = =

Problem 2:
There is no easy way to change the workgroup that Ubuntu belongs to. This means that you can either assign all of your Windows computers to the “WORKGROUP” workgroup (as outlined under “Problem 1″), or edit /etc/samba/smb.conf in order to change the workgroup that Ubuntu is a member of.

Problem 2 – part 1
Open this file for editing with the following command:

Code:
gksudo gedit /etc/samba/smb.conf

Scroll down to the section that looks like this:

Code:
 #======================= Global Settings =======================

[global]

## Browsing/Identification ###

# Change this to the workgroup/NT-domain name your Samba server will part of
   workgroup = WORKGROUP

Change “WORKGROUP” in “workgroup = WORKGROUP” to match your Windows workgroup.

Problem 2 – part 2
It may also help to add netbios name = computer-name just below “workgroup = WORKGROUP”.

Your “computer-name” can be anything, but common convention is to use the name you gave it when you installed Ubuntu (everything after the “@” symbol on the CLI prompt).

For example, here’s my CLI prompt:

Code:
dmizer@shinkansen:~$

And here’s my smb.conf file:

Code:
#======================= Global Settings =======================

[global]

## Browsing/Identification ###

# Change this to the workgroup/NT-domain name your Samba server will part of
   workgroup = WORKGROUP
   netbios name = shinkansen

Now, save the file by clicking on “File” > “save”, close gedit, and restart samba with the following command:

Code:
sudo /etc/init.d/samba restart

If, after running the above command, you see this error:

Code:
sudo: /etc/init.d/samba: command not found

Just reboot your machine instead.

= = = = = = = = = = = = = = = = = = =

Problem 3:
Ubuntu is unable to browse Windows host names by default. Enabling this ability will also require a conf file edit.

—CAUTION—
If you are using Firestarter, uninstall it before making this edit. Firestarter may prevent the machine from booting after this change is made. Use GUFW instead.
—CAUTION—


Problem 3 – Part 1
Open /etc/nsswitch.conf for editing with the following command:

Code:
gksudo gedit /etc/nsswitch.conf

Find the line that looks something like:

Code:
hosts:          files mdns4_minimal [NOTFOUND=return] dns mdns4

For this line, order IS important. You’ll need to add the “wins” option before dns, so the line reads like this:

Code:
 hosts:          files mdns4_minimal [NOTFOUND=return] wins dns mdns4

Now, save the file by clicking on “File” > “save” and close gedit.

Problem 3 – Part 2
You’ll also have to install the winbind daemon in order to resolve hostnames. This is easily done with the following command:

Code:
sudo apt-get install winbind

Then, either restart networking or reboot.

Problem 3 – Jaunty/Karmic
Some Karmic users are reporting name resolution failure even after performing all the steps in this howto. If you have a local DNS server, do not perform this edit. Usually small home networks do not have a local DNS server but most office networks do. If you are unsure, talk to your office sysadmin. Either way, the following edit may solve some issues.

Open /etc/samba/smb.conf for editing with the following command:

Code:
gksudo gedit /etc/samba/smb.conf

Find the line that looks something like:

Code:
;   name resolve order = lmhosts host wins bcast

Just as with Problem 3 – Part 1, order is important when editing this line. You’ll need to remove the semicolon, and move “host” to the end of the line so that it looks like this:

Code:
   name resolve order = lmhosts wins bcast host

Bug report here: https://bugs.launchpad.net/ubuntu/+s…ba/+bug/375593
Thanks to audiomick for this information.

= = = = = = = = = = = = = = = = = = =

Problem 4:
Firewalls block samba browsing. If you’re sharing files over samba, that probably means you’re on a LAN with only indirect (usually via a firewalled gateway) access to the Internet. This means that you probably don’t need a firewall at all. If you think you DO need a firewall, you should really think about how wise it is to poke holes in it to facilitate samba file sharing.

If you simply must have a firewall and have decided that it’s a good idea to allow samba access through it, start by checking all of your Windows computers to make sure that your firewalls allow Samba browsing. Also, since Jaunty, Ubuntu has enabled the UFW by default. This interferes with network browsing. Finally, if you’ve installed Firestarter or any other firewall tools, you may run into this problem. To correct this, you’ll need to add rules to allow the following ports:

  • Port 137/UDP – used by nmbd
  • Port 138/UDP – used by nmbd
  • Port 139/TCP – used by smbd
  • Port 445/TCP – used by smbd

First of all, determine if you have a firewall in place or not. To check for firewalls, run the following command:

Code:
sudo iptables -L

A disabled firewall should look like this: http://pastebin.com/f564e1a42. If not, then you have a firewall enabled.

If the UFW is enabled, here’s how to add UFW rules for samba browsing in Jaunty:

Code:
sudo ufw allow proto udp to any port 137 from 192.168.1.0/24
sudo ufw allow proto udp to any port 138 from 192.168.1.0/24
sudo ufw allow proto tcp to any port 139 from 192.168.1.0/24
sudo ufw allow proto tcp to any port 445 from 192.168.1.0/24

Make sure to change 192.168.29.0/24 so that it matches your own network IP range.

Credit for the UFW edit goes here: http://ubuntuforums.org/showthread.php?t=1225549

If you’re using firestarter, uninstall it. The default firewall in Jaunty is UFW, you can manage it via it’s GUI interface by installing gufw.

= = = = = = = = = = = = = = = = = = =

Vista problems:

If your trying to connect to Vista, you will not be able to connect to any UAC protected drive/directory. Because of this, sharing entire drives will not give you access (unlike it did in XP). Believe me when I say … this is a very good thing. You don’t want your entire system hanging out there for all to see. It’s possible to override this protection but I wouldn’t advise it.

Instead, share a single folder that your Vista user has control over. If you want an entire drive to be dedicated to sharing, then share the first folder on the drive and put everything else inside it like so:

D:/ddrive-shared/Music
D:/ddrive-shared/Movies
D:/ddrive-shared/Pictures
D:/ddrive-shared/Documents
D:/ddrive-shared/Other
etc

More information here: http://www.vistax64.com/vista-securi…ss-denied.html
Related Ubuntu discussion here: http://ubuntuforums.org/showthread.php?t=1176221

= = = = = = = = = = = = = = = = = = =

If you have addressed all of the above issues, and you are still unable to browse Windows shares, you may have more luck and better results by following the CIFS tutorial in my sig. Otherwise, feel free to post here and I’ll do what I can to help resolve the problem.

——
version history:
2009-06-04: Included Vista specific information
2009-06-20: Updated UFW configuration
2009-06-25: Included directions for verifying firewalls
2009-07-29: Changed UFW firewall rules to reflect findings given in this thread: http://ubuntuforums.org/showthread.php?t=1225549(incorrect)
2009-08-05: Removed name resolve order edit from problem 2 as it could possibly conflict with the winbind daemon.
2009-08-20: Corrected UFW rules per this post: http://ubuntuforums.org/showpost.php…&postcount=133
2009-10-29: Included “name resolve order” option edit per this post: http://ubuntuforums.org/showpost.php…ey are needed.