Skip to content

Instantly share code, notes, and snippets.

@markodvornik
Last active June 16, 2024 06:11
Show Gist options
  • Save markodvornik/1ca0fce3ed0090b06f6e19f20b57c590 to your computer and use it in GitHub Desktop.
Save markodvornik/1ca0fce3ed0090b06f6e19f20b57c590 to your computer and use it in GitHub Desktop.
How to hack the "WD My Cloud Home Duo" into a decent home media center

WD My Cloud Home Duo Hack

🚩 NOTE: in late 2022 WD introduced a firmware release in which they locked root user access over "serial connection". The methods described in this post are therefore irrelevant and do not work anymore. Feel free to discus other alternatives in the comments below. This was also the final firmware release for this product as it entered EOL in June 2023.

TL;DR

A simple How-To on turnning your WD My Cloud Home in to fully pledged Linux box and install some usefull apps (SSH & SFTP server, Torrent client, ...).

  • Connect to the device with USB serial cable.
  • Download and Install Entware
  • Install and configure other apps
  • Edit /system/bin/start_samba.sh file to make everything work at boot

1. Introduction

This is work in progress. Not all goals have been achieved yet. See the Progress section.

Western Digital has made a decent home storage unit with an accompanying dekstop and a mobile app. However, the functionality of this device is limited to just a few basics, such as:

  • backup of home computers (Windows backup or Apple Time Machine)
  • backup of mobile phone photos
  • remote access to files
  • multi user spaces and family sharing
  • Plex media server
  • IFTTT integration (limited)

This WD built-in feature set is disappointing. Based on WD user forum, the most desired features that are missing are:

  • acces to files without proprietary WD software (like a normal NAS would have - this comes as a surprise to many owners)
  • more apps (like Synology open app system)

The reason to even bother with WD MCHD is the fact that it is quite cheap for the storage you get and based on the Plex compatibilty devices list it houses a decent hardware power (CPU, network) that can manage HD & 4K movie streaming.

As this document shows, adding some of the desired features is not that hard so it si worth the effort.

Note: there are two models of WD MyCloud Home: single and double disc (The Duo). The way this two models mount their discs is different and so the way to hack them is not the same (The Duo model has RAID functionality).

This document is about the Duo model.

It turns out that the Duo model has some version of ARM Linux (Android) with Busybox installed and on a hardware side it has a serial connector. This makes it trivial to log on and install custom sowtfware.

~ # uname -a
Linux localhost 4.1.17 #1 SMP PREEMPT Mon May 11 21:44:23 PDT 2020 armv8l GNU/Linux

2. Overview

  1. make a MCHD a standard NAS with full network access to shell and all folders without WD Discovery Software
  2. install additional programs not included in WD Apps
  3. make everything work at boot
  4. keep everything compatible with WD Cloud

2.1. Progress / Status

  1. Not working:

    • WD's Samba keeps popping up and Entware Samba is crashing.

    • NFS throws an error (possiblly missing kernel features):

      Cannot register service: RPC: Unable to receive; errno = Connection refused

    • As an alternative, we'll install SFTP server for remote accessing files

  2. OK

  3. OK

  4. Untested. Probably not working.

3. Requirements

4. Recipe

  1. Connect to MCHD with USB UART cable and Serial App
  2. download and install Entware & install Entware's packages
  3. modify one of the WD startup scripts (e.g. start_samba) to run custom services
  4. disable Over the air update service

5. Setup

Below is a rough walk trough of the setup process.

  • *In a perfect scenario you would do this only once and repeat it in case hack is overwritten by some other WD script.
  • *Parts marked with 🏁 need to be done only once.

5.1. Terminal access - Connecting to the serial port with the USB-UART adapter

Serial connection allows you to establish a terminal access to the machine. You will also need a special software that can speak over the serial port, e.g. Serial App.

Serial connection port is on the MCHD motherboard (take off the white top half od the enclosure) positioned near the front of the device facing upward.

Adapter's cable wiring

BLACK to GND
GREEN to Rx
WHITE to Tx
RED - leave unattached

🏁 Once connected to the device with a serial connection you should see the command prompt. If not try changing connection settings in the serial app.

5.2. ENTWARE - The software repository

See Entware Wiki for detailed instructions on how to use it and the available package list.

Download and install Entware

Prepare App's location folder /opt/

/system/bin/mount -o rw,remount /
mkdir /opt
/system/bin/mount -o ro,remount /

🏁 Create source folder /data/data/entware.arm.

NOTE: use mount location with enough free space: /data location has only 1GB space, /data/data location is /dev/md1 storage and has ~unlimited space

mkdir /data/data/entware.arm

Mount source folder to /opt.

NOTE: A bind mount is equivalent to the original. Bind mounts are like hard links in this respect, not like symbolic links.

/system/bin/mount -o bind /data/data/entware.arm /opt

🏁 Install Entware to source folder. We will use a built-in busybox version of wget.

Prepare wget.

/system/bin/mount -o rw,remount /
cd /bin
ln -s /sbin/busybox wget
export PATH=$PATH:/bin
/system/bin/mount -o ro,remount /

Run install.

wget -O - http://bin.entware.net/armv7sf-k3.2/installer/alternative.sh | sh

Using Entware

All Entware packages (apps) are installed in the /opt/etc/ folder, not the usual /etc/ and config files of some of the apps are stored in /opt/root/.config/ folder.

Before using Entware, make sure to add /opt/bin & /opt/sbin to your PATH variable

PATH=/opt/bin:/opt/sbin:$PATH

The main tool for using Entware is opkg package manager (search, install, update packages). To see what can be insalled look at the Entware software list: Packages

Quick guide:

opkg list transmission*
opkg install transmission-daemon-openssl transmission-web
opkg remove transmission-daemon-openssl transmission-web
opkg info transmission-daemon-openssl

Entware shell extensions

The default WD MCHD system shell binaries are provided by the Busybox and in some of them are stripped-off versions of the original GNU binaries in order to save hard disk space. Since we are running the system with lots of storage we can replace Busybox versions with full GNU versions from the Entware package list.

Example: replace Busybox's rm command with GNU's rm.

opkg install coreutils-rm

Some of the Entware's usefull shell binaries

opkg install mc # file commander
opkg install joe # text editor
opkg install fdisk # partition tool
opkg install ptyhon3 # for python software to work
opkg install python3-pip # python package manager
opkg install openssh-sftp-server # 🔸 remote file access
opkg install htop # system resources monitor (cpu, memory)
opkg install iftop # network monitor

5.2.1. 🏁 DROPBEAR - The SSH Server

Reset some environment setups.

unset LD_LIBRARY_PATH
unset LD_PRELOAD

Install server.

/opt/bin/opkg install dropbear

Run server on the port 22.

/opt/sbin/dropbear -p 22 -a

Set ssh access password.

/opt/bin/passwd

Set DNS servers.

cd /opt/etc/
ln -s /system/etc/resolv.conf resolv.conf

Connecting to SSH Server from your PC

On your PC, start an SSH client and connect to the WD MCHD using the IP addres of your MCHD and root username. You can look up the IP address of MCHD with the ifconfig command. Contiune the rest of the process in the ssh shell.

ssh -l root 192.168.X.X

Note: it is a good idea to set a static IP address to your MCHD. The best way to do that is in the settings of your Network Router.

It is a good practice to set up key-based login to the ssh server.

  • *Create private & public key on your local machine (no-passphrase keys)
  • *Transfer public key to the MCHD server
  • Don't set a passphrase when asked

(optional) Install keygen tools on MCHD

opkg install openssh-keygen

On your local machine (You need to create private/public keys on your machine at .ssh/id_rsa.pub)

cd ~/.ssh
ssh-keygen -t rsa
ssh root@YOUR_MCHD_IP "tee -a /opt/etc/dropbear/authorized_keys" < ~/.ssh/id_rsa.pub

5.2.2. 🏁 TRANSMISSION - The Torrent client

Installation

/opt/bin/opkg install transmission-daemon-openssl transmission-web

Start the deamon.

/opt/bin/transmission-daemon -f

And immediately Stop the deamon by pressing Ctrl-C.

Configuration

After first run a user-config file is created. In order to keep the saved changes in the config file the deamon must not be running.

For the time of configuring the client it is best to run the deamon in the foreground so that you can see log messages right on the stack.

Edit user-config file using joe editor:

joe /opt/root/.config/transmission-daemon/settings.json

in the settings.json adjust the following parameters (the password is set to "transmission", below is the hashed version of it)

"bind-address-ipv4": "YOUR_MCHD_IP",
"port-forwarding-enabled": true,
"rpc-bind-address": "YOUR_MCHD_IP",
"download-dir": “/data/data/shared/Downloads”,
"rpc-username": "transmission",
"rpc-password": "{5a79ad5b52c489757daff2193692886514225491IGhscquC",
"rpc-whitelist": "127.0.0.1,192.168.*.*,YOUR_MCHD_HOST_NAME,::1",
"rpc-whitelist-enabled": true,

Download folder

  • *Temporary and downloaded files must reside somewhere in the /data/data/ folder (mount point) as this is where all the storage is mounted.
  • *Don't use folders inside /data/wd/diskVolume0/data/com.plexapp.mediaserver.smb (restsdkFilesystem). It seems that downloading to this location uses more resources and Transmission remote access might get unresponsive. Also, if for some reason you wish to experiment with disabling WD's services (Samba server) this location gets unmounted.

