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

Ok, it works

now, i’m looking for 2 things :slight_smile:

  1. how to launch dropbear automatically after restart
  2. how to configure samba shares, as i’ve got only public share (but working)
  3. how to configure so i have a netbios discovery of the nas (i need ip to mount)

thanks in advance

well to auto start dropbear I looked at Antonin_Fischer post 85 from August 13 its about how he edited /system/bin/start_samba.sh to auto start samba… all I did was also add dropber in there like this:

#! /system/bin/sh

if mount | grep /data/entware.arm > /dev/null; then
  echo "entware already mounted."
else
  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
fi

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/dropbear -p 22 -a
            /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

About netbios discovery I had it working at first but I lost it later dunno why tho… I was fiddling with smb config file too much or I dunno what happened but it isn’t working anymore…

for share folders you need to find where they are first and then add them to /opt/etc/samba/smb.conf as described in posts 81-83

Thank you

still have an issue

inside the script, there is the command : /opt/etc/init.d/rc.unslung start
inside the rc.unslung, there is the “find” command
there’s a pb :
/opt/etc/init.d/rc.unslung[38]: /opt/bin/find: Accessing a corrupted shared library

i used this version of binaries :
wget -O - http://bin.entware.net/aarch64-k3.10/installer/alternative.sh | sh
and
https://busybox.net/downloads/binaries/1.31.0-defconfig-multiarch-musl/busybox-armv7l

otherwise i cant install busybox


so far i managed to get ssh on start, after while, using cron script
now, i’m looking for samba

you can try replacing /opt/bin/find with /system/bin/find

Found the solution, i had to remove entware dir, then reinstall with the last binaries version.

Now it works, dropbear at launch, and no lib corruption

Need know to configure correctly smbd :slight_smile:

Now i can see the shares, but i go into the shares : “dont have the permissions”

Here’s my smb.conf, what’s wrong ?

[ global]

netbios name = YKM

server string = YKM NAS

workgroup = WORKGROUP

browseable = yes

deadtime = 30

domain master = no

encrypt passwords = true

enable core files = no

guest account = guest

guest ok = yes

local master = yes

load printers = no

map to guest = Bad User

max protocol = SMB2

min receivefile size = 16384

null passwords = yes

passdb backend = smbpasswd

preferred master = yes

printable = no

security = user

smb encrypt = disabled

smb passwd file = /opt/etc/samba/smbpasswd

socket options = TCP_NODELAY IPTOS_LOWDELAY

syslog = 2

use sendfile = yes

writeable = yes

ntlm auth = yes

restrict anonymous = no

[Public]

path = /data/wd/diskVolume0/samba/share

writable = yes

guest only = yes

browseable = yes

force create mode = 0666

force directory mode = 0777

public = yes

[YKM]

path = /data/wd/diskVolume0/samba/share

writable = yes

guest ok = yes

browseable = yes

create mask = 0640

directory mask = 0750

is this symlink or actual folder? change owner and permissions on it
for example if its folder:

chown root:root /data/wd/diskVolume0/samba/share

Well, it was purely a matter of permissions on unix side, not an samba side :slight_smile:

Netbios is working also :slight_smile:

I’m just know tuning, looking for the way to have sensitive case for the name

I try to hack AFP fileserver for macos

i modify /system/etc/netatalk/afp.conf

but after reboot, it dont take change :frowning:

Hi all,

Was anyone able to hack/ssh/adb/console/reflash… a My Cloud Home DUO?

Hello Guys !
I would first like to give a big THANK YOU for this post, and the different answers,
I was so so saad to purchase My Cloud Home and discover that it was not a NAS and I would have to send it back and spent 150€ more with the “NAS” version of Western Digital…

Then I discovered your post, followed it, followed the different comments, read everithing,
and finally made it work !

I would like to create a dedicated tuto page as multiple actions are still mandatory to achieve basic “from My Cloud Home to NAS (windows samba)”, will see… with Covid we have some free time in front of us…

Just a quick question, my you know why, I Still suffer some time to time of having to relaunch manually SSH & SAMBA, even with reboot of device, I still have “no samba” and “access refused” from ssh, I have to go with ADB, and restart manually ssh & samba

/opt/etc/init.d/S08samba restart ; /opt/etc/init.d/S51dropbear restart

ahah ! I just stupidly launched
wget -O - http://bin.entware.net/aarch64-k3.10/installer/alternative.sh | sh
thinking that worst it would say “stop installation allready detected previous version”
but instead system just stopped to work… and now even with ADB it do not want to connect…

