New MyBook Duo 4Tb astonishingly slow... I mean, really soul-numbingly slow

Ok, here goes.First of all, let me exlain the problem. The MBL comes with a miserable 256MB of RAM. When all services are enabled (AppleTalk, Web management, Twonky, NFS, Media Server, Samba etc) they require more memory than is available on the box. This causes the Linux kernel to have to swap and degrades performance to the point of making the device unusable. The way to fix the problem is to disable as many services as possible and get to the point where NO swapping occurs. Then the device becomes quite useable and I have seen write speeds of 30-40MB/sec and read speeds of 40-80MB/sec on my Mac with a Gigabit network. The lower speeds are obtained using SMB (Windows file sharing) and the higher ones with AFP (Apple Filesharing Protocol). O have not tested NFS but I would expect it to be even faster.

To do this you MUST be comfortable working with Linux. If this is not your thing, then donā€™t try this. Just return the device and get your money back. Seriously. Thereā€™s no way I can think of to really fix this without a bit of Linux hacking.

I will post four scripts here. You need to upload them to your MBL device. I put mine in the /root directory. Make them executable (chmod a+x script_name). They do the following:

  1. rc1.sh will restore your device /etc/rc1.d directory bacjk to its original state.
  2. rc2.sh will restore your device /etc/rc2.d directory bacjk to its original state. You will use rc1.sh and rc2.sh for any time you want to put things back the way they were (i.e. incredibly slow and painful)
  3. mac.sh is a script at will disble all services except those that are useful for Macs.
  4. dos.sh is a script that will set things up for DOS (Windows) boxes.

OK. Deep breath and letā€™s go. First of all, here is rc1.sh

#!/bin/bash

This script will recreate all the symbolic links in /etc/rc1.d for the

WD 2TB MyBook device after I have hacked at the runlevels.

ln -sf /etc/init.d/wdInitEntry /etc/rc1.d/S01wdInitEntry
ln -sf /etc/init.d/purgelogs.sh /etc/rc1.d/S02purgelogs.sh
ln -sf /etc/init.d/ramlog /etc/rc1.d/S02ramlog
ln -sf /etc/init.d/rsyslog /etc/rc1.d/S03rsyslog
ln -sf /etc/init.d/apache2 /etc/rc1.d/S04apache2
ln -sf /etc/init.d/mountDataVolume.sh /etc/rc1.d/S15mountDataVolume.sh
ln -sf /etc/init.d/ifplugd /etc/rc1.d/S20ifplugd
ln -sf /etc/init.d/smartmontools /etc/rc1.d/S20smartmontools
ln -sf /etc/init.d/reset_button_mon /etc/rc1.d/S88reset_button_mon
ln -sf /etc/init.d/rmnologin /etc/rc1.d/S98rmnologin
ln -sf /etc/init.d/wdInitFinalize /etc/rc1.d/S99wdInitFinalize

Now rc2.sh


#!/bin/bash

This script will recreate all the symbolic links in /etc/rc2.d for the

WD 2TB MyBook device after I have hacked at the runlevels.

ln -sf /etc/init.d/wdAppEntry /etc/rc2.d/S01wdAppEntry
ln -sf /etc/init.d/apache2 /etc/rc2.d/S04apache2
ln -sf /etc/init.d/fuse /etc/rc2.d/S11fuse
ln -sf /etc/init.d/mdadm /etc/rc2.d/S12mdadm
ln -sf /etc/init.d/ntpdate /etc/rc2.d/S16ntpdate
ln -sf /etc/init.d/ssh /etc/rc2.d/S16ssh
ln -sf /etc/init.d/monitorTemperature /etc/rc2.d/S17monitorTemperature
ln -sf /etc/init.d/monitorio /etc/rc2.d/S18monitorio
ln -sf /etc/init.d/portmap /etc/rc2.d/S19portmap
ln -sf /etc/init.d/nfs-common /etc/rc2.d/S20nfs-common
ln -sf /etc/init.d/nfs-kernel-server /etc/rc2.d/S20nfs-kernel-server
ln -sf /etc/init.d/samba /etc/rc2.d/S20samba
ln -sf /etc/init.d/sysstat /etc/rc2.d/S20sysstat
ln -sf /etc/init.d/vsftpd /etc/rc2.d/S20vsftpd
ln -sf /etc/init.d/netatalk /etc/rc2.d/S50netatalk
ln -sf /etc/init.d/mDNSResponder /etc/rc2.d/S60mDNSResponder
ln -sf /etc/init.d/upnp_nas /etc/rc2.d/S61upnp_nas
ln -sf /etc/init.d/sudo /etc/rc2.d/S75sudo
ln -sf /etc/init.d/dbus /etc/rc2.d/S79dbus
ln -sf /etc/init.d/avahi-daemon /etc/rc2.d/S80avahi-daemon
ln -sf /etc/init.d/forked-daapd /etc/rc2.d/S84forked-daapd
ln -sf /etc/init.d/twonky /etc/rc2.d/S85twonky
ln -sf /etc/init.d/orion /etc/rc2.d/S86orion
ln -sf /etc/init.d/cron /etc/rc2.d/S89cron
ln -sf /etc/init.d/lltd /etc/rc2.d/S90lltd
ln -sf /etc/init.d/stop-bootlogd /etc/rc2.d/S98stop-bootlogd
ln -sf /etc/init.d/vftd /etc/rc2.d/S98vftd
ln -sf /etc/init.d/wdAppFinalize /etc/rc2.d/S99wdAppFinalize

