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