This page documents how to run vanilla debian jessie on the Western Digital EX2 Ultra.
This page is based on the information from the doozan forum and the wd community. Fox exe from the WD forum did a great job of finding a lot of infos and Carl built the initrd to boot debian. Many thanks to them. Without their work it would have taken much longer to get to the success we have now.
The WD MyCloud EX2 Ultra is a small NAS device manufactured by Western Digital featuring two 3.5“ SATA slots a gigabit network interface and two USB-3 Ports. It has 1GB of RAM and 256MB NAND flash on board. An identical cousin is the WD MyCloud Mirror Gen2 with the difference of only having 512MB RAM. since the amount of FLASH is not sufficient to accommodate a full debian system, I decided to store only kernel and initrd in FLASH and put the operating system on the disks. It is based on debian jessie for the armhf architecture. You need a custom kernel and initrd to boot the system.
Since the disks are used for the operating system they rarely are able to sleep. This leads to temperatures in the system which require the fan to be kept running. It's a small 40mm fan which does not make much noise at low speeds, but I guess it's lifetime will suffer if run permanently. Because of this I decided to equipe the system with SSDs or 2.5” disks. With SSDs the fan is almost never needed except when the system is running under high load for hours. With 2.5“ disks the fan get's a little bit more work when there is a lot of disk I/O happening (e.g a RAID rebuild), but it is always off under normal load with the disks well below 40°C.
I'm operating three devices (WDBVBZ0000NCH) in different locations. One contains two SSDs from Samsung (MZ-75E1T0B) and WD (WDS100T1B0A). The other two use 2.5” harddisks from Toshiba (MQ03ABB300) and Seagate (ST3000LM024). I prefer running different brands of disks in RAIDs to avoid firmware or controller based failures under certain circumstances at the same time. To fit the 2.5“ devices into the 3.5” slots I used these adapters.
To install and run the device with debian you need a custom compiled kernel. The debian supplied kernel won't work with the device and probably never will, as the installed bootloader misses some features to make the platform selection work. You can't change any of the boot environment variables as the original uboot uses fixed compiled-in defaults.
u-boot-tools
package
You need to create a bootable usb-stick with your compiled kernel image and the debian installer ramdisk. Powering the EX2 while pressing the reset button on the back will make the bootloader search for usb devices. It recognizes DOS vFat partitions and searches for the files uImage
and uRamdisk
in /boot
.
You already created the kernel image in the part about compiling the kernel but you still need the ramdisk image to install debian.
wget http://ftp.de.debian.org/debian/dists/jessie/main/installer-armhf/current/images/netboot/initrd.gz mkimage -A arm -T ramdisk -n "debian jessie installer" -c gzip -d initrd.gz uRamdisk wget https://github.com/cschil/WD-385-initrd/raw/master/uInitrd-wd385
We need to create two partitions on the stick. The first is a FAT file system for the boot loader with kernel and debian install ramdisk. The second one is an ext4 file system on which we copy the stuff we need to make the system bootable after the debian installer is finished. The total amount needed is around 250MB, so any old stick should do.
echo -e "0 40 0xb\n,200" | sfdisk -u M /dev/<stick> mkfs.vfat -F32 /dev/<stick1> mkfs.ext4 /dev/<stick2> mount /dev/<stick1> /mnt/ mkdir /mnt/boot cp uImage uRamdisk /mnt/boot umount /mnt mount /dev/<stick2> /mnt/ cp uImage uInitrd-wd385 mcm-daemon_1.00_armhf.deb modules.tgz /mnt umount /mnt
picocom -b 115200 /dev/ttyUSB0
or similar.You will see the bootloader scanning the USB-bus twice and after about 20s you should have the normal debian installer on the serial console. Keep the reset button pressed until you see the device booting the kernel in the console output.
Continue without kernel modules
, when asked. All drivers are compiled in.rootfs
when creating the root filesystem or the initrd won't boot it.none
.Execute a shell
.Execute the steps necessary to make the system bootable. You need to prepare the target filesystem to be able to chroot into it and to execute the flash commands.
mount -o bind /dev/ /target/dev mount -o bind /dev/pts/ /target/dev/pts mount -o bind /proc /target/proc mount -o bind /sys /target/sys mount /dev/sdc2 /target/mnt
We can now chroot into the target system to remove systemd install the mtd-tools and the mcm-daemon. It's important to remove systemd as it doesn't cope with the ramdisk assembling your filesystems. With systemd you will end up with an unbootable system as Poettering's brain fart is unable to realize, that everything it needs is already there and will complain in an endless loop.
chroot /target /bin/bash aptitude update aptitude install sysvinit-core mtd-utils smartmontools dpkg -i /mnt/mcm-daemon_1.03_armhf.deb tar xvzf /mnt/modules.tgz -C / depmod -a
Now check that the flash-partitions are the same as in this example:
root@debian:/# cat /proc/mtd dev: size erasesize name mtd0: 00500000 00020000 "U-Boot" mtd1: 00500000 00020000 "uImage" mtd2: 00500000 00020000 "uRamdisk" mtd3: 0b900000 00020000 "image.cfs" mtd4: 00f00000 00020000 "rescue fw" mtd5: 01400000 00020000 "config" mtd6: 00a00000 00020000 "reserve1" mtd7: 00a00000 00020000 "reserve2"
As you can see the kernel belongs in /dev/mtd1
and the ramdisk belongs in /dev/mtd2
. We can now flash the kernel and ramdisk.
flash_erase /dev/mtd1 0 0 flash_erase /dev/mtd2 0 0 nandwrite -p /dev/mtd1 /mnt/uImage nandwrite -p /dev/mtd2 /mnt/uInitrd-wd385
If you want the system to boot unattended you can write your passphrase into the config-space of the ex2u.
ubiattach -p /dev/mtd5 mount -t ubifs /dev/ubi0_0 /mnt/ mkdir /mnt/initrd echo -n "<your passphrase>" > /mnt/initrd/key.luks rm -f /etc/crypttab
The option -n
after echo
is important to create a file without trailing newline or the decryption of the device would fail.
The file /etc/crypttab
needs to be removed to keep the init system from asking again for the passphrase.
After successful completion of all steps we are ready to reboot the system. Just exit the shell and return to the debian installer. Select Finish the installation
and let the system reboot.
A serial console via 3.3V TTL serial converter is required to install debian on the EX2. It might be possible to do it without, but sooner or later you will lock yourself out and will need it anyways if you don't want to install the system from scratch. You can get the pin-out from the picture. I soldered a header on the board and connected the wires to a 3.5mm audio jack, I built into the back of the device. I use this type of connection on all my embedded devices.
The labels in the image denote which wire of the TTL-converter to connect, it's already “crossed”.
One person from the doozan forum suggested that you can use a SATA cable to connect to the board edge slot since it has the same 1mm spacing as the SATA connector. I tried it and didn't get it to work.
The uboot bootloader and kernel talk with 115200N81 on the port.
— MM 2017-03-09