Edit (08/04)

well, finally the script of @Kryten replacing natatalk makes my device restarting every minutes (don’t know why, hard reboot with led offline etc…), making quite impossible to manage via ssh the device and even transfering files…

maybe this script is not working with new versions / firmware…

I even tried to put a “if” before the script (test if mounted entware) because I was suposing a scheduler to restart this script and not making a reboot (was not aware that it was a hard reboot at this time), and now I even don’t have access to adb, ssh or nothing during the minute while the disk is online… so, tomorrow: lets unpack everithing and put back the original netatalk_daemon.sh

I know that your script was well in place as dmesg told me some logs before my last “add a if”…

[ 20.702078] pctrl-rtk: do_pcm_work: done
[ 23.343006] type=1400 audit(1388534420.459:76): pid=2703 comm=“mount”
[ 24.355280] type=1400 audit(1388534421.469:77): pid=2704 comm=“mkdir” name=“opt”
[ 27.378670] type=1400 audit(1388534424.499:78): pid=2706 comm=“mount” path=“/data/entware.arm” dev=“sataa22” ino=121683 ioctlcmd=125d
[ 27.391240] type=1400 audit(1388534424.499:79): pid=2706 comm=“mount” path=“/opt” dev=“rootfs” ino=6724
[ 29.408364] type=1400 audit(1388534426.529:80): pid=2702 comm=“entware.sh” name=“rc.unslung” dev=“sataa22” ino=122250
[ 29.419657] type=1400 audit(1388534426.529:81): pid=2707 comm=“entware.sh” path=“/opt/etc/init.d/rc.unslung” dev=“sataa22” ino=122250
[ 29.636887] type=1400 audit(1388534426.749:82): pid=2711 comm=“nmbd” name=“log.nmbd” dev=“sataa22” ino=121715
[ 29.667040] nf_conntrack: automatic helper assignment is deprecated and it will be removed soon. Use the iptables CT target to attach helpers instead.
[ 35.603584] type=1400 audit(1388534432.729:83): pid=2712 comm=“nmbd” name=“browse.dat.” dev=“sataa22” ino=121690
[ 39.643971] type=1400 audit(1388534436.769:84): pid=2721 comm=“dropbear” path=“/dev/pts/0” dev=“devpts” ino=3 ioctlcmd=5401
[ 45.145898] type=1400 audit(1388534442.269:85): pid=2725 comm=“dmesg”

you can look at the end of this post I already posted my exeprience in following this tutorial.

are still arround ? any advice?

previous post:
I observed it previously but was thinking about issue with cron modification that I had aplied following another advice in this post thread, so if someone could help here ?

ok, finally having to reinstall entware (samba not starting, multiple issues, even “grep” was ko)…
So, from Windows & ADB:

  1. Deleted all content of /opt/ to do a clean reinstall (backup few samba config before)

cd /opt
rm -R *

  1. new download and install of entware last version

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

Configuring entware-opt.
Info: Congratulations!

  1. install everithing according tuto

unset LD_LIBRARY_PATH
unset LD_PRELOAD
/opt/bin/opkg install dropbear
/opt/sbin/dropbear -p 22 -a
/opt/bin/passwd
/opt/bin/opkg install nano
/opt/bin/opkg install openssh-sftp-server
/opt/bin/opkg install samba36-server

4.Go on ssh connection to continue to work,

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

  1. Replace netatalk script with the customised one of (I prefer the hammer method), use vi to copy paste (more used to vi than nano)

cd /system/bin/
vi netatalk_daemon.sh.custo
mv netatalk_daemon.sh netatalk_daemon.sh.ori
mv netatalk_daemon.sh.custo netatalk_daemon.sh

  1. edited samba files to replace contents with my backups
    vi /opt/etc/samba/smb.conf
    vi /opt/etc/samba/smbpasswd

  2. my groups, users recreation

addgroup -g 1000 share
adduser -HD -u 1000 -G share -g “user for scripted files transfer between NAS” -s /dev/null
downloader share
adduser -HD -u 1004 -G share -g “the main user” -s /dev/null user share

  1. restart from de Windows PC

adb reboot

Waiting… 1 minutes to have all started… ssh ok, samba shared ok :slight_smile: time to go to bed !

Hi Romain,

