Intro
Since 2017 I have been using an Western Digital My Cloud Mirror Gen 2 which I bought at Amazons Black Friday (or similar) - because the included 2x 8 TB WD Red were even cheaper with the NAS than standalone. Using the NAS had been quite ok, especially the included Docker Engine and Plex Support were a nice to have, the included Backdoor in older Versions - not so much. Recently WD had their new "My Cloud OS 5" replace the old My Cloud OS 3 - and made things worse for a lot of people. As I don't want any more surprises - and more control over my hardware - I decided to finally go down the road and get Debian 11 with an LTS (5.15) Kernel running on the hardware. This is how it went.
Warning
Warning, these are just my notes on how to convert a My Cloud OS 3 / My Cloud Mirror Gen 2 device to a "real" Debian system. You will need to take your device fully apart, solder wires and lose the warranty. Additionally you will lose all your data and even brick the hardware if something goes wrong, I am taking in no way responsibility, neither can I give support. You're on your own now.
Step 0: Get Serial Console Access
Without a serial console, you will not be able to do anything here. You will need to completely disassembly the NAS and will lose all warranty. The plain motherboard will look like this. On the most right side you will see the pins for the UART interface you will need to solder to.
When you're done with that, connect your 3v3 TTL UART USB device like this:
... and connect to it via 115200 BAUD with Putty, TeraTerm Pro or any other software (Do not connect the 3v3 pin :)). It would be wise starting without the hard drives installed.
Step 1: Flashing U-Boot
The current U-Boot on the NAS is flawed, you need to replace it. I will be CyberPK here which did an awesome job explaining everything:
We have to prepare an usb drive formatted in Fat32, and extract the uboot at link into it and connect to usb port#2.
Connect the device to the serial adapter, poweron the device and start pressing '1' (one) during the boot until you can see the 'Marvell>>' Command Prompt
press ctrl+c
then
We will start here to change stuff and break stuff. But if I could give you one tip before you start: Please execute printenv once. Copy and paste all env variables and everything Uboots spits out. It could save your hardware one day. Thanks, Nico out!
usb start
bubt u-boot-a38x-GrandTeton_2014T3_PQ-nand.bin nand usb
reset
This will reboot the device. Access again the Command prompt and add the following envs, a modified version of the ones provided by bodhi at this post:
setenv set_bootargs_stock 'setenv bootargs root=/dev/ram console=ttyS0,115200'
setenv bootcmd_stock 'echo Booting from stock ... ; run set_bootargs_stock; printenv bootargs; nand read.e 0xa00000 0x500000 0x500000;nand read.e 0xf00000 0xa00000 0x500000;bootm 0xa00000 0xf00000'
setenv bootdev 'usb'
setenv device '0:1'
setenv load_image_addr '0x02000020'
setenv load_initrd_addr '0x2900000'
setenv load_image 'echo loading Image ...; fatload $bootdev $device $load_image_addr /boot/uImage'
setenv load_initrd 'echo loading uInitrd ...; fatload $bootdev $device $load_initrd_addr /boot/uInitrd'
setenv usb_set_bootargs 'setenv bootargs "console=ttyS0,115200 root=LABEL=rootfs rootdelay=10 $mtdparts earlyprintk=serial init=/bin/systemd"'
setenv bootcmd_usb 'echo Booting from USB ...; usb start; run usb_set_bootargs; if run load_image; then if run load_initrd; then bootm $load_image_addr $load_initrd_addr; else bootm $load_image_addr; fi; fi; usb stop'
setenv bootcmd 'setenv fdt_skip_update yes; setenv usbActive 0; run bootcmd_usb; setenv usbActive 1; run bootcmd_usb; setenv fdt_skip_update no; run bootcmd_stock; reset'
saveenv
reset
(This code was also modified by me to use the fatload instead of the ext2load)
With this, our NAS is ready.
Step 2: Build a kernel and rootfs
- On your current linux machine, get yourself a copy / git clone of Heisaths wdmc2-kernel Repo
- Get all dependencies installed according to this repo, I installed it on a Debian 11 machine
- Replace the file content of wdmc2-kernel/dts/armada-375-wdmc-gen2.dts with the content of the real and improved dts for the WDMCMG2 (original from this link, copy available here) - but keep the file name still armada-375-wdmc-gen2.dts
- Replace the file content of wdmc2-kernel/config/linux-5.15.y.config with the file from here (please know this config ain't perfect, but it will get you running. You can always file a PR and help me out ;))
- Start the build process in wdmc2-kernel with ./build.sh
- Mark: Linux Kernel, Clean Kernel sources, Debian Rootfs, Enable ZRAM on rootfs
- Kernel -> Kernel 5.15 LTS
- Build initramfs -> Yes
- Debian -> Bullseye
- Fstab -> usb
- Rootpw -> whateverYouWant
- Hostname -> whateverYouWant
- Locales -> no changes, accept (or whatever you want)
- Default locale for system -> en_US.UTF-8 (or whatever you want)
- Tzdata -> Your region
- Now your kernel and rootfs will be build
While this is on-going, get yourself a nice USB 2.0 or USB 3.0 stick prepared with
- partition table: msdos
- 1st partition: 192 MB, FAT32, label set to boot, boot flag enabled
- 2nd partition: rest, ext4, label set to rootfs
When the kernel is done compiling and your usb stick is done, copy all the files (sda is the name of my usb stick
- mkdir /mnt/boot /mnt/root
- mount /dev/sda1 /mnt/boot
- mount /dev/sda2 /mnt/root
- mkdir /mnt/boot/boot
- cp wdmc2-kernel/output/boot/uImage-5.15.* /mnt/boot/boot/uImage
- cp wdmc2-kernel/output/boot/uRamdisk /mnt/boot/boot/uInitrd
- tar -xvzf wdmc2-kernel/output/bullseye-rootfs.tar.gz --directory=/mnt/root/
- rm -rf /mnt/root/etc/fstab
- cp /mnt/root/etc/fstab.usb /mnt/root/etc/fstab
// within /mnt/root/etc/fstab:
// change all /dev/sdb to /dev/sdc if all two drive slots on the NAS are used <- this!
// change all /dev/sdb to /dev/sda if no drive slots on the NAS are used - umount /mnt/boot /mnt/root
Step 3: First boot and getting things running
Insert the USB stick into the 2 slot of the NAS. Leave the drives still out and boot it up for the first time, watch it via terminal. Login at the end with root and your chosen password.
If it boots, you can shut it down again with shutdown -P now, unplug power, insert the drives and reboot.
First thing after the first boot with drives, your own initramfs / Ramdisk from your current setup:
- cd /root/
- ./build_initramfs.sh
- cp initramfs/uRamdisk /boot/boot/uInitrd
Second, install MDADM for the RAID:
- apt update
- apt install mdadm
- mkdir /mnt/HD
- edit your /etc/fstab and add a mount point for your md/raid. I used the old drives with my old data on it like this (depending on the fact as which mdX it launches...)
/dev/md0 /mnt/HD ext4 defaults,noatime,nodiratime,commit=600,errors=remount-ro 0 1
A lot of good knowledge about Ramdrives can be found here.
I would advise to do steps: 1. Folder2RAM, 2. Kernel Options, 4. Logrotate - option 3 did not work out for me.
To get the drive to sleep at some point, we need to reconfigure MDADM
dpkg-reconfigure mdadm
// monthly check ok
// daily degration check ok
// monitoring disable
... and get hdparm working
apt install hdparm hd-idle
# hdparm config
, add in /etc/hdparm.conf
/dev/sda {
# apm = 127
# acoustic_management = 127
spindown_time = 120
# spindown_time = 4
write_cache = on
}
/dev/sdb {
# apm = 127
# acoustic_management = 127
spindown_time = 120
# spindown_time = 4
write_cache = on
}
# Spindown Time means: 120 * 5 sec = 600 sec / 60 sec = 10 min
# apply it after saving the file with:
/usr/lib/pm-utils/power.d/95hdparm-apm resume
We can check the status of the drives with smartctl
smartctl -i -n standby /dev/sda
smartctl -i -n standby /dev/sdb
To get fan control working
apt install wget
wget -O mcm-fancontrol-master.tar.gz https://github.com/nmaas87/mcm-fancontrol/archive/refs/heads/master.tar.gz
tar -xvzf mcm-fancontrol-master.tar.gz
cd mcm-fancontrol-master/
cp fan-daemon.py /usr/sbin/
chmod +x /usr/sbin/fan-daemon.py
cp fan-daemon.service /etc/systemd/system/
systemctl enable fan-daemon
systemctl start fan-daemon
(You can change low temp and high temp in the /usr/sbin/fan-daemon.py
to get the Fan to kick in later and also set DEBUG = True
if you want to see some details in the systemctl status fan-daemon
)
MDT Utils can be useful, just mentioning it here
apt install -y mtd-utils
cat /proc/cmdline
cat /proc/mtd
Samba ...
apt install samba --no-install-recommends
# change /etc/samba/smb.conf to your liking and setup your SMB
Plex ...
# Plex
apt update
apt install apt-transport-https ca-certificates curl gnupg2
curl https://downloads.plex.tv/plex-keys/PlexSign.key | apt-key add -
echo deb https://downloads.plex.tv/repo/deb public main | tee /etc/apt/sources.list.d/plexmediaserver.list
apt update
apt install plexmediaserver
systemctl status plexmediaserver
Well, that's it.
Thanks a lot to all awesome contributors in the net:
- https://github.com/Heisath/wdmc2-kernel
- https://github.com/gisab/WDMC-Ex2
- https://github.com/vzhilov/WDMC-Ex2-Ultra
- https://github.com/Johns-Q/wdmc-gen2
- https://github.com/Zeik0s/wdmc-gen2
Companion repo with files: https://github.com/nmaas87/WDMCMG2
Hey do you know the dts file for a "WD MyCloud Ex2"?
```
# cat /proc/cpuinfo
Processor : Marvell PJ4Bv7 Processor rev 1 (v7l)
BogoMIPS : 1196.85
Features : swp half thumb fastmult vfp edsp vfpv3 vfpv3d16 tls
CPU implementer : 0x56
CPU architecture: 7
CPU variant : 0x1
CPU part : 0x581
CPU revision : 1
Hardware : Marvell Armada-370
Revision : 0000
Serial : 0000000000000000
```
Oh I believe I found one! https://github.com/gisab/WDMC-Ex2/blob/main/3.Kernel/armada-370-wdmc-mirror-gen1-gs.dts
Hey there, I think the EX2 was just the Mirror Gen 2 with double the RAM/Memory... or something like that. I don't recall it too well to be honest, but I think that would be the only difference. I am sure that somehwere in the links I added I saw some stuff for the Ex2, but I am a bit off the rails right now (like, I know I saw it.. but where?! :D)
These repos should have some files for it:
https://github.com/vzhilov/WDMC-Ex2-Ultra
https://github.com/gisab/WDMC-Ex2
Hi,
Very useful post. However, I would like to flash the nand memory instead to use the USB key. How could I get (or create) the uImage and the uRamDisk to boot the box from the USB and flash it??
Many thanks in advanced.
Hi, I don't know. I guess its technically possible, but this is beyond the scope. Reason why I never looked into it are these both points:
a) Leaving the NAND intact means you can easily jump back if something goes horribly wrong
b) NAND is quite small (I think 256 MB?) - so it will not be enough to even host the basic Debian 11 system without any apps (mine with just using SMB, OpenSSH is more than 2 GB in size, with Plex even 3 GB). WD actually had the same issue, so it installs all apps on a part of the RAID disk which makes the hard drive constantly spin up if any activity takes place. Partitioning the boot and root partitions again should be possible, but I have not tried this yet. You could look up probably some other people have done it. Best of luck!
Hey Nico,
Thanks for your answer. Indeed, the NAND is too small, that's why the OS would be in the internal drives.
Basically my idea would be the following, but with a new kernel 🙂
cd /mnt/root
wget http://fox-exe.ru/WDMyCloud/WDMyCloud-Ex2-Ultra/Dev/Linux-4.15.0-rc6/libs-4.15.0-rc6.tar.gz
wget http://fox-exe.ru/WDMyCloud/WDMyCloud-Ex2-Ultra/Dev/Linux-4.15.0-rc6/uImage
wget http://fox-exe.ru/WDMyCloud/WDMyCloud-Ex2-Ultra/Dev/Linux-4.15.0-rc6/uRamdisk
tar xvf libs-4.15.0-rc6.tar.gz
dd if=/dev/zero of=/dev/mtdblock1
dd if=uImage of=/dev/mtdblock1
dd if=/dev/zero of=/dev/mtdblock2
dd if=uRamdisk of=/dev/mtdblock2
rm uImage uRamdisk libs-4.15.0-rc6.tar.gz /mnt/root/lib/modules/4.14.4 -r
I'm unable to solder the pins... I'm just getting charaters without any sense:
�������_�����_�_�_�}����������__���������������������
I was able to solder the pins, everything works, because I've tested with a tester, but, I have not getting anything. The uart-ttl device works with 3.3v and 5v. is it ok? I don't know what else I can do.
Thanks
Try to use cables as short as possible for the TTL, switch TX/RX as it could be mixed up and a 3v3 only converter is besser in that case, but you should initially be able to see something on a 5v TTL - but I would not recommend it using it with the WD.
Thanks for your answer Nico, I've tried all the combinations, but nothing works.. I have nothing in the screen... I'm done, even, the WD can't boot and I don't know how to recover it.
Have you tried removing all connections from the board? It sounds like there is a short circuit or similar.
Yes, I did, but nothing works. The power led blinks in blue, but nothing else. The network is blinking too, but, no ip.
Thats bad. I would pull the drives and see if that does something. Other than that I would recommend to look into the official forums for recovery ideas: https://community.wd.com/ - but if your WD My Cloud Mirror Gen 2 of yours does not come up with any serial console output and you know the serial interface is good, than thats a bad sign. The garbage you described earlier were the constant serial output during boot which was probably garbled due to bad grounding or too long cables. If it does not give out any output anymore it could be that the unit is fried. There is nothing I can help you with, sorry!
Hey Nico,
Do not ask me how or why, but I was able to get the WD back to live using an internal drive. However, the serial port is not working... nothing in putty.
Hi Nico,
I have tried many things, but the UART doesn’t work. But I was thinking if you would be so kind and you could jump your u-boot partition to flash mine. To me it would be the only way to upgrade the kernel to the latest.
Thanks, in advanced.
I was looking into this and wanted to grab mtd0, which is Uboot.
However, I found out that I did not include the mtd modules in my kernel, so I can only access the NAND via U-Boot and have no time for this for the next weeks. I stumbled upon this post, which says mtd0 is read-only in everything else but Uboot, meaning you will not be able to flash Uboot from anything else other than within uboot. So if the serial/UART is fried, you cannot flash a new version. You could try with the old installed version, but if something goes wrong with the boot env - or they don't work - your device will really brick and you cannot use it anymore. Your choice, but I would refrain from doing that. https://community.wd.com/t/alternative-firmware-debian-jessie-synology-dsm6/156551/580
Hi Nico,
Thanks for your reply. You can get it with a dd in rescue mode, in fact I have dumped mine.
Indeed, I can’t use the old version, because the env variables are not set or updated.
As you mention, I’m not going to play with the u-boot, because I could brick it. I have asked to Debian forum, let’s see if they can help too. Anyway, many thanks for your time and help.
Is it possible to provide me with the bullseye rootfs?
I am just playing around with an old WDMCM2 I got and can only find strech rootfs from fox-exe.
Yes, I uploaded the rootfs, boot and modules here: https://mega.nz/folder/NnhkgZyY#jQn7UduI7XZz5MIOM-CKUQ