Create the Download folder.

mkdir -p /data/data/shared/Downloads

Start the deamon.

To connect to the transmission client use web browser at the http://YOUR_MCHD_IP:9091/transmission/web/ or an desktop app Transmission Remote GUI. Username and password are transmission/transmission.

Try downloading some torrent. If everything is as expected, Stop and then Start the deamon without the -f.

5.2.3. 🏁 FLEXGET - The torrent download automation service

Flexget is a torrent download automator. It can be configured in paralel with the Transmission torrent client. Flexget can periodialy check for predefined Movies and TV Shows Episodes and sends the download command to the transmission. There are many ways to configure flexget, see the official docs.

Installing Flexget and dependencies:

opkg install python3 python3-pip python3-dev gcc binutils gawk ldd make sed tar
opkg install coreutils-install diffutils ldconfig patch pkg-config --force-overwrite
opkg install python3-sqlite3 python3-yaml bzip2 libbz2
pip install cloudscraper transmission-rpc
pip install flexget

5.2.4 Samba 4

It is possible to have many samba file sharing instalations. To have the latest version of Samba with custom folders exposed to sharing use entware samba4-server package and configure service with /opt/etc/samba/smb.conf.

Shares

Setup folders on a large partition, e.g. /data/wd/diskVolume0/samba/share/.

Set user

/opt/bin/smbpasswd -c /opt/etc/samba/smb.conf -a MY_USERNAME -s

5.3. 🏁 Make everything work at boot

Modify MCH standard startup script for Samba server. Edit /system/bin/start_samba.sh file.

Note: There are no text editors available in the WD's Busybox version. You need to type in the console the whole Custom Hack section below (mount Entware). Only after Entware is installed you can use terminal text editor.

Add the code below at the beginning of the file.

This code:

  • *creates mount point for Entware and mounts it.
  • *starts all services that we've added to the system

Before editing the file the location needs to be remounted for read/write access.

/system/bin/mount -o rw,remount /system
#! /system/bin/sh

# CUSTOM HACK
if mount | grep /data/entware.arm > /dev/null; then
echo "entware already mounted."
else
  unset LD_PRELOAD
  unset LD_LIBRARY_PATH
  sleep 3

  # Create /opt folder
  /system/bin/mount -o rw,remount /
  sleep 1
  /system/bin/mkdir /opt
  /system/bin/mount -o ro,remount /
  sleep 3

   # Mount Entware installation to /opt
  /system/bin/mount -o bind /data/entware.arm /opt
  sleep 2

  # Start/stop all our custom Entware apps (init scripts) in /opt/etc/init.d
  /opt/etc/init.d/rc.unslung start
  sleep 2
fi

Return mount point to it's original read-only mode.

/system/bin/mount -o ro,remount /system

5.3.1 🏁 Add a custom disk locations (folder) to WD-Samba shares

To access any folder location on WD MCHD you need to add them to Samba configuration.

Note: this method might not persist over WD-Cloud sowftware or firmare updates of the MCHD.

Note: this configuration is unsecure.

To share a folder e.g. /data/data/shared edit /data/wd/samba/etc/samba/smb.conf and add this config at the end of the file.

[Public]
path = /data/data/shared
writable = yes
guest ok = yes

Restart Samba:

rm -f /data/wd/samba/var/run/samba/smbd.pid
killall smbd
/data/wd/samba/bin/smbd -D

5.3.2. 🏁 Prevent WD-Cloud updates from disabling the hack

TODO

When device becomes unavailable reconnect USB-serial cable and run:

# /bin/sh
/system/bin/mount -o rw,remount /
mkdir /opt
/system/bin/mount -o ro,remount /
mount -o bind /data/entware.arm /opt
PATH=/opt/bin:/opt/sbin:$PATH
unset LD_LIBRARY_PATH
unset LD_PRELOAD
/opt/etc/init.d/rc.unslung start

6. Troubleshooting

6.1. X failed: No space left on device

/opt/tmp or any other system folder is full because it is mounted on a too small partition. Fix mounts so that they point to a larger partition - e.g. /data/data/entware.arm and not /data/entware.arm.

@gdemarchi
Copy link

Hi, thanks for the prompt reply ...

Yes, http://wd.hides.su/fox_exe/WDMyCloud-Home-Duo/

Yes, I know ... i had exactly the system up and running with debian and omv, but one drive failed, therefore I took out one of the two drives, the good one, and put it on a linux machine, in order to be able to rescue the data. Now this seems to be fine, I juste wanted to get a couple of 2-3 TB disks to put them again in the enclosure, since from the hw spec the device is not too bad ...