Now the one for Mac users (mac.sh)

#!/bin/bash

This script will turm off everything except AFP and Time Machine

The result will be a setup suited to most Mac users and will get

the NAS running way faster than it does ā€œout of the boxā€.

On my (Gigabit) network I get speeds of just under 40MB/sec on write

and just under 80MB/sec on read.

To put everything back again, use the rc1.sh and rc2.sh scripts.

rm /etc/rc1.d/S03rsyslog
rm /etc/rc1.d/S04apache2
rm /etc/rc2.d/S04apache2
rm /etc/rc2.d/S11fuse
rm /etc/rc2.d/S18monitorio
rm /etc/rc2.d/S20nfs-common
rm /etc/rc2.d/S20nfs-kernel-server
rm /etc/rc2.d/S20samba
rm /etc/rc2.d/S20vsftpd
rm /etc/rc2.d/S61upnp_nas
rm /etc/rc2.d/S84forked-daapd
rm /etc/rc2.d/S85twonky
rm /etc/rc2.d/S86orion
rm /etc/rc2.d/S90lltd

And finally the one for Windows (dos.sh)

#!/bin/bash

This script will turm off everything except SMB (DOS file shares)

The result will be a setup suited to most DOS users and will get

the NAS running way faster than it does ā€œout of the boxā€.

On my (Gigabit) network I get speeds of just under 30MB/sec on write

and just under 40MB/sec on read. Your mileage may vary :slight_smile:

To put everything back again, use the rc1.sh and rc2.sh scripts.

rm /etc/rc1.d/S03rsyslog
rm /etc/rc1.d/S04apache2
rm /etc/rc2.d/S04apache2
rm /etc/rc2.d/S11fuse
rm /etc/rc2.d/S18monitorio
rm /etc/rc2.d/S20nfs-common
rm /etc/rc2.d/S20nfs-kernel-server
rm /etc/rc2.d/S20vsftpd
rm /etc/rc2.d/S61upnp_nas
rm /etc/rc2.d/S84forked-daapd
rm /etc/rc2.d/S85twonky
rm /etc/rc2.d/S86orion
rm /etc/rc2.d/S90lltd
rm /etc/rc2.d/S50netatalk
rm /etc/rc2.d/S60mDNSResponder
rm /etc/rc2.d/S80avahi-daemon

How to use:

  1. Copy and paste the scripts into four files. Call them anything you like but I will refer to them as rc1.sh, rc2.sh, mac.sh and dos.sh
  2. Enable SSH on your device. There are many posts that can tell you how to do this. Google.
  3. Copy the four scripts to your device. I put them in my /root directory (rootā€™s home) but it really doesnā€™t matter.
  4. Login to root on your device
  5. Run either mac.sh or dos.sh according to what you want.
  6. Reboot the device (type in reboot (duh))
  7. Enjoy massively improved performance.
  8. Use rc1.sh and rc2.sh to put things back the way WD gave it to you (i.e. Slow and painful)
  9. I would imagine that hitting the reset button might also put things back the way they started but I couldnā€™t be bothered to try it.

If you have any questions or suggestions for improment (and I know there are many) then by all means post here or just e-mail me at tony at mattheys dot com. I hope this helps you get some more utility out of your device.

2 Likes

Fixed my issue too! Ā Very slow transfer (6MB per hour) before. Ā Thanks!

Thanks for posting this. What a way to learn a little ssh and recall some Unix things from 18 years ago. Phew.

Iā€™m yet to see if the performance is fixed, but I know one thing is broken: the http interface. Iā€™d like to get that back to set up shares, users etc.

Any idea which of the processes rmā€™d I should recover to get this functionality back?

And now to test the speed!

-dene

To get the http interface back, just re-enable apache2. From the command line you can go ā€œ/etc/init.s/apache2 startā€ to use it and then ā€œ/etc/init.d/apache2 stopā€ to kill it. It does use quite a bit of memory so I like to leave it disabled.

Dene09 wrote:

 

And now to test the speed!

 

-dene

Bitterly disappointed! Really thought this would work. No change in speed here.

