Debian Linux on the My Cloud PR4100/PR2100

Thank you, that didn’t work for me on Stretch:

root@unassigned-hostname:~# apt install linux-image-4.9-amd64 linux-headers-4.9-amd64 linux-source-4.9
Reading package lists... Done
Building dependency tree       
Reading state information... Done
E: Unable to locate package linux-image-4.9-amd64
E: Couldn't find any package by glob 'linux-image-4.9-amd64'
E: Couldn't find any package by regex 'linux-image-4.9-amd64'
E: Unable to locate package linux-headers-4.9-amd64
E: Couldn't find any package by glob 'linux-headers-4.9-amd64'
E: Couldn't find any package by regex 'linux-headers-4.9-amd64'

I was able to do this instead:

sudo apt install linux-headers-amd64 linux-source-4.9

Then everything else worked except for the last step:

debian@unassigned-hostname:~/kbuild/linux-source-4.9$ sudo make M=drivers/tty/serial modules_install
  INSTALL drivers/tty/serial/8250/8250_lpss.ko
  INSTALL drivers/tty/serial/8250/8250_moxa.ko
  INSTALL drivers/tty/serial/8250/serial_cs.ko
  INSTALL drivers/tty/serial/jsm/jsm.ko
  INSTALL drivers/tty/serial/rp2.ko
  DEPMOD  4.9.130
debian@unassigned-hostname:~/kbuild/linux-source-4.9$ sudo depmod
debian@unassigned-hostname:~/kbuild/linux-source-4.9$ sudo modprobe 8250_lpss
modprobe: FATAL: Module 8250_lpss not found in directory /lib/modules/4.9.0-8-amd64

I fixed that by starting over and modifying the following two lines in the Makefile first (as explained in How to recompile just a single kernel module?):

SUBLEVEL = 0
EXTRAVERSION = -8-amd64

Hi @Tfl, would you please update your guide? I followed the instructions and my PR4100 shut down immediately and disabled SSH. :frowning:

2018-11-18 14:55:05,309 - main - ERROR - WdHwDaemon: Daemon failed with PMCCommandRejectedException: ; exiting
2018-11-18 14:55:11,733 - main - ERROR - FanControllerImpl: Overheat condition requires immediate shutdown

The happy solution is to use the fork of wdnas-dl2100-hwtools (which took me hours to find :roll_eyes:): https://github.com/WDCommunity/wdnas-hwtools

Here’s how to create an installation drive from macOS:

Format a USB drive using Disk Utility:
Format: MS-DOS (FAT)
Scheme: Master Boot Record

$ hdiutil attach -nomount debian-9.5.0-amd64-netinst.iso
/dev/disk3              Apple_partition_scheme
/dev/disk3s1            Apple_partition_map
/dev/disk3s2            Apple_HFS
$ mkdir -p /tmp/debian-installer
$ mount -t cd9660 /dev/disk3 /tmp/debian-installer
$ cp -L -R /tmp/debian-installer/. /Volumes/UNTITLED/
cp: /tmp/debian-installer/./debian: directory causes a cycle
$ umount /tmp/debian-installer/
$ hdiutil eject /dev/disk3
$ cp preseed.cfg /Volumes/UNTITLED/
$ cp grub.cfg /Volumes/UNTITLED/boot/grub/
$ diskutil unmount /Volumes/UNTITLED/

Hehe, sorry again :slight_smile:
I’ll add the link to the original guide. I didn’t do it yet as editing the posts makes it a bit more difficult to follow this thread. I’ve barely tested my fork (even though it has the required changes to use it on a PRx100).

Thanks for contributing the instructions for macOS!

Edit: regarding your kernel issues: you need the kernel headers, image and source of the same version (linux-header-xxx, linux-source-xxx and linux-image-xxx). Check your /boot/grub/grub.cfg and current kernel with uname -r: my guide requires you to run the same version as you’re building for.
Or simply use @dswv42’s kernel…