Now, the i eventually managed to boot either to a android rescue, which is essentially useless, or keeping the reset button pressed (no case any more so it's a button, easier to press 😁 ... and I had lukily the USB-serial cable for the console) I manage to boot the USB bootloader ...
There I tried both the "old" debian and omv and the new (debian 11 + omv 6), but I'm encountering some problems to get them booting properly ...
My plan and what i need to do, for which i would thankful for any help, is:

a) get any linux system to boot, eventually enough to pull up the eth and connect via telnet and
b) "write"/burn the working linux to some non volatile memory: i assume that for having a full blown debian+omv i would have to wait for the disks to arrive, but meanwhile i wanted to try with another disk/usb stick ... just to play around ...

Thanks a lot and best

@bigdude9
Copy link

bigdude9 commented Mar 28, 2022

Hello and thanks for this information.
For the cable adapter is that adapter cable directly connected to a USB male, or does this require a rs232 port or adapter in between the PC and MCHD ? (sorry for the basic question, but I do not have a serial port so I wanted to be sure I didn't need one).

Thanks again !

--found what I needed. worked through these changes and more. Thanks for the pointer and help. It's a shame WD doesn't update and fix this device up better that's a pretty outdated android and plex they provide. It would be nice to do more with it, but I'm just about to give up and load it up with Linux or a newer android if I can find the drivers for it.

@libarra
Copy link

libarra commented Dec 25, 2023

Yes, http://wd.hides.su/fox_exe/WDMyCloud-Home-Duo/

Dont be afraid because it is russian you can google translate it really easylie. I´ll make a Youtube video about this. But you need to do:

  1. Format a usb stick ti fat32 with Windows if you can.
  2. copy all the Files to it.
  3. stick it in the top! USB Port and press the reset button with a paper clip (littel hole) and keep it pushed
    4.Put in the power cord
  4. wait util it is not blinking any more
  5. use a shell on your computer
  6. intsall telnet
  7. conect with telnet <>
  8. install-omv.sh --help for all the options
  9. read the PDF if you want to know more about how to format
  10. FOR Raid0 use, install-omv.sh 20 0 10
  11. if it is not working you can use X instad of 0 (install-omv.sh 20 x 10) and format the raid later on in debian
  12. if it sucsessfully worked you are not getting kicked out of the telnet and you should type: reboot -f
  13. conect with ssh like ( ssh root@<<<<YourIPadressMaybeAnOtherOneThanBefore!!>>>>>>>) PW: root
  14. OpenMediaVoult shuld be installed so you can go to <<<YourIPadressMaybeAnOtherOneThanBefore!!>>>>>>> and it should pop up
  15. I think user is admin pw is admin.

and there you go it takes about 10 mins.

More Information is the pdf provided.

If you can thank the person who builds it!!!!

I love this guy he helped me like 10000000 Times!!!!! If you read this, you are awesome!

Hi man, thank you for your post. I'm trying but in any combinations of raid parameters: 0, 1 or X , received this a message in russian after the "Syncing disks" message and the install doesn't complete:

/ # install-omv.sh 15 x 10
--- Ожидание готовности дисков -------
--- Разбивка дисков ----
sfdisk: cannot open /dev/sda: Input/output error
Checking that no-one is using this disk right now ... OK

Disk /dev/sdb: 3.7 TiB, 4000787030016 bytes, 7814037168 sectors
Disk model: WDC WD40EFRX-68N
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 4096 bytes
I/O size (minimum/optimal): 4096 bytes / 4096 bytes

The size of this disk is 3.7 TiB (4000787030016 bytes). DOS partition table format cannot be used on drives for volumes larger than 4294966784 bytes for 512-byte sectors. Use GUID partition table format (GPT).
Created a new DOS disklabel with disk identifier 0x253e759a.
/dev/sdb1: Created a new partition 1 of type 'Linux raid autodetect' and of size 2 GiB.
Partition #1 contains a linux_raid_member signature.
/dev/sdb2: Created a new partition 2 of type 'Linux raid autodetect' and of size 15 GiB.
Partition #2 contains a linux_raid_member signature.
/dev/sdb3:
New situation:
Disklabel type: dos
Disk identifier: 0x253e759a

Device Boot Start End Sectors Size Id Type
/dev/sdb1 2048 4196351 4194304 2G fd Linux raid autodetect
/dev/sdb2 4196352 35653631 31457280 15G fd Linux raid autodetect

The partition table has been altered.
Calling ioctl() to re-read partition table.
Syncing disks.
--- Ожидание перезагрузки таблицы разделов -------

Please your help and thanks in advance.

Luis.

@amirssahmadi
Copy link

hello every one just wondering

is it posible to get direct usb data transfer?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment