How to permanently disable wdmcserverd and wdphotodbmergerd

Thought i would share how to permanently disable wdmcserverd and wdphotodbmergerd (media scanning and thumbnail generation services) since a lot of people seem to be having similar issues with 100% CPU usage and the drive not sleeping.

First step was to prevent the services from starting on boot.

You will need to enable ssh and login to your drive using the default password and navigate to /etc/init.d

WDMyCloud:~#
cd /etc/init.d
ls

Here you will find the init scripts for the various services. Edit “wdmcserverd” and “wdphotodbmergerd”. All you need to do here is add an “exit 0” after the first line.

pico wdmcserverd
pico wdphotodbmergerd

Both pico and vi are available on the WD MyCloud, so either will do. The first lines of both files should look now like this:

#!/bin/sh
exit 0

After saving the files you can reboot the drive and that should be it.

Except that you may notice the web interface now no longer shows the drive capacity.

To fix this we need to hunt around a bit more in the code of the AXAJ/PHP web interface which is all accessible via ssh once again.

If you want to skip to the solution just got the sections labelled (1.) and (2.) below. What follows is an walk-through of how i did it.

Log in via ssh again, and navigate to the web root:

cd /var/www/htdocs

At this point i started looking around for various likely files, but a faster way would be grepping for keywords like “capacity”, “storage”, and “usage” as in “grep -R capacity”.

In any case a educated guesses at the fairly logical file structure and this led me to find “gCapacity” and “gUsage” in “UI/js/global.js” so i knew where things were going to end up. There was also a function as follows:

function get_storage_capacity() {
    $.ajaxAPI({
        "url": "storage_usage",
        "success": function(data) {
            return parseInt(data.storage_usage.size);
        }
    });
}

Since its a single page HTML5 application meant there had to be a REST api around somewhere, and this variable tells us:

var apiUrlPrefix = "/api/2.1/rest/";

Typing the full url “http://[hostname]/api/2.1/rest/storage_usage” into my browser i could see the error message was that an uncaught exception was being thrown in place of the XML.

So i hunted around for the api code, there is an “api/rest” folder in the root of “/var/www/htdocs” but that only contained a single index.php file. Further up the tree we find a “rest-api” folder in the root of “/var/www” which contains some promising looking structure. After a “grep -R storage_usage” from this folder i located the PHP file (1.) In this file, knowing that we have disabled the media scanning service i commented out the line which was trying to calculate media breakdown.

1.)

pico /var/www/rest-api/api/Storage/src/Storage/Controller/Usage.php

//$result = $storageUsageObj->calculateMediaBreakdown($result);

As indicated by the “use Storage\Model;” at the top and the “$storageUsageObj = new Model\Usage();” declaration there is a corresponding Model.php somewhere. We also see an interesting description of how the usage is calculated to account for reserved space and an example of the correct XML output if no exception is thrown.

I expected the usage to come from parsing a “df” command output and that’s correct.

Editing the model file (2.), the only two lines i needed to change appeared to be references to the media database object which i guessed was now throwing an exception.

2.)

pico /var/www/rest-api/api/Storage/src/Storage/Model/Usage.php

public function __construct($dbPath = null) {
	//$this->mediaDb = openMediaDb($dbPath);
	$this->dbAccess = new \DBAccess();
}

public function __destruct() {
	//closeMediaDb($this->mediaDb);
}

With that we are done, so restart apache and load the web interface to see the new capacity correctly calculated.

cd /etc/init.d
./apache2 restart

4 Likes

you have become my new favorite user :slight_smile: well second to @Bill_S as he still holds the keys to my firmware.

Good job.

Since you are a guru, check into why the drives are waking up 5 to 30 seconds after they are put to sleep. This repeats several times until it finally settles down into a deeper sleep for the night. It is as though they wait for the drive to sleep then a disk activity occurs just right after the sleep command is issued.

A “like” for you!!

much easier to use the standard system commands to disable services

update-rc.d wdphotodbmergerd disable
update-rc.d wdmcserverd disable

either method probably will need to be redone after a firmware upgrade

again easier: deactivate the Cloud Connection in “Settings” / “General”.

Both services are helper service daemons for the Cloud environment.

Larryg0
Why not use the S98user-start script. It gets run on every boot. Just put code in this script to stop wdserverd and wdphotodbmerged.

RAC

Raphael

I think I’m close to finding out why the 8 second sleep occurs. So far it looks like after the my clouud wake up to do some house keeping. Files used by the monitorio.sh script have been removed from cache. So when the monitorio script determines that it is time to put the drive in standby. It does the touch of /tmp/standby. But touch needs to be brought back into cache. It is not always touch. I could be hdparm or the date or the ledCtrl.sh.

I found that monitorio does not monitor ior_root. During the 8 second sleep iow_root iow_datavol and ior_datavol did not change. But ior_root did change.
I’ve been monitoring the disk I/O. I can see disk reads of touch/hdparm/ledCtrl.sh/date at times when the 8 second sleep occurs.

RAC

Why not use the S98user-start script.

Is that not overwritten by a firmware upgrade…?

update-rc.d disable is persistent across power cycles.

It’s being persistent across firmware upgrades that is the difficulty…

Correct is is not persistent across firmware upgrades. It is across power cycles. Just save a copy
of the user-start script on your data volume. After a firmware upgrade just copy your file back. This file can be used to make any changes to the device that you normally make manually after a firmware upgrade.

RAC

Edit: I’m not sure that it gets over written on a firmware upgrade. S98user-start is a symbolic link to /CacheVolume/user-start

Yes, there are dozens of ways to disable the services and init.d scripts from ssh.

And some ways that are supposed to work but don’t from the UI (depending on your firmware revision). On my version turning off cloud settings doesn’t disable the services, and why would it… the thumbnail generation is also for the native windows GUI tool.

But none of these address the calculation of drive capacity in the UI as i did… so if you still want that to work after the services are stopped you should find this useful.

The techniques i used are basic so less dependent on firmware version or the UI, or indeed any particular system V rc scripts. You just need grep and vi !

Its sad we have to go thru all these gyrations to get the drive to sleep (and stay asleep). WDC has designed the drive to do so much stuff its impossible to not have some disk cycle of some sort. Why not give us control over all this house keeping.

I guess I should have said in my post I was talking about stopping the two services. Your fix for the capacity would still be necessary.

RAC

cpt_paranoia
I just check my My Cloud and the user-start file was not over written on firmware update.

RAC

emerson.clarke

What version of firmware are you on. I’m on 04.04.01-112. I don’t have a /var/www/rest-api/api/Storage/src/Storage/Controller/Usage.php file on my system.

RAC

Im running an earlier version of the firmware v04.00.01-623, but i guess there should be a similarly named Controller/Usage.php file somewhere if you search around. I doubt they switched from PHP to something else…

find / --name Usage.php

Or if you want to make it faster, check where apache2 is running from and search from the web root.

on my latest firmware, the following locations:

/var/www/rest-api/api/Storage/src/Storage/Usage/Model/StorageUsage.php

/var/www/rest-api/api/Storage/src/Storage/Usage/Controller/StorageUsage.php

To help others out, can you include your firmware version and specific My Cloud model?