For reference, Iā€™m trying to copy my iPhoto library across from the MacBook Air. Once it hits the Database/Faces/Detected folder (contains about 14,000 files, 3kB each) it slows to a crawl. This isnā€™t a problem with the read speed from the Mac. If I stop the process, and attempt to browse to that folder, it takes ages to do anything on the MBLD.

Something is not right.

Make sure that after you run the mac.sh or dos.sh script you REBOOT. Otherwise the memory hogging processes are still there. You can check by typing in ā€œtopā€ and looking at whether or not you are using any swap space. If you are using more than a few (hundred?) K of swap space then something did not work right. Generally my swap used is 0k which is when I get the best performance.

Ok, Iā€™ve rebooted twice actually. Once using the web interface (this may have reset things). And once using ssh reboot. Which would have done nothing special if the first spoiled things. Iā€™ll ssh back in and see if the mac.sh tells me it canā€™t find thingsā€¦

In the meantime, my Swap numbers donā€™t look good:

Screen Shot 2012-10-09 at 3.06.55 AM.png

Running mac.sh showed those settings have already been removed. Having rebooted, Iā€™m sure the mac.sh settings are engaged, but still massively slow.

Itā€™s fantastic though from your advice I can see itā€™s potentially a memory swapping issue, even if I donā€™t have a fix.

Thanks for your help.

-dene

The biggest issue with the performance is the swapping. You must get it down to zero (or very close to zero).

I used ā€œtopā€ and killed off processes one by one until it went to zero. Use my mac.sh and dos.sh scripts to guide you in which processes you can kill safely. Your device may be set up slightly different to mine, so you might need to play with it a bit. If you look at the scripts and compare the names of the startup scripts I am removing to the process names you see in top, you will see the correspondence and understand which ones you can kill.

For some reason on mine the stupid upnp_nas process keeps firing up and I havenā€™t found a way to kill it automatically, but since it doesnā€™t seem to affect my memory usage I havenā€™t worried too much.

One more thing, you can ask top to sort thr process list by memory usage so youy can target the ā€œbadā€ processes. I also found that once I got my swap space usage down to less than 25MB the device actually became quite responsive, but I am a bit of a perfectionist so I kept hacking at it until I stripped it down to zero :slight_smile:

Huge thanks to Tony for this fix. Even with a wired connection between my iMac and the MBLD, the best I could get was 13 MB/s write, 30 MB/s read. Now, despite keeping http enabled, itā€™s 21 write and 78 read. Much more usable!

Tony_Mattheys wrote:

One more thing, you can ask top to sort thr process list by memory usage so youy can target the ā€œbadā€ processes. I also found that once I got my swap space usage down to less than 25MB the device actually became quite responsive, but I am a bit of a perfectionist so I kept hacking at it until I stripped it down to zero :slight_smile:

Hi Tony, I wasnā€™t able to find how to ask top to list in memory usage order. Do you recall the command?

Also, referring back to my screen shot, I take it Iā€™m trying to get ā€œSwap Usageā€ down as low as possible, rather than just the raw size?

Thanks again,

-d

With top running, hit ā€œOā€ (Uppercase letter O) and then ā€œoā€ (lowercase letter o). Voila! Process list is sorted by Memory usage. You can make this permanent by typing in ā€œWā€ (Upper case W) to save a .toprc file. Hint: ā€œhā€™ā€ (lower case h) gives help/

I am having the same problem. I tried to follow the instructions but I could not swtich user with my password. I assume this is the password I use to login to my computer? Stuck. I would appreciate any help you could offer. Thanks.

I followed your instruction (created the dos.sh file in the root directory, changed itā€™s permission) but when I tried to run it at the ssh prompt I got the following messageĀ 

ā€œ-bash: dos.sh: command not foundā€

What did I wrong?

execute like this

./dos.sh

not

dos.sh

If that still doesnā€™t work, then you didnā€™t set the execute bits correctly.

@Tony

Dying here as I knew this MBL wouldnā€™t be as fast as my Synology but I needed something to dump an emergency backup to. This thing is running painfully slow and we have terabytes to go; excited to find your tweaks.

Dumb question, will modded with either script format the drives or break the default spanning mode the MBL comes in?

thanks!

SLC

The tweaks should not affect any of that AFAIK.

My suggestion (seriously) is that unless you are very familiar with Linux and very comfortable making these kinds of changes, DONā€™T DO IT. Return the device and get your money back. There is a fundamental issue with it in that it was never given enough RAM to allow it to run all the services that WD starts. There is also no way (as far as I am aware anyway) to upgrade its internal RAM, so the only option you have is to reduce your memory footprint.

The device is fundamentally flawed out of the box.

I agree but I do have a backup. And Sadly, I am in a foreign country where the only give you 24hour refund if something is very wrong. Itā€™s really of no use to me unless I can increase the performance.

I was able to load the file onto my Public folder then I copied the dos.sh file I made using Notepad++ into /root.

But I get an error about directories not existing and the services canā€™t be removed: