NAS - WD My Cloud

I have Syncthing running on my WD My Cloud:

Updated See post below

4 Likes

This is a simple guide to get syncthing to startup as a service and run at boot:

Must be on firmware < 4.00 http://www.scramworks.net/hacking-mycloud.html#mc1

Downgrading your Cloud

I’ve only tested this with 4.00.00-607 (7/2014) firmware, they may lock the device down even further with subsequent updates.

Turn off automatic updates, otherwise all your hardwork will be for nothing.

I found the “how To” for downgrading on the WD supportforums but just incase that vanishes I’ll repeat JoaquinAR’s instrustions here.

Get the latest 3.X version of the firmware from: http://download.wdc.com/nas/sq-030401-230-20140415.deb.zip (Cached copy Here - in case WD decide to remove it from their site.)

“You’d have to edit the file /usr/local/sbin/updateFirmwareFromFile.sh commenting out the lines 256 through 259 since it won’t allow you to apply any version lower than the existing one:”

Using a terminal or putty SSH to drive then

nano /usr/local/sbin/updateFirmwareFromFile.sh

# if [ -z "${update_container}" ] && [ "${vnew}" -lt "${vnow}" ]; then 
# error="failed 200 \"invalid firmware package\"" 
# pre-update_error $error 
# fi

You can now install the downgrade from the web interface.

Step 1: I created a share on the My Cloud Shares called Tools You can set this up via the web page UI. Navigate in the browser to the WD’s ip address. Enable SSH in settings

Step 2: First you need to have the ARM7 binary file saved on the WD Drive. Download file https://github.com/syncthing/syncthing/releases Extract the file twice (I used 7zip) you are looking for the file named syncthing I saved the file to /shares/Tools/ (copy to folder via windows)

Step 3: Using putty SSH login to WD user: root password: welc0me

Step 4: cd /shares/Tools chmod +x sycthing ./syncthing

Step 5: ./syncthing Wait for Syncthing to setup.

After it has setup you will need to ctrl + c to kill the process

cd /root/.config/syncthing

Step 6: nano config.xml

Modify the config file

gui enabled="true" tls="false"
        address 192.168.1.25:8080  address

Or what ever IP you are using to connect to the WD UI. I have set my device up to be a static IP at 192.168.1.25

Step 7: Press Ctrl + x Y to save And Enter to save the file as named

Step 8: You will need to move the file to the /usr/local/bin mv /shares/Tools/syncthing /etc/usr/local/bin

Step 9: nano /etc/init.d/syncthing

Step 10: Paste this script into the file :

https://forum.syncthing.net/t/keeping-syncthing-running-systemd-regular-etc-init-d/402
#!/bin/sh
### BEGIN INIT INFO
# Provides: syncthing
# Required-Start: $local_fs $remote_fs
# Required-Stop: $local_fs $remote_fs
# Should-Start: $network
# Should-Stop: $network
# Default-Start: 2 3 4 5
# Default-Stop: 0 1 6
# Short-Description: Multi-user daemonized version of syncthing.
# Description: Starts the syncthing daemon for all registered users.
### END INIT INFO

# Replace with users you want to run syncthing clients for
syncthing_USERS=""
DAEMON=/usr/local/bin/syncthing

startd() {
  for stuser in $syncthing_USERS; do
    HOMEDIR=$(getent passwd $stuser | awk -F: '{print $6}')
    if [ -f $config ]; then
      echo "Starting syncthiing for $stuser"
      start-stop-daemon -b -o -c $stuser -S -u $stuser -x $DAEMON
    else
      echo "Couldn't start syncthing for $stuser (no $config found)"
    fi
  done
}

stopd() {
  for stuser in $syncthing_USERS; do
    dbpid=$(pgrep -fu $stuser $DAEMON)
    if [ ! -z "$dbpid" ]; then
      echo "Stopping syncthing for $stuser"
      start-stop-daemon -o -c $stuser -K -u $stuser -x $DAEMON
    fi
  done
}

status() {
  for stuser in $syncthing_USERS; do
    dbpid=$(pgrep -fu $stuser $DAEMON)
    if [ -z "$dbpid" ]; then
      echo "syncthing for USER $stuser: not running."
    else
      echo "syncthing for USER $stuser: running (pid $dbpid)"
    fi
  done
}

case "$1" in
  start) startd
    ;;
  stop) stopd
    ;;
  restart|reload|force-reload) stopd && startd
    ;;
  status) status
    ;;
  *) echo "Usage: /etc/init.d/syncthing {start|stop|reload|force-reload|restart|status}"
     exit 1
   ;;
esac

exit 0

Step 11: ctrl + x – to exit y – to save enter – confirm file name

Step 12: nano /etc/init.d/mystartup.sh

Step 13: Copy and paste like before in the previous step

#! /bin/sh
# /etc/init.d/mystartup.sh
#
 
syncthing restart &
 
exit 0

Step 13: ctrl + x – to exit y – to save enter – confirm file name

Step 14: sudo chmod 755 /etc/init.d/mystartup.sh

Step 15: sudo chmod 755 /etc/init.d/syncthing

Step 16: sudo update-rc.d mystartup.sh defaults

Step 17: I like to use reboot command in terminal, but it has caused a few issues. The better way is to reboot the device via the WD UI.

3 Likes

This is working flawlessly. I have been able to update the WD Cloud drive via network computer web ui. What I find very nice about this program and what I am doing is this:

I setup my NAS WD Cloud with a few Repositories, then I set up a few Nodes. Interestingly enough I can now share files from one computer to another and not have to know there specific node! It is great! My NAS WD Cloud drive manages all of the nodes. So now I have my working computer linked to the WD Cloud, then my portable also linked to WD Cloud, and my home laptop is also linked to the same Repository, but none of the three need to know each others nodes! It is like dropbox but maybe about 100X better! They are all sharing the Repository, but none know, nor care that they are sharing with each other.

I then have my WD Cloud drive make backups (seeing how I have some room for it there) my other devices don’t need to worry about storing redundant files on them.

1 Like

Nice How-To!

What NAS WD My Cloud Software Version are you running? I heard that with 4.0 one cannot run “Non-WD-apps” any more.

1 Like

I am running v03.04.01-230.

I actually downgraded to run a few other services that I found fun to try out. I never tried running syncthing on the newer 64K requirements. I suspect that it will not work. It was very easy to downgrade. I simply downloaded a previous firmware update it is a .deb package, then I commented out 4 lines of an update script. Then I did a firmware update via the web GUI and the after reboot I had a good firmware version.

I have a similar post on the WD website.

1 Like

Do you think this will work also with MyCloud EX2? Looks very promising! BitSync does not allow my NAS to enter sleep mode…

1 Like

If Bitsync was working then I would assume syncthing will work. Give it try and report back your findings.

I just ran the syncthing install on WD My Cloud and got this error at the end:

[FYEDP] 20:45:29 INFO: Completed initial scan (rw) of folder default
[FYEDP] 20:45:30 INFO: Automatic upgrade: Get https://api.github.com/repos/syncthing/syncthing/releases?per_page=10: x509: failed to load system roots and no roots provided

It looks to have completed and I’m going to try to continue editing the xml to turn off GUI, etc… but I was just curious if this was an expected error. Did you see this line as well? Anyone else?

The automatic upgrade fails because the system (i.e. the WD NAS) doesn’t have the expected CA certificates for SSL, so syncthing can’t verify Github’s SSL certificate. It’s not a critical problem.

It looks like the upgrade code currently doesn’t check signatures; is that something you’re planning to add eventually?

Yes, that should be added. Probably not as far as checking the signature (that being a dependency on gpg, somehow getting the correct public key in a trusted way, and so on) but at least checking the hash to make sure the download wasn’t broken.

There are a few different signature verification methods in crypto (crypto/rsa, crypto/dsa, crypto/ecdsa). You’d just have to sign with one of those as well. As for the public key, you could just include that in the code.

Just putting it out there :smile:; I’m not clamoring for this, and there are higher priority things to do. Anyone who wants/needs to verify can do it manually (not that it’s difficult). I was just curious if it was an eventual goal, or if you’d accept a patch to do it (not from me unfortunately; I don’t know Go yet).

Whom exactly should go here? I’ve placed ‘david’ in there which is a share user on the MyCloud.

The problem I’m having is that syncthing doesn’t appear to start just from the mystartup.sh (and syncthing script is calls). If I type ‘syncthing’ in shell, it starts right up, but when I use mystartup.sh all it says is “Starting syncthiing for david” but it is not started and not reachable from webUI.

What am I missing here?

Also, should the items under ### BEGIN INIT INFO be edited? If so, how might that look?

/etc/init.d/syncthing

I didn’t modify any part of the script file. Nor do I think that you need to make any custom adjustments. Just copy it in its entirety and paste it into the file.

This walk through represents the exact steps I took to get this working on my device. The only real option you will want to make a change to is the IP address in step 6. All others just copy and paste for now.

As far as just typing syncthing in the terminal you are not running it as a service, and it will run until you end your terminal session.

I took the users out, no change. I can’t get the mystartup.sh script to work even manually running it. No errors, just clean exit.

Note that the following does work, although it’s not quite the same, because then it’s running as root, I think… so I’m guessing it’s an issue with the user switch options on the start-stop-daemon?

start-stop-daemon -b -S -x /usr/local/bin/syncthing

I’m pretty well stuck on this now, so anyone that has some ideas to try, please chime in. I understand that running it manually is not ideal, which is why I’m trying to figure out how to get it going automatically. :smile:

They only way I was able to get this to run was as root. Sorry if you want it to run as a user, I don’t have an answer for you.

That’s okay! Anyone can answer if they think of something that would help.

Also, I was connected via ssh as root. I just put a user in the script because I thought I had to; It wasn’t working either way. :smirk:

Thanks for this post, anyway; this is already really helpful and awesome!

For anyone interested I think that this procedure should work on the WD NAS Clean Debian installation, i.e. Debian version 7.8 as at 27 Feb 2015. (This is pure Debian, with none of the WD bloat, installed as per http://community.wd.com/t5/WD-My-Cloud/Clean-debian-and-OpenMediaVault-on-WDMyCloud/td-p/785505.) I run the Clean Debian version and syncthing in “daemon” mode (hence my installation was a little different) and restarts from the GUI work fine.

I use NFS and sync two folders on the NAS, a Linux PC and a laptop, also running Linux. My original idea was to replace Dropbox but I love syncthing and even though Dropbox gave me 50GB free I’d rather be in control of my own data. I have also installed ramlog so that the NAS server can spin the disk down when not in use.

[Unrelated to SyncThing]

I then have my WD Cloud drive make backups …

Sounds like a great sync plan, but as far as backups go, you might also want an “offsite” backup in case of natural disaster or similar event; With all hardware in one location, it could all be lost at once. I have a very similar setup but I also use SpiderOak/Carbonite online service. Hope this is helpful :wink:

Anybody running Syncthing on v5 firmware? edit: Sorry, I just saw this thread was a few years old.