Browsing Samba Shares Sometimes Fails in Nemo

Please post suggestions for improvement of Cinnamon here
https://github.com/linuxmint/Cinnamon

Browsing Samba Shares Sometimes Fails in Nemo

Postby jlacroix on Tue Sep 03, 2013 12:50 pm

I've been loving Mint 15 Cinnamon (64-bit) so far but I'm noticing a problem when browsing Samba shares. I have a file server (running Wheezy) with several Samba shares on it. Browsing the shares works initially, but there generally tends to be a problem with browsing the shares after my laptop sleeps and then resumes. The process goes something like this:

1.) Navigate to a Samba share in Nemo by clicking on "Network" on the left side (this works)
2.) Make the laptop sleep
3.) Resume
4.) Try to access Samba shares through Nemo (you can't)
5.) Try to access Samba shares already mounted in Nemo (not possible)
6.) Click on the "eject" icon next to each mounted share in Nemo to remove them
7.) Samba share browsing starts working again after a few minutes

Sometimes during this process, Nemo will lock up and crash the desktop, but not always. I'm loving Mint so far but as a HEAVY Samba share user, this is frustrating me. :(
jlacroix
Level 1
Level 1
 
Posts: 17
Joined: Thu Jul 22, 2010 11:33 am

Linux Mint is funded by ads and donations.
 

Re: Browsing Samba Shares Sometimes Fails in Nemo

Postby altair4 on Tue Sep 03, 2013 1:32 pm

I've never had to deal with this issue because all portable devices ( laptops / tablets ) in this shop come from Apple. The macbooks don't exhibit this problem but I set up my Linux desktops to accommodate they way Apple browses for samba shares. You might try the same to see if it fixes this problem since it sounds like all of your machines are running Linux.

On the Server:

[1] Make sure avahi-daemon is running:
Code: Select all
sudo service avahi-daemon status

[2] Make sure port 5353/udp ( and port 445 of course ) is open if you are using a firewall.

[3] Create an avahi/samba service config file:
Code: Select all
gksu gedit /etc/avahi/services/samba.service

[4] Add this content to the file:
Code: Select all
<?xml version="1.0" standalone='no'?>
<!DOCTYPE service-group SYSTEM "avahi-service.dtd">
<service-group>
   <name replace-wildcards="yes">%h SMB</name> ## Display Name
   <service>
       <type>_smb._tcp</type>
       <port>445</port>
   </service>
</service-group>

Note: This is the only tricky part since that first line can't have any leading spaces in front of it. If it does it won't work. You will know you've done it right when saving the file changes the font colors.

Um... that's it really. All Linux and OSX machines should instantly see your Server as "Server-Host-Name SMB".

This is only a guess on my part but when your machine hibernates it might break the samba connection and when it comes back the nmbd process treats it like a new machine added to the lan and starts the master browser election process all over again - it will work but it takes a few minutes for all that to work. Avahi is instant since there is no master browser, or workgroup, or netbios name, or any of the other things that Windows uses to find things.

Anyway, if my suggestion does nothing it's easy enough to undo - just delete the /etc/avahi/services/samba.service file.
Please add a [SOLVED] at the end of your original subject header if your question has been answered and solved.
altair4
Level 15
Level 15
 
Posts: 5521
Joined: Tue Feb 03, 2009 10:27 am

Re: Browsing Samba Shares Sometimes Fails in Nemo

Postby jlacroix on Thu Sep 05, 2013 12:15 am

altair4 wrote:I've never had to deal with this issue because all portable devices ( laptops / tablets ) in this shop come from Apple. The macbooks don't exhibit this problem but I set up my Linux desktops to accommodate they way Apple browses for samba shares. You might try the same to see if it fixes this problem since it sounds like all of your machines are running Linux.

On the Server:

[1] Make sure avahi-daemon is running:
Code: Select all
sudo service avahi-daemon status

[2] Make sure port 5353/udp ( and port 445 of course ) is open if you are using a firewall.

[3] Create an avahi/samba service config file:
Code: Select all
gksu gedit /etc/avahi/services/samba.service

[4] Add this content to the file:
Code: Select all
<?xml version="1.0" standalone='no'?>
<!DOCTYPE service-group SYSTEM "avahi-service.dtd">
<service-group>
   <name replace-wildcards="yes">%h SMB</name> ## Display Name
   <service>
       <type>_smb._tcp</type>
       <port>445</port>
   </service>
</service-group>

Note: This is the only tricky part since that first line can't have any leading spaces in front of it. If it does it won't work. You will know you've done it right when saving the file changes the font colors.

Um... that's it really. All Linux and OSX machines should instantly see your Server as "Server-Host-Name SMB".

This is only a guess on my part but when your machine hibernates it might break the samba connection and when it comes back the nmbd process treats it like a new machine added to the lan and starts the master browser election process all over again - it will work but it takes a few minutes for all that to work. Avahi is instant since there is no master browser, or workgroup, or netbios name, or any of the other things that Windows uses to find things.

Anyway, if my suggestion does nothing it's easy enough to undo - just delete the /etc/avahi/services/samba.service file.

Thanks, I'll give that a shot but a few questions first. I should input all of that on my server or my Mint laptop? Second, I'd prefer that my Linux machines see other Linux machines as "hostname" and not "Server-Host-Name SMB." I'm not sure I understand the relevance of that.

If it's any consolation, in KDE network browsing works flawlessly. It's mainly Cinnamon that has this issue though I may have seen something similar happen in XFCE. Not sure if the fact that it works in KDE makes any difference.
jlacroix
Level 1
Level 1
 
Posts: 17
Joined: Thu Jul 22, 2010 11:33 am

Re: Browsing Samba Shares Sometimes Fails in Nemo

Postby altair4 on Thu Sep 05, 2013 6:51 am

I should input all of that on my server or my Mint laptop?

On the server
I'd prefer that my Linux machines see other Linux machines as "hostname" and not "Server-Host-Name SMB.

Then remove the "SMB" in the Display Name line of the samba.service line:
<?xml version="1.0" standalone='no'?>
<!DOCTYPE service-group SYSTEM "avahi-service.dtd">
<service-group>
<name replace-wildcards="yes">%h</name> ## Display Name
<service>
<type>_smb._tcp</type>
<port>445</port>
</service>
</service-group>

The reason for adding the extra SMB after the hostname ( %h ) is two fold:

** When the normal netbios mechanism is working it will display hostname in Network. If you also have avahi broadcast it's presence with only hostname you won't know which protocol you're using.

** Avahi service files are used for many things besides Samba. I set up one for SSH as well as Samba so that my SSH server will show up under Network in the client machines. To differentiate the two one is set to broadcast "hostname SMB" and the other "hostname SSH".
If it's any consolation, in KDE network browsing works flawlessly. It's mainly Cinnamon that has this issue though I may have seen something similar happen in XFCE. Not sure if the fact that it works in KDE makes any difference.

The irony here is that based only on my own experiences with avahi this process works in every desktop environment except Windows and KDE. I found a bug report on this that's 5 years old now so I don't think it's reasonable to think it will get fixed.

As for the original symptom happening in Cinnamon, Gnome, and XFCE I've long suspected that it's gvfs that's the source of many problems with samba and ssh and gvfs is a Gnome(ish) thing not a KDE thing. You could try to mount the share the old school way with a manual cifs mount and bypass browsing to the share through the file manager but that defeats the purpose of browsing to the share.
Please add a [SOLVED] at the end of your original subject header if your question has been answered and solved.
altair4
Level 15
Level 15
 
Posts: 5521
Joined: Tue Feb 03, 2009 10:27 am

Re: Browsing Samba Shares Sometimes Fails in Nemo

Postby jlacroix on Sun Sep 08, 2013 6:34 pm

altair4 wrote:
I should input all of that on my server or my Mint laptop?

On the server
I'd prefer that my Linux machines see other Linux machines as "hostname" and not "Server-Host-Name SMB.

Then remove the "SMB" in the Display Name line of the samba.service line:
<?xml version="1.0" standalone='no'?>
<!DOCTYPE service-group SYSTEM "avahi-service.dtd">
<service-group>
<name replace-wildcards="yes">%h</name> ## Display Name
<service>
<type>_smb._tcp</type>
<port>445</port>
</service>
</service-group>

The reason for adding the extra SMB after the hostname ( %h ) is two fold:

** When the normal netbios mechanism is working it will display hostname in Network. If you also have avahi broadcast it's presence with only hostname you won't know which protocol you're using.

** Avahi service files are used for many things besides Samba. I set up one for SSH as well as Samba so that my SSH server will show up under Network in the client machines. To differentiate the two one is set to broadcast "hostname SMB" and the other "hostname SSH".
If it's any consolation, in KDE network browsing works flawlessly. It's mainly Cinnamon that has this issue though I may have seen something similar happen in XFCE. Not sure if the fact that it works in KDE makes any difference.

The irony here is that based only on my own experiences with avahi this process works in every desktop environment except Windows and KDE. I found a bug report on this that's 5 years old now so I don't think it's reasonable to think it will get fixed.

As for the original symptom happening in Cinnamon, Gnome, and XFCE I've long suspected that it's gvfs that's the source of many problems with samba and ssh and gvfs is a Gnome(ish) thing not a KDE thing. You could try to mount the share the old school way with a manual cifs mount and bypass browsing to the share through the file manager but that defeats the purpose of browsing to the share.

Thanks for the reply. Sorry I haven't gotten back with you until now. Anyway, I've decided that Avahi is not the way I'd like to go about fixing this. The more I think about it, I think the problem is because Cinnamon is mounting Samba shares and placing an icon on my desktop and within Nemo. Is there a way to make Cinnamon not mount Samba shares when I access them? Everything seems to start working when I "unmount" the share from Nemo.
jlacroix
Level 1
Level 1
 
Posts: 17
Joined: Thu Jul 22, 2010 11:33 am

Re: Browsing Samba Shares Sometimes Fails in Nemo

Postby altair4 on Sun Sep 08, 2013 7:38 pm

jlacroix wrote:The more I think about it, I think the problem is because Cinnamon is mounting Samba shares and placing an icon on my desktop and within Nemo. Is there a way to make Cinnamon not mount Samba shares when I access them? Everything seems to start working when I "unmount" the share from Nemo.

I'm sorry but I couldn't quite follow that.

If you unmount the share it's no longer accessible. Well, you can access a remote share with smbclient but that's with the terminal. If you don't want to mount them using gvfs ( Nemo ) you can do that with a manual cifs mount but I'm not sure that would circumvent the original problem of loosing the samba connection when you go into hibernate.

As for actually stopping a gvfs mount in Nemo I'm not sure that's possible. You could remove some gvfs packages I suppose but then other things won't work so I don't see this as an option.

Perhaps some kind of script that either prevents the machine from hibernating if a samba mount is present or one that unmounts the samba shares when the system goes into hibernate is the answer.
Please add a [SOLVED] at the end of your original subject header if your question has been answered and solved.
altair4
Level 15
Level 15
 
Posts: 5521
Joined: Tue Feb 03, 2009 10:27 am

Re: Browsing Samba Shares Sometimes Fails in Nemo

Postby jlacroix on Sun Sep 08, 2013 9:17 pm

altair4 wrote:
jlacroix wrote:The more I think about it, I think the problem is because Cinnamon is mounting Samba shares and placing an icon on my desktop and within Nemo. Is there a way to make Cinnamon not mount Samba shares when I access them? Everything seems to start working when I "unmount" the share from Nemo.

I'm sorry but I couldn't quite follow that.

If you unmount the share it's no longer accessible. Well, you can access a remote share with smbclient but that's with the terminal. If you don't want to mount them using gvfs ( Nemo ) you can do that with a manual cifs mount but I'm not sure that would circumvent the original problem of loosing the samba connection when you go into hibernate.

As for actually stopping a gvfs mount in Nemo I'm not sure that's possible. You could remove some gvfs packages I suppose but then other things won't work so I don't see this as an option.

Perhaps some kind of script that either prevents the machine from hibernating if a samba mount is present or one that unmounts the samba shares when the system goes into hibernate is the answer.

To try to better explain what I'm talking about, when I navigate to a Samba share in Nemo, it appears on the left hand side with an eject icon next to it. If I put my laptop to sleep, and then wake it up, browsing Samba shares is dead. It shows that there are no Samba servers available. If I click on the eject icon next to the Samba share in Nemo, Samba browsing starts working again. I wonder if Nemo didn't mount the shares and just let you browse them instead, if that would solve it.
jlacroix
Level 1
Level 1
 
Posts: 17
Joined: Thu Jul 22, 2010 11:33 am

Re: Browsing Samba Shares Sometimes Fails in Nemo

Postby altair4 on Mon Sep 09, 2013 10:21 am

Since there doesn't seem to be any way for me to reproduce this kind of problem I have another idea you might not like. I have done this only once just to see if it could be done and I have just done it again based on my notes and it still works so it might be a solution for you.

[1] Install the following package on the client Linux machine:
Code: Select all
sudo apt-get install autofs

[2] Edit /etc/auto.master and add one line right above the "+auto.master" line at the end:
# Note that if there are entries for /net or /misc (as
# above) in the included master map any keys that are the
# same will not be seen as the first read key seen takes
# precedence.
#
/home/altair/Shares /etc/auto.shares --timeout=30 --ghost
+auto.master

The "/home/altair/Shares" in this example is the parent of the mount points for all the remote samba shares. It can be anywhere you want and autofs will create the directory by itself.

[2] Create a new file:
Code: Select all
gksu gedit /etc/auto.shares

Add a line defining the share for all the shares you have on the Debian server, for example:
Code: Select all
ShareName1 -fstype=cifs,rw,uid=1000,iocharset=utf8 ://server-host-name.local/share-name1
ShareName2 -fstype=cifs,rw,uid=1000,iocharset=utf8 ://server-host-name.local/share-name2

Where:
ShareName1 is the name of the mount point you want the debian share to mount. Autofs will create this directory by itself.
server-host-name.local is the debian server host name with it's .local qualifier ( It can also be an ip address ).
share-name1 is the name of the share on that debian server.

[3] Then restart autofs:
Code: Select all
sudo service autofs restart

When you go to ( in this example ) /home/altair/Shares/ShareName1 the remote share is automatically mounted.

Notes:

** Autofs is designed to make a connection and mount on demand when the mount point directory is accessed.
** It is also designed to disconnect and unmount after a period of inactivity ( in this case 30 seconds - "--timeout=30" )
** You will get a mount icon in Nemo with a unmount arrow which you will not be able to use to actually unmount it but if you sit there and don't actually use the share for 30 seconds you will notice it unmounts by itself.
** Specifying the Debian servers host name:

Samba works best when it's unburdened with the somewhat primitive Windows way of using netbios names so the best is by ip address, then an mDNS qualified ( .local ) host name ( which all Linux and OSX machines can do by default ), and most problematic is the windows-netbios name way:
ShareName1 -fstype=cifs,rw,uid=1000,iocharset=utf8 ://192.168.0.100/share-name1
ShareName1 -fstype=cifs,rw,uid=1000,iocharset=utf8 ://server-host-name.local/share-name1
ShareName1 -fstype=cifs,rw,uid=1000,iocharset=utf8 ://server-host-name/share-name1


BTW, if your share require authentication the lines in /etc/auto.shares would look like this:
Code: Select all
ShareName1 -fstype=cifs,rw,username=name,password=secret,uid=1000,iocharset=utf8 ://server-host-name.local/share-name2
Please add a [SOLVED] at the end of your original subject header if your question has been answered and solved.
altair4
Level 15
Level 15
 
Posts: 5521
Joined: Tue Feb 03, 2009 10:27 am

Linux Mint is funded by ads and donations.
 

Return to Cinnamon

Who is online

Users browsing this forum: Bing [Bot] and 17 guests