I’m guessing you’ve not attached a console if you are rebooting via adb. It is worth reiterating that having a hardwired console where you can see events in real time, makes debugging this device hack much much easier.

Here is something I encountered early on, where the MCH would go offline every 20 mins. I’m not saying it’s what you observed but it may be useful to somebody:

The device has a network check which pings a WD server periodically and, if you have firewalled it on your router (as you should), it eventually decides that the MCH has a fault with its network connection. So it restarts the whole network stack - if you are in ssh at the time you get unceremoniously ejected and of course smb, nfs etc all die. The solution I used was to put this in the /etc/hosts file:

127.0.0.1 staging.mycloud.com

Exactly, you are right, I did not followed your advice for the Console display, to be honest, as I’m not actively hacking it, I prefered to simply apply your advices and tune alittle, without having to let the MCH open, on my desktop, and I do that remotely by night on my laptop… and, I took the risk to brick the device stupidly like I’ve done here.
MCH is currently oppened, I’m restoring your netatalk_daemon without my stupid “if” at the begining, and will also look at your solution for the “ping” to western digital (Yes I followed advice to iptable), keep you posted, BIG thanks for this very quick reply.

Edit: @Kryten for info:
After removed my stupid “if” and replugged the MCH to power it was runing for more than 2 min without reboot, then I plugged network… lights On: booom Shutdown, and restart every 2 minutes. :-OOOO
Event if I added the 127… (I added it before default 127…) and there was also a ipv6 line at the end. But I tried to remove IP table rules, finally I had not them running by the way.

So, during the 2 minutes online I SSH it to remove your startup script, and at next reboot it was ok, device is now running well while I’m writing this message…

So… not sure in fact your script is compatible with last MCH versions ? anything to do with the fact that you mount the network interface in your script, etc?

I will then try to apply the “cron” solution to restart entware, ssh and samba waiting to understand more this strange MCH

@RomainBagdam - OK, well if you don’t have the option to attach a console you could try searching these logs for the instant when your connection broke:

/data/logs/main.log
/data/logs/system.log

They will give you more useful debug info than dmesg in this situation.

On your suggestion about firmware updates causing a problem. It is possible but unlikely, I think, as WD probably consider the MCH to be near end-of-life. Remember that this little box is running a version of Android - it’s an OS, not firmware, and any updates will be to the OS services/scripts (and mainly for security reasons). The only firmware involved is what’s burned into the RealTek board and this can’t be updated remotely.

@Kryten thanks, that’s what I’ve done the same night before you posted this answer,
I also replaced the custom Samba start script of Antonin_Fischer with the one of @bumbak reply#103, and now My device is working 100% ok, no more restart. I supose this was linked to android program that check at regular intervals for running scripts/programs and relaunch WD custom scripts (we modified), entware via rc.unslung script was certainly restarted regularly.

I would really like to know more on Android standard boot, WDMCH custom boot scripts sequence, then be able to customise a little bit more “clean” the device…
Maybe create a more simple tuto to get a NAS quickly from this device…

Then… I spent some hours to look at the different logs that are more in this folder on my device:

    /data/wd/diskVolume0/logs/upload/main

And found that usually the reset button script was invoked by the system to do a reset, don’t know why,

sh      : type=1400 audit(0.0:1034): path="/system/bin/reset_button.sh" dev="sataa20" ino=259

and while inspecting the reset button script I discovered that there is way to physically shutdown the device (don’t know what is the custom manual/physical action to do on the button, maybe hit twice…)… in the official manual it is not explained how, only 3 possibility:

  • 1 time: reset
  • hold more than 30s: reset ownership to create new mycloud owner
  • hold more than 60s: Factory reset (and data)

.

/system/bin/reset_button.sh
#log -p -i -t "reset_button" "$1 $2"
if [ "$1" == "short" ]; then
led_ctrl_client -s 7
log -p i -t "reset_button" "short press - reboot"
reboot
elif [ "$1" == "long" ]; then
log -p i -t "reset_button" "Perform Hardware Reset"
led_ctrl_client -s 7
notify_cloud -s reset_button -n 134
sleep 5
led_ctrl_client -s 20
elif [ "$1" == "factory" ]; then
log -p i -t "reset_button" "Perform Factory Reset"
notify_cloud -s reset_button -n 136
sleep 5
factory_reset.sh
elif [ "$1" == "shutdown" ]; then
set_clean_shutdown
led_ctrl_client -s 8
log -p i -t "reset_button" "shutdown ..."

