INSTALL ENTWARE ON WD MY CLOUD HOME (SSH ACCESS, NFS SERVER, OPKG install packages)

Hi Ahmed,

I used the exact same commands that juju and ansir have listed in their posts above. Have you tried following these? What happened? Tell me where you got stuck and I’ll suggest what might be wrong.

There are lots of resources on the web where you can get a basic grounding in Linux admin and shell commands - here’s one that includes a link to a video session on ubuntu.

If you are unfamiliar with ubuntu I suggest you follow the tutorial here to download it and create a bootable USB stick. Run this up and practice. You can do no harm if you use the “Try Ubuntu” option on booting as you just need to reboot to start again.

The instructions presented in this thread do not modify firmware. Firmware resides on an eprom usually, and is ‘baked’ into the hardware itself. Instead they modify files that are part of the Linux operating system which WD has chosen for this product. If you mess up your OS you may make the MCH unbootable. So I suggest you don’t go any further until you are up to speed on the Linux primer I linked above.

Good luck!

Kryters

2 Likes

I will give it a try and if anything goes wrong i will ask here . Thank you very much

It seems that the duo model has a flash card in it for the system, this makes the hack a bit more difficult :(.

grep mmcblk debug_logs/kernel/1553369429_kernel.log
03-23 19:28:12.566 0 0 I mmcblk0 : mmc0:0001 4FPD3R 3.64 GiB
03-23 19:28:12.577 0 0 I mmcblk0boot0: mmc0:0001 4FPD3R partition 1 4.00 MiB
03-23 19:28:12.580 0 0 I mmcblk0boot1: mmc0:0001 4FPD3R partition 2 4.00 MiB
03-23 19:28:12.589 0 0 I mmcblk0rpmb: mmc0:0001 4FPD3R partition 3 512 KiB
03-23 19:28:12.599 0 0 I mmcblk0 : p1 p2 p3 p4 < p5 p6 >
03-23 19:28:12.599 0 0 I : add_partition partition name = mmcblk0p1
03-23 19:28:12.612 0 0 I : add_partition partition name = mmcblk0p2
03-23 19:28:12.619 0 0 I : add_partition partition name = mmcblk0p3
03-23 19:28:12.626 0 0 I : add_partition partition name = mmcblk0p4
03-23 19:28:12.638 0 0 I : add_partition partition name = mmcblk0p5
03-23 19:28:12.638 0 0 I : add_partition partition name = mmcblk0p6
03-23 19:28:12.638 0 0 I rescan_partitions: rescan device mmcblk0 partitions finish.
03-23 19:28:22.543 0 0 I EXT4-fs (mmcblk0p3): mounted filesystem with ordered data mode. Opts: (null)
03-23 19:28:22.543 0 0 I fs_mgr : __mount(source=/dev/block/mmcblk0p3,target=/system,type=ext4)=0
03-23 19:28:22.566 0 0 I EXT4-fs (mmcblk0p5): recovery complete
03-23 19:28:22.572 0 0 I EXT4-fs (mmcblk0p5): mounted filesystem with ordered data mode. Opts: (null)
03-23 19:28:22.580 0 0 I fs_mgr : __mount(source=/dev/block/mmcblk0p5,target=/cache,type=ext4)=0
03-23 19:28:22.732 0 0 I EXT4-fs (mmcblk0p6): 9 orphan inodes deleted
03-23 19:28:22.738 0 0 I EXT4-fs (mmcblk0p6): recovery complete
03-23 19:28:22.760 0 0 I EXT4-fs (mmcblk0p6): mounted filesystem with ordered data mode. Opts: noauto_da_alloc
03-23 19:28:22.769 0 0 I fs_mgr : __mount(source=/dev/block/mmcblk0p6,target=/data,type=ext4)=0

Here are a few notes for anyone wanting to attach a console to the device (a Realtek RTD1295):

I used a UART to USB cable like this one: Raspberry Pi USB Console cable

Connected to the 4-pin header on the board thus:

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

hint: Remove the little black plastic collar from the UART header first.

Download and install PuTTY from here

Before switching on the power to the board, plug the USB end of the cable into your PC or laptop and let Windows install the driver. Then run the Windows device manager and locate the new serial port. Mine was listed as “Prolific USB-to-Serial Comm Port (COM3)”. I tested driver version 3.8.28.0 on Windows 8.1 and 10.

Create a PuTTY session as follows (in the Session tab):

Connection type: Serial
Serial line: COM3 (in my case)
Speed: 115200

in the Serial tab of the PuTTY dialog I also set Flow Control to None but this may be unnecessary.

Power on the board. On booting, without the HDD attached we get:

C1:80000000
C2
?
C3h
hwsetting size: 000005C0
C4
f
5-5
Goto FSBL: 0x10100000
<=============================================>
fsbl_main: sys_secure_type = 0x0000BEEE
fsbl_main: sys_boot_type = 0x00000001
fsbl_main: sys_boot_enc = 0x00000000
fsbl_main: sys_bisr_done = 0x00000000
sys_hwsetting_size:00000600
sys_bootcode_size:00067440
sys_secure_fsbl_size:00010B00
sys_secure_os_size:00000000
sys_bl31_size:00005040
sys_rsa_key_fw_size:00000000
sys_rsa_key_tee_size:00000000
sys_rescue_size:00026360

HwSetting:
hwsetting_blk_no:88120800
hwsetting_total_size:00000680
hwsetting_blk_count:00000680

Bootcode:
bootcode_blk_no:88120E80
bootcode_total_size:00067460
bootcode_blk_count:00067460

FSBL:
secure_fsbl_blk_no:881882E0
secure_fsbl_total_size:00010B20
secure_fsbl_blk_count:00010B20

TEE OS:
secure_os_blk_no:88198E00
secure_os_total_size:00000000
secure_os_blk_count:00000000

BL31:
bl31_blk_no:88198E00
bl31_total_size:00005060
bl31_blk_count:00005060

RSA Key Fw:
rsa_key_fw_blk_no:8819DE60
rsa_key_fw_total_size:00000000
rsa_key_fw_blk_count:00000000

RSA Key TEE:
rsa_key_tee_blk_no:8819DE60
rsa_key_tee_total_size:00000000
rsa_key_tee_blk_count:00000000

Rescue:
rescue_blk_no:8819DE60
rescue_total_size:00026380
rescue_blk_count:00026380
********** FW_TYPE_BOOTCODE **********
fwInfo->fwType: 00000001
fwInfo->isGolden: 00000001
fwInfo->ddrReadAddr: 00520000
fwInfo->ddrDestAddr: 00020000
fwInfo->flashType: 00000001
fwInfo->flashUnitSize: 00000001
fwInfo->flashOffset: 88120E80
fwInfo->dataSize: 00067460
body_size:00067440
flash_unit_no:88120E80
flash_unit_count:00067460
real_size:00067418
sha256 Fw
j bootcode jump address:00020000
64b


4.1.4

CPU  : Cortex-A53 quad core - AARCH32
Board: Realtek QA Board
[ERR] get_accessible_ddr_size: hw setting error. (impossible value 0x0)
[ERR] get_accessible_ddr_size: hw setting error. (impossible value 0x0)
DRAM:  0 Bytes
Watchdog: Disabled
Cache: Enabled
Non-Cache Region: 1 MB@0x07900000
nor flash id [0x00c84014]
sector 256k en: 0
sector  64k en: 1
sector  32k en: 1
sector   4k en: 1
page_program  : 1
max capacity  : 0x00100000
spi type name : GD25Q80C_08Mbit
[SATA] enable SATA interface
[SATA] spread-spectrum disable
Factory: NOR
Factory: pp:0, seq#:0xa, size:0x2400
------------can't find tmp/factory/000BootParam.h
Set HDMI TX OFF
In:    serial
Out:   serial
Err:   serial
Net:   Realtek PCIe GBE Family Controller mcfg = 0024
dev->name=r8168#0
*** Reboot-Action invalid ***
Hit Esc or Tab key to enter console mode or rescue linux:  0
------------can't find tmp/factory/recovery
======== Checking into android recovery ====

AHCI 0001.0301 32 slots 2 ports ? Gbps 0x3 impl SATA mode
flags: ncq pm led clo only pmp pio slum part
No port device detected!
Error, SATA device initialization failed!
bootr - boot realtek platform

Usage:
bootr [u/uz]
        u   - boot from usb
        uz  - boot from usb (use lzma image)
        m   - read fw from flash but boot manually (go all)

Enter console mode, disable watchdog ...

and then the help command gives:

Realtek> help
b2ndbc  - load 2nd stage bootcode
bdinfo  - print Board Info structure
bootm   - boot application image from memory
bootr   - boot realtek platform
dcache  - enable or disable data cache
dhcp    - boot image via network using DHCP/TFTP protocol
env     - environment handling commands
factory - FACTORY sub system
fatinfo - print information about filesystem
fatload - load binary file from a dos filesystem
fatls   - list files in a directory (default /)
fatwrite- write file into a dos filesystem
fdt     - flattened device tree utility commands
gettime - get timer val elapsed
go      - start application at address 'addr' or start running fw
goru    - start rescue linux from usb
gpt     - GUID Partition Table
help    - print command description/usage
i2c     - I2C sub-system
icache  - enable or disable instruction cache
keyset  - keyset - write keyset file into factory area
loady   - load binary file over serial line (ymodem mode)
md      - memory display
mtest   - simple RAM read/write test
mtest2  - simple RAM read/write test
mw      - memory write (fill)
ping    - send ICMP ECHO_REQUEST to network host
reset   - Perform RESET of the CPU
rtkfat  - Realtek FAT32 format utility v1.0
rtkfdt  - RTK fdt utility
rtkgpt  - rtkgpt utility
rtkrng  - rng utility
rtkspi  - spi flash utility
sata    - SATA sub system
saveenv - save environment variables to persistent storage
source  - run script from memory
tftp    - download image from TFTP server
tftpput - TFTP put command, for uploading files to a server
uart_write- for uart mp tool burn mac and sn key

unzip   - unzip a memory region
usb     - USB sub-system
version - print monitor, compiler and linker version
wdpp    - Western Digital Boot Patition Tool

Hi everybody I managed to hack my MCH I have done every step mentioned by you superior users ( especially Kryten I have learned linux basics because of his help ) but I have a little problem I don not know what to do next with Entware .
Is any GUI server I can install with Entware ?
How could I update / remove and re-install Plex media server for more malleability ?
If you Kryten could help me with some tutorials to dig my way into android world ?
And where are the path to my media files stored on plex shared media folders
Any help will be appreciated , thank u everybody in advance .

1 Like

I managed to install Debian Jessie (CLI) , transmission guiding its download folder to (/data/data/com.plex…/aut0|*******/plex) and it is working flawlessly . I also installed netdata server which is awesome because with it I knew the mounted folders for my hdd
I tried to install emby server but i could not get it working because after installation I did not know how to run it because there is no UI to do so even with adb command i could not make it working
Can someone help with emby/plex server ?
Please guys keep this topic up and running

Hello,
Finally I found some spare time to prepare Bootable USB with Ubuntu.
I’ve connected the drive to Ubunto pc, changed build.prop, changed files in saata18. But when I connected this drive To LAN, I can;t localise it - i checked on router by MAC adrress and there is no such device. (my cloud app on android says that the drive is not connected to the internet) Any suggestions how can I find it?
Every piece of advice is appriciated.
Thanks in advance

If I understand you correctly I’d say the most likely cause is that the start-up procedure is failing to initialize the Ethernet interface. This happened to me briefly when I was hacking my MCH. There might be a number of reasons and you need to look at the logs to find out what’s gone wrong.

The interface is started in the last stages of the Android init sequence so your file changes may have broken an earlier start-up phase.

Your best bet is to attach a console cable as described in my previous post. You can then watch the start up live in a Putty session and then, probably, you’ll be able to log onto the console and correct the problem or start the interface manually.

Hello Kryten, did you manage to add smb users and personnal shares ?
I’m still stuck @ run the cron task on every boot and lost in using “smbpasswd -a user”
Any help appreciate :innocent::smiling_face_with_three_hearts:
@juju Many many thanks for the sharing: you rocks !

Yes I did get the MCH to work as a very fast samba host, but not the way I originally intended. Details to follow when I get time, but basically I hacked the MCH startup scripts such that it no longer starts up the WD-installed Samba, and instead starts up the ENTWARE Samba (v3.6). Then I created my own smb.conf to share files from my own fileshares directory on /data/wd/diskVolume0/.

When using the ENTWARE Samba all the config files are held in /opt including the password files.

The MCH is now running about 10x the speed of my old LG NAS, mainly due to the much faster modern hardware but also because the O/S is minimal. It’s so good I even bought another MCH -prices are currently low. I’m experimenting with a cheap blank non-WD disk on this one to see if I can network boot Ubuntu Server and install a full distro.

Hell yeah! Brilliant idea!
I’m not this good to do that on a minute, but I will search in that direction:upside_down_face:
Thank you very much for replying and telling us the key paths. :ok_hand:t4:

Waouh yes !!
I think i got something … dirty, but something :wink: [ok … very dirty !!:innocent::sweat_smile:]
I change the /system/bin/start_samba.sh to look like this: (I had to add the ssh deamon start here because the cron job won’t work for me …)

#! /system/bin/sh

        unset LD_PRELOAD
        unset LD_LIBRARY_PATH
        sleep 3
        /system/bin/mount -o rw,remount /
        sleep 1
        /system/bin/mkdir /opt
        /system/bin/mount -o ro,remount /
        sleep 3
        /system/bin/mount -o bind /data/entware.arm /opt
        sleep 2
        /opt/etc/init.d/rc.unslung start
        sleep 2

function start_samba()
{

    #Start smbd with fail-retry once
    count="0"
    while [ $count -le 1 ]
    do
        smbd_pid=`ps | grep smbd | busybox awk '{print $2}'`
        if [ -z "$smbd_pid" ]; then
            echo "starting smbd daemon"
            rm -f /data/wd/samba/var/run/samba/smbd.pid
            /opt/sbin/smbd -D
        else
            echo "smbd_pid is $smbd_pid"
            break
        fi
       count=$((count+1))
    done

}

PLATFORM=`getprop ro.hardware`
if [ "$PLATFORM" != "yoda" ]
then
        start_samba
fi

install entware samba v3.6 like Kryten said:
opkg install samba36-server
and make my own /opt/etc/samba/smb.conf
regarding the template in the same directory
and smbpasswd -a toto to add my user with a password

=> And a reboot permit me to connect with the password !
I did not make any speed test, but what a cool thing.

@Kryten , if you think it’s not ok or if there is more simple, do not hesitate :wink:

1 Like

Nice bit of smart code there @Western1. You’ve sneaked up on it with a scalpel and made a neat incision. I strode up to it with a bloody great hammer and bludgeoned it into submission. :innocent: I’m never going to get time to make a proper job of documenting it, so I’ll just pass on some notes here.

Firstly, the MCH uses Android which is designed for phones and tablets, not NAS. It’s lightweight and robust and no doubt WD chose it over a Debian distro to maximise performance and make it hard to hack. Android ‘unpacks’ itself on boot, so some startup files you can’t get at, unless you hack the image rather than the live system. Too much trouble!

I read through the startup rc files in the root directory /init*.rc and this was most instructive, although as stated previously, I knew I wasn’t going to mod them. My goal was to stop Android in its tracks and I found that way down the end of the startup sequence it starts up netatalk. This is an Apple protocol to allow IOS devices to connect, and I have none of those. So, I modded /system/bin/netatalk_daemon.sh to subvert Android and then exit. Users of netatalk can probably use the same technique but just remove the exit 0 from the following script. If netatalk fails for any reason it won’t get restarted, though.

The script does this:

  • stops a whole layer of processes that make Android special. Bizarrely, the simple command “stop” does this. For example, there’s one process called SurfaceFlinger which manages touchscreen displays. It has no place I can think of on a NAS!
  • Brings up the ethernet interface and grabs a DHCP address
  • Stops lots of processes I don’t need at the service management level (ie. doesn’t just kill the process but stops it from being started again by the service manager). e.g.
    ** otaclient is an over-the-air updater which would probably overwrite my changes so that had to go!
    ** appmgr starts the native samba so as it’s cut I can use the ENTWARE one instead
    ** restsdk-server communicates with the WD mothership. I don’t want the WD MyCloud functionality
  • Then I start ENTWARE, and because I’ve installed their samba, ntp, cron, dropbear and whatever else I choose to install later, it becomes more like a Debian system.
  • Final thing is to stop the netatalk service management so it doesn’t restart the script.

Paths caused as issue, particularly where ENTWARE startup scripts used busybox commands, so I had to make sure /system/bin was in things like rc.unslung - Something I need to refine a bit when I get chance.

This all gets around the cron issue you describe @Western1 as we are no longer using it to break in.

Here’s the modified /system/bin/netatalk_daemon.sh script:

** EDIT Apr 2020 - commented out the stop of led-server as it’s needed by some system scripts

#! /system/bin/sh

# DO NOT USE THIS SCRIPT UNLESS YOU HAVE A CONSOLE CONNECTED
# AND UNDERSTAND WHAT THE SCRIPT IS ABOUT TO DO TO YOUR NICE
# SHINY MCH. EVEN THEN, THINK HARD ABOUT DOING IT AND IF YOU DECIDE
# TO GO AHEAD DON'T BLAME ME IF IT ALL TURNS TO RATS**T - Kryten

# Hijacked this script to configure system from my own purposes.
# It's called late in the boot process and we don't want appletalk anyway

# Stop the android processes that are only there for phones & tablets

stop

# Bring up the eth0 and get an address

ifconfig eth0 up
dhcpcd eth0

# Stop other android processes I don't need

stop avahi
stop otaclient
stop appmgr
stop installd
#stop led-server
sleep 1
stop restsdk-server
stop media

# Start the ENTWARE environment to make it more like a proper linux system

entware.sh start
sleep 40        
             
# Should now be safe to stop this service so it doesn't repeat
stop netatalk 
exit 0
-----------------------------------------------------------------------------
remainder of original netatalk_daemon.sh

It’s a good idea to watch the startup on the console to see how the startup runs as normal and then kills off all the stuff we don’t need.

2 Likes

I successfully installed entware for arm8l by wget from the previous posts

wget -O - http://bin.entware.net/aarch64-k3.10/installer/alternative.sh | sh

and install dropbear successfully, and try to start it by

/opt/sbin/dropbear -p 22 -a

create the symlinks for
cd /opt/etc/
ln -s /system/etc/resolv.conf resolv.conf

I tried this:
root@monarch32_mini:/opt/etc # /opt/sbin/dropbear -F -E -w -g -p 22
[4565] Jul 24 20:32:04 Early exit: Bad buf_getptr

but I cannot connect with ssh, the port 22 refused my connection. It seems that the dropbear doesn’t start it. The called line /opt/sbin/dropbear -p 22 -a has not any result message, I don’t know why it is doesn’t work. I don’t find here similar problem…can you help me, or write me some diagnostic which can I try?
Thanks.

It seems that the problem is with certificates in /opt/etc/dropbear, the certs have zero length. I tried to delete it but it doesn’t help.
So I tried to use parameter -R for create hostkeys as required,
and finally I try to test dropbear by calling command:

/opt/sbin/dropbear -R -F -E -p 2222
(the port 22 is used already), so I test the connection, and see in the console what happens and the connection is successful. But it is not according your descriptions now…

If port 22 is used already it suggests that dropbear is already running, and it should be if you’ve installed entware as per previous posts.

/opt/var/run/dropbear.pid should indicate the dropbear process id.

The more usual way to start it is

/opt/etc/init.d/S51dropbear start

take a look at the entware start scripts (/system/bin/entware.sh and /opt/etc/init.d/rc.unslung) and you’ll see what I mean.

I got this exact same error as @Antonin_Fisher and fixed it by deleting the zero length host keys and generating new keys using dropbearkey …Once done, dropbear works as expected.

Thanks for help. It works correctly now.
I have second question. I see here just connection of nfs to samba public share. But I have data in private part which is included in the /data/wd/diskVolume0/data/com.plexapp.mediaserver.smb/auth0. Problem is that I set this directory to nfs. It correctly work on linux, but not in windows.
I tried to trick to use symlink of this folder to the samba public share and edit the smb.conf

follow symlinks = yes
wide links = yes

and restart samba (there are some mistakes in the restart). And again it works for linux, but the windows has not rights to the symlink place.

How you solve private repository? Because this private repository is set to Plex and I want to keep this settings. I need same working approach for linux and windows, because more stations with both OS are used for this WD cloud.

I have never tried to use nfs and smb servers together to access the same ext4 filesystem. I think you might have to be careful about file and directory permissions doing this as each server will impose it’s own policy and settings.

Have you considered just using smb server and then running smbclient on the linux client?

Also, you talk about the “samba public share” which makes me think you are using WDs own installed Samba, not the entware one. I can’t comment on this as I replaced it.

Thanks for your response Kryten. I already try it your installation of entware samba. I had almost success, I can use entware samba for linux systems correctly, but it doesn’t work for windows systems. It seems that there is some problem in my configuration file. I tried to use and configure according to template file and smb.conf of WD volume0 folder. But it is still same, I cannot open the smb by windows.
Is it possible to share your working configuration of /opt/etc/samba/smb.conf, and maybe the user creation. I have to adduser for it. I already tried to change the folder owner/group, but still same, linux ok, win not…