Fixing slow SMB shares in Finder

Hmm.  That’s quite a geeky title.  Maybe I should expound a little bit…

SMB stands for Server Message Block, which is a networking protocol used for accessing files and stuff on a Windows server.  It’s proprietary to Microsoft, so the rest of the world has developed their own ways of using it, more specifically with a technology called Samba.  Apple made use of Samba in OSX until 10.7, where they replaced it with their own version.  The good thing about all this is that, basically, a Mac is able to connect to a Windows file share right out of the box.  The bad thing is that Apple’s implementation of SMB is not altogether nor entirely wonderful.  In fact, it has the tendency to be a bit slow and unreliable.

At school we are still using a Windows server for file sharing, which means that all the Macs access the shared drives using SMB.  But recently the unreliability has become increasingly annoying: taking ages just to browse the contents of files, being unable to delete or move files (because Finder kept complaining that the file in question was already in use by someone else), and not being able to edit files.  Not great.

The options were to buy another Mac server and use that for file sharing (because it could share via SMB, AFP and WebDAV)).  Or try and find a solution on the Internet.

Thankfully, the Internet (via macosx.com) has answered.

I found that if I edited the /etc/nsmb.conf file as follows:

echo notify_off=yes >> /etc/nsmb.conf

it seemed to fix it.  Yay!

Sidebar in Lion

Having got the Lion machines to actually log onto our network, the task was to tweak away the preferences using Workgroup Manager on our Snow Leopard server.

One of my aims for the Macs in the school is that they should be just as easy to use for everyday tasks as a PC was before; it’s no good it being super simple to make a video in iMovie if it’s a complete pain to access the school shared drive.  Putting a shortcut to the ‘school’ shared drive in the Finder sidebar was therefore a priority for me.  I managed to get this to work in Snow Leopard because a mounted network drive appears under ‘devices’ rather than ‘places’ so I just managed those preferences with Workgroup Manager.

Toucan set up our Macs with a log script that renames the ~/Documents folder to something called ‘MacDocuments’ and then creates a shortcut to the user’s network home (i.e. Tim.Lings$ in my case) called ‘Documents’. Without any further trickery, Finder then puts this link to the network home in the sidebar instead of the normal link to the user’s Documents folder.  This is remarkably handy, as default folder for saving files automatically becomes the network home folder rather than a local documents folder.  This is much easier than having to train children and teachers to always save to the network drives.

Now the problem with Lion and the sidebar is that it puts any extra shared drives under the ‘favourites’ heading on the sidebar, along with ‘Pictures’, ‘Movies’, ‘Desktop’ etc.  The clever hack mentioned earlier still works, meaning that my network home folder appears in the sidebar instead of the local ‘Documents’ folder.  Normally to manage the preferences of a feature in OSX, you just set it how you want it, find the relevant .plist file in ~/Library/Preferences (i.e. com.apple.sidebarlists.plist), make a copy of the file, open it with Property List Editor, remove all the XML keys you don’t want to manage, and then import it into Workgroup Manager.  However, this then means that every user would have ‘Tim.Lings$’ in their sidebar, as well as the ‘school’ shared drive as they all lived under that ‘Favourites’ heading in the sidebar.  What to do?

It then struck me that maybe if I changed the key in the preference file to go back to just showing the default ~/Documents shortcut, Finder would swap in the relevant network home drive, as before.  I copied that key from a blank Lion login account and it seemed to work.  Hurrah!