But discovered lot of strange things I need to investigate: :sweat_smile:

The device can (or it does) send the logs to Western digital’s Amazon buckets
The script responsible of logs upload contains the bucket secret keys… I need to know how to use them !

/system/bin/setup_logs_config.sh
if [ -z "$AWS_BUCKET" ]
then                                        
    AWS_BUCKET="wd-portal-prod-fwcrashdump"
AWS_BUCKET=$(setprop debug.log.upload.aws_bucket "$AWS_BUCKET")
fi   

if [ -z "$AWS_ACCESS_KEY_ID" ] || [ -z "$AWS_SECRET_ACCESS_KEY" ]
then
	AWS_ACCESS_KEY_ID="AKIAJUO************"
        AWS_SECRET_ACCESS_KEY="Qq9i+k30OuzjzUAA*********"
fi

Network/internet test you are right, looking at logs show the device verify local network, gateway and internet access to WD… by the way, in the official manual it’s written that device MUST be connected to Internet…

/data/wd/diskVolume0/logs/upload/main # cat *

2020-04-17T00:22:10.696Z  2758  9615 I ConnectivityService: checking ethernet link
2020-04-17T00:22:10.696Z  2758  9615 I ConnectivityService: checking gateway
2020-04-17T00:22:10.696Z  2758  9615 I ConnectivityService: ping gateway 192.168.#.#, count 0
2020-04-17T00:22:10.721Z  2758  9615 I ConnectivityService: ping staging.mycloud.com, count 0
2020-04-17T00:22:10.747Z  2758  9615 I ConnectivityService: diagnosisNet success.

**And a script that seems to be used to gather regular details about the device… do some network tests also… **
/system/bin/filebeat_start.sh

But it’s associated to a program, not a script, so no idea of what it really does…

"/system/bin/filebeat" (12 MO...)

results seems to be writen in specific file… /etc/filebeat.yml

how to get info on architecture/version of the system

# /system/bin/getprop ro.hardware
monarch

there is a web server content I would really like to be able to use

/system/data/www/htdocs/
index.html etc

and there is a wab server running with lighthttpd,

http://192.168.0.**:33284

But can’t see any files in here with standard internet browser

interesting help explaining the usage of some folders

/system/bin/move_upload_logs.sh
export HOME=/data

CONFIG_FOLDER=/wd_config
BASEPATH=/data/logs
TOMBSTONEBASEPATH=/data/tombstones
PSTOREBASEPATH=/sys/fs/pstore
OTABASEPATH=/data/wd/ota
FACTORYRESETBASEPATH=/wd_config
PLEXBASEPATH="/data/data/com.plexapp.mediaserver.smb/Plex Media Server/Logs"
UPLOADEDLOGSPATH=/data/wd/diskVolume0/uploadedLogs
SMARTCTLBASEPATH=/tmp

another script that shall be helpful… to get info on the device…

host_util.sh

function show_help
{
echo "WD Host Utility version $SCRIPT_VER"
echo "Usage: $SCRIPT_NAME [Options]"
echo "Options:"
echo "-sn			- Show serail number"
echo "-mac			- Show mac address"
echo "-time			- Show time"
echo "-hdd [sn|cap|temp]	- Show HDD [serail number|capacity|temperature]"
echo "-cpu			- Show CPU usage"
echo "-version		- Show platform OS version"	
exit 0
}

All in All, the device is remotely configured from mycloud.com, and from your account you can donwload device logs (explaining why they built in a log export function), disable the option to send logs to western digital (thanks god, EU laws on personal data protection force them to put this kind of options), shutdown the device, restart, factory reset, etc… So, it’s a little bit “by design” that we have all those “strange” scripts… but I woul really like to understand more how their technical architeture is working to achieve all of that :slight_smile:

And, finally not so surprised that the device reboots every 2 minutes if it countiniously fail to connect to mycloud (with your startup script), it is logic, device is broken from Western Digital point of view if it doesn not connect sucessfully to internet…
last question Kryten, regarding your /etc/hosts file what do you exactly have inside at the end, I would try.

1 Like

Just found a way to install Debian on this sheet:
Install Debian on WD My Cloud home(in french, but translate from http://4pda.ru/forum/index.php?showtopic=467828&view=findpost&p=87961189 )

1 Like

:scream:wOOOOw
la classe !
Thank you for this post @Western1, May the force be with me to give a try :slight_smile: