Introduction
Everyone knows that MyBook isn't the fastest NAS, but therefore it's cheap, silent and can be customized thanks to Linux. The following tips could help increasing the transfer speed with Samba.
1. First of all we'll measure the overall throughput of Samba before we're going to edit anything. In order to do that reboot your MyBook first in order to get clean results and not having anything allocated to the few memory we have.
# reboot
2. In the meantime go grab yourself a Linux machine (a VM is fine too) or at least Mac OS X. Now create an empty file of 100 MB filled with zeros in "/tmp". Hint: If you're using Mac OS X replace "bs=100M" with "bs=104857600", since Mac OS X shipped with an outdated version of dd that doesn't supports size-operators like "M" = Megabyte.
# cd /tmp
# dd if=/dev/zero of=100MB bs=100M count=1
3. Now get familiar with "smbclient". It's a comand line tool for SMB access and comparable to the "ftp" command line tool. Connect to your MyBook using the following command. After that enter the password for the user given.
# smbclient \\\\<ip-adress-of-your-mybook>\\<share-name-on-your-mybook> -U <valid-username-with-access>
Now first measure the write speed of Samba by typing the following command within the command prompt of smbclient:
# smb: \> put 100M
4. Wait until the transfer has finished and take a look at the printed transfer speed. Write down the value - we need this later for comparison. Redo the last step, but instead of "put 100M" write "get 100M". This will transfer the file from the share to your local /tmp directory. Again write down the vlaues.
5. Now login to your Mybook by using SSH and open the Samba configuration file:
# nano /etc/smb.conf
6. Right under the last line (should be "max log size = 1"), but still in the "[global]" section append the following commands:
refresh = 1
socket options = TCP_NODELAY IPTOS_LOWDELAY
read raw = No
write raw = Yes
max xmit = 131072
use sendfile = Yes
dead time = 15
getwd cache = Yes
otlocks = No
7. Save the changes and restart Samba:
# /etc/init.d/samba.sh restart
8. Now go back to your Linux/Mac OS X machine where smbclient is started (and now probably exited because Samba was restarted) and redo steps 3. and 4. You can now compare the transfer speeds before and after this little tweaking. They should be above 1.000 Kb/s higher than before. For example these are my stats:
Before:
putting file 100M as \100M (3425,2 kb/s) (average 3410,5 kb/s)
getting file \100M of size 104857600 as 100M (5022,3 kb/s) (average 5022,3 kb/s)
After:
putting file 100M as \100M (4374,2 kb/s) (average 4374,2 kb/s)
getting file \100M of size 104857600 as 100M (5949,3 kb/s) (average 6204,7 kb/s)
9. Of course you can tweak a lot more, here are some options you can play with until you are sastisfied with the speeds. But be warned: Enabling/disabling some options could result in dropping transfer speeds for getting, but increasing speeds for writing - and vice versa.
write raw = Yes/No
read raw = Yes/No
max xmit = 65535/131072
use sendfile = Yes/No
All other settings should be left as given in this tutorial. "refresh = 1" fixes a bug newly created folders/files not visible within Finder (Mac OS X). "dead time = 15" automatically closes connections after 15 minutes of inactivity. Good for memory-saving on the MyBook. "getwd cache = Yes" creates a cache for files and directories, thus speeding up things a bit". "oplocks = No" could be a pain if you're storing and accessing database files like MS Access. Enable (set to "Yes") if you have any problems with that!
Hope this helps, if you've got other tips just let us know! :-)
Cheers,
Cedric