I added some new features in the wdhw tools:

  • Set the LCD text and brightness with the wdhwdaemon.client module
  • Run scripts when buttons are pressed
  • Added a dsm branch. Note that I won’t make a guide nor provide support on this subject.

Cool, thank you!

WARNING: this doesn’t work. To be updated in the future.

Instructions to run the installer in a local VM, installs debian to a local disk. Then plug the disk to boot the My Cloud device.
FIrst make sure the usb flash drive is not mounted anymore.
Then create a file with the full preseed config from the first post. It needs to be named preseed.cfg, otherwise you’ll need to use extra-args for the kernel.

sudo apt install qemu-kvm libvirt-bin virtinst
sudo virt-install --name wdnas \
           --memory 256 --boot uefi \
           --location=http://ftp.be.debian.org/debian/dists/stable/main/installer-amd64/ \
           --disk /dev/sdc \
           --initrd-inject ./preseed.cfg

Note: select a nearby ftp mirror from https://www.debian.org/mirror/list

When the install finishes you can install the WD hw-tools and OMV and whatever you like, no need to use SSH even.
When you’re done, shutdown the VM

sudo virsh destroy wdnas
sudo virsh undefine wdnas

Unplug the drive from your pc and plug it the My Cloud NAS. Boot the My Cloud NAS and enjoy!

1 Like

Hi :wave:

I tried the QEMU install on USB but I never managed to make the NAS boot from USB.
I tried every ports (the front one and both back).
Een when I remove the 4 hard drives, the NAS still boot on the internal firmware and never boot from the USB stick (GPT formatted, using a Debian Stretch bootable system).

Is there something to do to be able to boot from USB ?

Hello.
Thanks for everyone hard work. :slight_smile:
Been following forums and github for months now. My WD dl4100 did the crash again and cold not find the firmware. Got it working and backed up everything. Then installed debian 9 via serial and then OMV. Setup everything and was ready to dive into Micheal Rolands github for x64 WD systems. Everything was kind of secful after the script would not run because of the double brackets. Ran the script and it deleted the files from wdhwd install dir. After recreating all the files and scripts, the script kept handging so I did it by hand. Got it in and running. Rebooted her and the daemon won’t run. here is my error.
2018-12-29 19:21:56,285 - main - ERROR - WdHwDaemon: Daemon failed with SerialException: Could not configure port: (5, ‘Input/output error’); exiting

any help to get her running correctly would be greatly appreciated.
Thank you
Tony

@noirbizarre I used the libvirt installation to deploy Ubuntu 18 (which needed some additional steps) and only did a quick run with Debian without running it on my NAS. I’m also having troubles with booting so I’ll revisit that post when I figured it out.

@Tonysch on a DL4100 you need the original configuration by Michael Roland, as my version for the PR2100/PR4100 has some other parameters. First try to use screen to validate communication with the PMC. For a DLx100 it is

screen /dev/ttyS0

Type VER and STA a few times, it should show 0x6A or 0x6C.
Then get the wdhw tools somewhere in your home directory. Copy what you need to /usr/local/lib/wdhwd like the instructions are indicating.
I’d recommend to start with a sudoers file without shutdown rights (if you run as wdhwd user) or comment all shutdown calls in the daemon.

Thanks Tf1.
Followed your suggestions and output of screen on ttyS0 was VER=WD PMC v19 VER=WD PMC v19. So I copied over the files from MR DL2100 github. Followed his install file. On reboot my system fan and power light are correct.
I viewed my wdwhd log file and ]
2018-12-30 10:14:25,737 - main - ERROR - WdHwDaemon: Daemon failed with PMCCommandRejectedException: ; exiting
Also my LCD buttons are not working.

Thanks again for your help. :slight_smile:
Tony

If fan and power light are fine, it means the service works as intended.
I also get the failure on boot… seems like an initialization issue, I’ll create a github ticket for that.
Possibly resolved with pcm_test_mode=on in the config file.

To get LCD buttons working, checkout my fork but make the necessary changes in the config file.

Feel free to create tickets on github if you have other questions.

Here’s how I got it working.

I also hardened the wdhw tools install script a bit… please let me know if you still face issues.

Install the ‘wdnas-hwtools’.
Everything works well, but when you restart, the ‘wdhwd’ service does not start. You have to log in to the console and start it manually from ‘root’ or through ‘sudo’.
Tell me what to fix?
Thank!

Any message in /var/log/wdhwd/daemon.log?
And output of

journalctl -u wdhwd

Mystic!
Reinstalled Debian and ‘wdnas-hwtools’ - everything works.
Thank!

1 Like

Last year I installed Debian on My Cloud PR2100, but with both hard drives formatted.
Now I want to go back to My Cloud OS. I tried following How to reset a My Cloud PR2100 device but no luck. Any advises?

@fuweichin: Boot the PR2100 without hard drives. It should boot into OS3 (if you didn’t touch the emmc flash). When the web interface is available, hot plug the drives back in.
You can setup the drives again via the GUI (note that they have to be wiped).
Alternatively, get a new pair of drives.

This is why I install Debian to a USB My Passport SSD drive: you can keep all your data on the WD reds and boot whichever OS you need at the time.

Debian Buster with UEFI boot

This guide applies to WD My Cloud PR2100, PR4100, DL2100, DL4100.
I’m running Ubuntu 18.

Debian Installation in VM

Get the buster amd64 netinst iso from the official sources.
Get KVM

apt install qemu-kvm ovmf

Prepare work dir

mkdir isos && cd isos

Setup bios binary for UEFI support. See here for some more info.

cp /usr/share/ovmf/OVMF.fd bios.bin

Find your USB device, usually /dev/sdb or /dev/sdc. I’ll use /dev/sdX here.

lsblk
blkid

Now start a virtual machine with the buster ISO and your usb drive and 2GB of ram.

kvm -bios ./bios.bin -cdrom <buster.iso> -hda /dev/sdX -boot once=d -m 2G

It should boot with an image with “TianoCore”.

If you didn't see it, try this instead
kvm -L . -cdrom <buster.iso> -hda /dev/sdX -boot once=d -m 2G

Install Debian with the graphical installer.
My recommendation:

  • setup your location for closer mirrors
  • accept defaults for most of the other settings
  • deselect the Debian desktop environment
  • select SSH server and standard system utils

The virtual machine will boot from disk after the installation.

Prepare to run on WD NAS

Your drive now has Debian installed and it’s running as a virtual machine on your PC, but you need a few more fixes before plugging it in your NAS.

Some optional SSH tricks

To ssh into your qemu session, start the VM with these additional parameters

-net nic -net user,hostfwd=tcp::10022-:22

Source
Add this to your local ~/.ssh/config

Host qemu
    Hostname localhost
    User debian   # adapt this to the user you created during install
    Port 10022

Now simply setup your keys and then connect

ssh-copy-id qemu
ssh qemu
Root access (required for rest of the guide)
su

Alternatively, install the sudo package and add your user to the sudo group.

Setup Networking

Automatic

In the VM, create /etc/systemd/eth0.network

[Match]
Name=eth0

[Network]
DHCP=v4
Static IP

Create /etc/systemd/eth0.network

[Match]
Name=eth0

[Network]
Address=192.168.0.10/24
Gateway=192.168.0.1
DNS=8.8.8.8   # use a DNS server of your choice

Create a similar file for eth1.

Now create udev rules to pin ethernet interfaces to eth0 and eth1. Note the PCI addresses of your NICs first.

lspci -D | grep Ethernet
0000:01:00.0 Ethernet controller: Realtek Semiconductor Co., Ltd. RTL8111/8168/8411 PCI Express Gigabit Ethernet Controller (rev 15)
0000:02:00.0 Ethernet controller: Realtek Semiconductor Co., Ltd. RTL8111/8168/8411 PCI Express Gigabit Ethernet Controller (rev 15)

Now create a udev rule to set the interface names. Create /etc/udev/rules.d/60-persistent-net.rules

# add eth0
ACTION=="add", SUBSYSTEM=="net", KERNELS=="0000:01:00.0", NAME:="eth0"
# add eth1
ACTION=="add", SUBSYSTEM=="net", KERNELS=="0000:02:00.0", NAME:="eth1"

Source

Update network driver

Add the non-free repo to /etc/apt/sources.list (simply append non-free to the first line)

apt update
apt install firmware-realtek

Setup bootloader

You need to help the PRx100 bootloader to pick up this disk.
Add this to /etc/default/grub.

GRUB_CMDLINE_LINUX_DEFAULT="acpi_enforce_resources=lax console=ttyS0,115200n8 net.ifnames=0"

If you did create the udev rules for the ethernet interfaces, you may drop net.ifnames.
Run

grub-install --removable
update-grub

Shutdown the virtual machine and eject the USB drive.
Boot the NAS with the USB drive and ssh into your box.

Now install the kernel module for fan/lcd control.
Rename this attachment to 8250_lpss.ko and move it to /lib/modules/4.19.0.6-amd64/extra
8250_lpss.txt (420.2 KB)

depmod
modprobe 8250_lpss
dmesg | tail
Building the kernel module

First read this and you may need these extra steps.

Extra required packages to build kernel modules:

apt install bison flex libelf-dev libssl-dev

Also copy the System.map to your kbuild directory before using modules_install

cp /boot/System.map-$(uname -r) System.map

Enjoy.

1 Like

I finally figured out the odd issues with ethernet interface names.

debian@wdnas:~$ udevadm test-builtin net_id /sys/class/net/eth0
Load module index
Parsed configuration file /usr/lib/systemd/network/99-default.link
Created link configuration context.
Using default interface naming scheme 'v240'.
ID_NET_NAMING_SCHEME=v240
ID_NET_NAME_MAC=enx0014ee02bdff
ID_OUI_FROM_DATABASE=Western Digital Technologies, Inc.
ID_NET_NAME_ONBOARD=eno1
ID_NET_LABEL_ONBOARD=en Onboard LAN
ID_NET_NAME_PATH=enp1s0
debian@wdnas:~$ udevadm test-builtin net_id /sys/class/net/eth1
Load module index
Parsed configuration file /usr/lib/systemd/network/99-default.link
Created link configuration context.
Using default interface naming scheme 'v240'.
ID_NET_NAMING_SCHEME=v240
ID_NET_NAME_MAC=enx0014ee02be00
ID_OUI_FROM_DATABASE=Western Digital Technologies, Inc.
ID_NET_NAME_ONBOARD=eno1
ID_NET_LABEL_ONBOARD=en Onboard LAN
ID_NET_NAME_PATH=enp2s0
ID_NET_NAME_SLOT=ens1

You can see they both get eno1 as ID_NET_NAME_ONBOARD, which is why these interfaces become eno1 and rename0 by default.
The bug is documented here.
The proper fix would be to use a newer BIOS, but that’s probably not gonna happen.
Systemd name policy defaults to this:

[Link]
NamePolicy=kernel database onboard slot path
MACAddressPolicy=persistent

As the “onboard” policy is chosen, but the identical names cause a rename.
Solution: update /usr/lib/systemd/network/99-default.link to look like this

[Link]
NamePolicy=kernel path onboard
MACAddressPolicy=persistent

The ethernet interfaces will now default to enp1s0 and enp2s0.
You can still use the udev rules from previous post to rename them to eth0 and eth1 if you want to, but it’s no longer necessary.

An alternative is to go for biosdevnames… but that’s for another post.

1 Like