Debian Linux on the My Cloud PR4100 / PR2100

This guide will demonstrate how to install Debian (Stretch) on the My Cloud PR4100 NAS. No modifications to the NAS or its firmware are required. The installation process does not alter the factory firmware, and is fully reversible if reasonable precautions are taken.

WARNING: THE FOLLOWING PROCEDURES MAY VOID YOUR WARRANTY OR BRICK YOUR NAS - USE EXTREME CAUTION AT ALL TIMES

NOTE: BASIC LINUX SKILLS AND A SPARE HARD DRIVE ARE REQUIRED

The following guide is based on the WD My Cloud PR4100 NAS, but may be applicable to other WD My Cloud NAS models, possibly with minor variations applied as needed. It also assumes that the user knows how to obtain the NAS IP address and establish an SSH connection.

Compatibility:

Model: PR4100 / PR2100
Processor: Intel Pentium N3710 1.6GHz Quad Core
Archetecture: x86_64 (64 bit)
Distro: amd64

Required Tools:

Rufus (source): https://rufus.akeo.ie/
Mini Tool Partition Wizard: https://www.minitool.com/partition-manager/partition-wizard-home.html
PuTTY: https://www.chiark.greenend.org.uk/~sgtatham/putty/latest.html

Optional:

Required Download:

Debian 9 - Stretch (x86_64):
https://cdimage.debian.org/cdimage/archive/9.13.0/amd64/iso-cd/debian-9.13.0-amd64-netinst.iso

Caveats:

UPDATE: Hardware control has been achieved… Instructions coming soon.

Due to missing drivers, there is currently no control of the fan (runs full speed), reset button, front text display, or front LEDs. The blue HDD LEDs are controlled by the hardware and work as expected. USB access and hot-swap HDD functionality have not been tested. Otherwise, Debian runs without any noticable problems,

Debian does not install a web inerface to configure and/or manage the NAS, but many packages exist to provide this functionality. Webmin and Openmediavault are two popular options.

Installation Overview:

  1. Power off the NAS.
  2. Remove all hard drives from the NAS.
  3. Insert a blank hard drive (with no partitions) into the NAS.
  4. Prepare a bootable USB stick using Rufus.
  5. Replace the existing \boot\grub\grub.cfg file.
  6. Create a preseed.cfg file and copy it to \preseed.cfg on the USB stick.
  7. Remove the USB stick and insert it into the NAS.
  8. Power on the NAS. Installation time may vary from 30 to 60 minutes.
  9. When the NAS powers off, remove the USB stick and power it back on.
  10. Use SSH to connect with the NAS and login to verify that the installation was successful.

Installation Instructions:

Power off the NAS by briefly pressing the power button, then remove all hard drives and number each of them to indicate which HDD bay they originated from.

WARNING: Failure to remove all existing hard drives from the NAS may result in data loss.

Insert a blank hard drive (with no partitions) into the first HDD bay of the NAS. Any HDD bay may be used, but it’s easier to remember that the OS is stored on the hard drive in the first HDD bay. If necessary, the Mini Tool Partition Wizard (or similar tools) may be used to ensure that the hard drive is in fact blank. A blank hard drive is not strictly required, but it helps to avoid potential data loss and the complications of inserting a spare hard drive with a bootable partition, which can have unpredictable consequences.

Prepare a bootable USB stick using Rufus to load the Debian ISO file. The USB stick must be formatted as fat32 and it must be bootable. If using Rufus, load the Debian ISO file by clicking the little CD icon next to “Create a bootable disk using [FreeDOS]”. Afterwards, you should see “Create a bootable disk using [ISO Image]”. Other ISO to USB tools may work, but only Rufus has been fully tested.

After the ISO to USB process has finished, open \boot\grub\grub.cfg on the USB stick and replace its contents with the following parameters.

set default="0"
set timeout="5"

menuentry --hotkey=i 'Debian Preseed Install' {
    linux    /install.amd/vmlinuz debian-installer/locale=en_US keyboard-configuration/xkb-keymap=us preseed/file=/cdrom/preseed.cfg console=ttyS0,115200n8
    initrd   /install.amd/initrd.gz
}
submenu 'Advanced options ...' {
    menuentry --hotkey=e '... Expert install' {
        linux    /install.amd/vmlinuz priority=low console=ttyS0,115200n8
        initrd   /install.amd/initrd.gz
    }
    menuentry --hotkey=r '... Rescue mode' {
        linux    /install.amd/vmlinuz rescue/enable=true console=ttyS0,115200n8
        initrd   /install.amd/initrd.gz
    }
    menuentry --hotkey=a '... Automated install' {
        linux    /install.amd/vmlinuz auto=true priority=critical console=ttyS0,115200n8
        initrd   /install.amd/initrd.gz
    }
}

Create a preseed.cfg file using one of the following sets of parameters and copy it to \preseed.cfg on the root of the USB stick. The first set of parameters provides a fully automated (headless) install. The second set of parameters can be used to establish an SSH connection so that the rest of the install process can be completed manually. Only one set of parameters may be used.

Debian Preseeding (Stretch):

https://www.debian.org/releases/stretch/amd64/apb.html.en
https://www.debian.org/releases/stretch/amd64/apbs04.html.en

The usernames and passwords in the “Account Setup” section of the preseed.cfg file should be changed prior to installation. The default login for SSH is (username: debian / password: insecure). By default, the root user cannot connect to SSH and a standard user account must be used. If needed, the su command may be used to become the root user (password: r00tme).

### Preseed (Automated Install):

### Splash
d-i debian-installer/splash boolean false

### Localization
d-i debian-installer/locale string en_US

### Keyboard Selection
d-i keyboard-configuration/xkb-keymap select us

### Network Configuration
d-i netcfg/choose_interface select auto
d-i netcfg/get_hostname string unassigned-hostname
d-i netcfg/get_domain string unassigned-domain
d-i netcfg/wireless_wep string

### Hardware Detection
d-i ethdetect/prompt_missing_firmware boolean false
d-i hw-detect/load_firmware boolean true

###  Network Console (username is installer)
#d-i anna/choose_modules string network-console
#d-i network-console/password password r00tme
#d-i network-console/password-again password r00tme
#d-i network-console/authorized_keys_url string http://10.0.0.1/openssh-key

### Mirror Settings
d-i mirror/country string manual
d-i mirror/http/hostname string http.us.debian.org
d-i mirror/http/directory string /debian
d-i mirror/http/proxy string

###  Account Setup
d-i passwd/root-password password r00tme
d-i passwd/root-password-again password r00tme
d-i passwd/user-fullname string Debian User
d-i passwd/username string debian
d-i passwd/user-password password insecure
d-i passwd/user-password-again password insecure

### Clock and Time Zone
d-i clock-setup/utc boolean true
d-i time/zone string US/Eastern
d-i clock-setup/ntp boolean true

### Partitioning
d-i partman-efi/non_efi_system boolean true
d-i partman-auto/disk string /dev/sda
d-i partman-auto/method string regular
d-i partman-lvm/device_remove_lvm boolean true
d-i partman-md/device_remove_md boolean true
d-i partman-lvm/confirm boolean true
d-i partman-lvm/confirm_nooverwrite boolean true
d-i partman-auto/choose_recipe select atomic
d-i partman-partitioning/confirm_write_new_label boolean true
d-i partman/choose_partition select finish
d-i partman/confirm boolean true
d-i partman/confirm_nooverwrite boolean true
d-i partman-md/confirm boolean true
d-i partman-partitioning/confirm_write_new_label boolean true
d-i partman/choose_partition select finish
d-i partman/confirm boolean true
d-i partman/confirm_nooverwrite boolean true

### Apt Setup
d-i apt-setup/non-free boolean true
#d-i apt-setup/contrib boolean true
#d-i apt-setup/use_mirror boolean false
#d-i apt-setup/services-select multiselect security, updates
#d-i apt-setup/security_host string security.debian.org

### Package Selection
tasksel tasksel/first multiselect standard, web-server
d-i pkgsel/include string openssh-server build-essential
d-i pkgsel/upgrade select safe-upgrade
popularity-contest popularity-contest/participate boolean false

### Bootloader Installation
d-i grub-installer/only_debian boolean true
d-i grub-installer/with_other_os boolean false
d-i grub-installer/bootdev  string /dev/sda
d-i debian-installer/add-kernel-opts string nomodeset acpi_osi=Linux acpi_enforce_resources=lax console=ttyS0,115200n8

### Finish
d-i finish-install/reboot_in_progress note
d-i debian-installer/exit/poweroff boolean true

### Custom Commands
# This command is run just before the install finishes, but when there is
# still a usable /target directory. You can chroot to /target and use it
# directly, or use the apt-install and in-target commands to easily install
# packages and run commands in the target system.
#d-i preseed/late_command string LINUX COMMANDS GO HERE

The default login during the manual SSH install process is (username: installer / password: r00tme). Afterwards, the default login for SSH is (username: debian / password: insecure).

### Preseed (Manual SSH Install):

### Splash
d-i debian-installer/splash boolean false

### Localization
d-i debian-installer/locale string en_US

### Keyboard Selection
d-i keyboard-configuration/xkb-keymap select us

### Network Configuration
d-i netcfg/choose_interface select auto
d-i netcfg/get_hostname string unassigned-hostname
d-i netcfg/get_domain string unassigned-domain
d-i netcfg/wireless_wep string

### Hardware Detection
d-i ethdetect/prompt_missing_firmware boolean false
d-i hw-detect/load_firmware boolean true

###  Network Console (username is installer)
d-i anna/choose_modules string network-console
d-i network-console/password password r00tme
d-i network-console/password-again password r00tme
#d-i network-console/authorized_keys_url string http://10.0.0.1/openssh-key

Remove the USB stick and insert it into the NAS, then briefly press the power button to power on the NAS. At this point, the installation process will begin. Fully automated installation time may vary from 30 to 60 minutes. The manual SSH install process may take up to 5 minutes to provide an SSH connection.

If using the automated installation process, wait for the NAS to automatically power off, then remove the USB stick and power on the NAS by briefly pressing the power button.

WARNING: If using the automated installation process, EXTREME CAUTION must be taken not to leave the prepared USB stick inserted in the NAS (or computer) after the installation process is complete, or data loss may occur.

Afterwards, use SSH to connect with the NAS and login to verify that the installation was successful.

Installation Reversal:

To reverse the Debian installation process, simply power off the NAS by briefly pressing the power button, then remove the hard drive that Debian was installed on. Afterwards, replace the original hard drives and power on the NAS. The Debian installation process does not alter the WD factory firmware, which makes switching back and forth as easy as pushing a button and swapping hard drives… if desired.

4 Likes

Thanks for sharing!

EDIT November 2018 - hijacking this post to provide instructions for wdhw tools (fan_control and led etc…)

  • Install Debian 9 (stretch) with the instructions from the opening post.
  • Install a custom kernel, available here.
    Alternatively, just build the required 8250_lpss uart kernel module. See here.
  • Install the wdnas hwtools by Michael Roland. I made an installer for Debian stretch. Feel free to tune the scripts.

Original post

click me

When I find the time, I’ll share a guide with instructions to install debian to an external USB file.
It allows you to keep your disks seated and you keep access to your data.

  • It is highly recommended to use Debian 9 stretch… it has everything in the kernel and all package requirements for the wdhw tools.
  • Check if the braswell smbus drivers are loaded
# apt install setserial
# setserial -g /dev/ttyS2
/dev/ttyS2, UART: 16550A, Port: 0x0000, IRQ: 19
echo -ne 'FAN=25\r' > /dev/ttyS2       # this should turn off the fan
  • If that failed, use lm-sensors to detect the module and try again
# apt install lm-sensors
# sensors-detect                # and say yes to all

I got it to work under Debian 8 after a lot of fiddling:

  • update kernel to 3.17+
  • compile i2c-tools manually and install in /usr/lib… don’t use the apt package
  • use pip3 to install pyserial… don’t use the apt package
  • simplify the sudoers.d file until visudo agrees
  • some python3.4 backwards compat fixes:
    • socket.listen(0)
    • serial.is_open = serial.isOpen()
  • default SoC delta temperature monitor unknown value to return 2 (normal) instead of 7 (critical)

I believe OMV has a package or some guides to minimize OS disk writes by setting ramdisks in /etc/fstab. The whole squashfs concept on the WD emmc flash is also interesting.

I don’t like to spill a storage disk slot for the OS… and mdadm detects the raid config automatically, it’s quite easy to mount the RAID5 volume.

Hi @dswv42 Great work - thank you!! Just wondering if you’ve had an progress with being able to control the fan?

I tried in your other topic before I installed Debian (My Cloud PR4100 / PR2100 Firmware) and it worked - but now I’ve installed Debian, I get the -bash: echo: write error: Input/output error

Do you have any ideas?

Ahh makes sense! Which Linux kernel is this? Or how you would go about compiling it?

I’m still experimenting but this may get you started:

Note that you may need to install busybox from entware and need the /opt/bin/sh shell instead of /bin/sh to get support for calculations.

After a break of a few months I picked this up again.
The goal is to get fan control with the least effort possible.
Communication is done over the Intel Braswell SMBus device and the Intel Braswell HSUART controller bound to /dev/ttyS2

Debian Jessie (3.16+ kernel)

Out of the box, there is no support for the Braswell smbus/uart… the driver is unknown.

# apt install setserial
# setserial -g /dev/ttyS2
/dev/ttyS2, unknown Port: 0x0000 IRQ: 4

The PCI bus shows that no drivers are loaded.

$ lspci -k -s 00:1e
00:1e.0 DMA controller: Intel Corporation Atom/Celeron/Pentium Processor x5-E8000/J3xxx/N3xxx Series LPIO1 DMA Controller (rev 35)
    Subsystem: Intel Corporation Atom/Celeron/Pentium Processor x5-E8000/J3xxx/N3xxx Series LPIO1 DMA Controller        
00:1e.3 Communication controller: Intel Corporation Atom/Celeron/Pentium Processor x5-E8000/J3xxx/N3xxx Series LPIO1 HSUART Controller #1 (rev 35)
    Subsystem: Intel Corporation Atom/Celeron/Pentium Processor x5-E8000/J3xxx/N3xxx Series LPIO1 HSUART Controller
00:1e.4 Communication controller: Intel Corporation Atom/Celeron/Pentium Processor x5-E8000/J3xxx/N3xxx Series LPIO1 HSUART Controller #2 (rev 35)
    Subsystem: Intel Corporation Atom/Celeron/Pentium Processor x5-E8000/J3xxx/N3xxx Series LPIO1 HSUART Controller

$ lspci -k -s 00:1f
00:1f.3 SMBus: Intel Corporation Device 2292 (rev 35)

The smbus component is an I2C device, but there was no I2C devices detected on my Debian Jessie installation with kernel 3.16.

# ls /sys/bus/i2c/devices

Google for vendor 8086 and device id 2292 leads to this great site: Linux Kernel Driver DataBase: CONFIG_I2C_I801: Intel 82801 (ICH/PCH)

vendor: 8086 ("Intel Corporation"), device: 2292 ("Atom/Celeron/Pentium Processor x5-E8000/J3xxx/N3xxx SMBus Controller")
...
lkddb pci 8086 2292 .... .... ...... : CONFIG_I2C_I801 : drivers/i2c/busses/i2c-i801.c # in 3.17–3.19, 4.0–4.16, 4.17-rc+HEAD

The i2c driver called i2c_i801 only supports the SMBus controller with ID 2292 as of kernel 3.17 or 4.0+.
Support in the kernel was added with this patch: [4/4] i2c: i801: Add PCI ID for Intel Braswell - Patchwork

I compiled and installed the 3.18 mainline kernel on my PR4100 (with Debian 8) with these steps:

$ mkdir -p ~/kbuild && cd ~/kbuild
$ wget https://cdn.kernel.org/pub/linux/kernel/v3.x/linux-3.18.106.tar.xz
$ tar xf linux-3.18.106.tar.xz
$ cd linux-3.18.106

Note that you could also just patch the 3.16 kernel source (but then you need to add the 8250 uart support too).
Copy the config of the kernel you’re currently using.

$ cp /boot/config-3.16.0* .config

Build the kernel config

$ make olddefconfig

Ensure that the serial port module is enabled by setting SERIO_SERPORT in .config to yes or by adding serport to /etc/modules

Build the kernel

$ make -j 4 KDEB_PKGVERSION=1.0.TFL deb-pkg

or use this

$ fakeroot make-kpkg --initrd --revision=1.0.TFL kernel_image kernel_headers -j 4

Install it and reboot

# dpkg -i ../linux-image-3.18.106_1.0.TFL_amd64.deb
# reboot

Verify new kernel

$ uname -r

Normally it is sufficient to do

# insmod i2c_designware_pci i2c_i801
# insmod serport

Then I used lm-sensors and sensors-detect and finally I had this:

lsmod | grep i2c
i2c_algo_bit           12744  1 i915
i2c_i801               16965  0 
i2c_designware_pci     12611  0 
i2c_hid                17403  0 
hid                   102264  1 i2c_hid
i2c_designware_platform    12645  0 
i2c_designware_core    12813  2 i2c_designware_pci,i2c_designware_platform
i2c_core               50108  8 drm,i2c_designware_pci,i915,i2c_i801,i2c_hid,i2c_designware_platform,drm_kms_helper,i2c_algo_bit

Confirm that ttyS2 has a uart driver now

# setserial -g /dev/ttyS2
/dev/ttyS2, UART: 16550A, Port: 0x0000, IRQ: 19

Then the final test (I believe I had to run this command twice):

echo -ne 'FAN=25\r' | sudo tee /dev/ttyS2
echo -ne 'LN1=Cool Story Bro\r' | sudo tee /dev/ttyS2
echo -ne 'LN2=--------------\r' | sudo tee /dev/ttyS2

And finally the box fell silent.
Now setup the python2.7 branch of WD Hardware tools. Note that this is made for a DL2100, you’ll need some changes to make it work on a PRx100. Check the issues in the github repo.

Debian Stretch (4.9+ kernel)

Show the pci devices and the kernel modules they use.

lspci -k -s 00:1e

00:1e.0 DMA controller: Intel Corporation Atom/Celeron/Pentium Processor x5-E8000/J3xxx/N3xxx Series LPIO1 DMA Controller (rev 35)
    Subsystem: Intel Corporation Atom/Celeron/Pentium Processor x5-E8000/J3xxx/N3xxx Series LPIO1 DMA Controller        
00:1e.3 Communication controller: Intel Corporation Atom/Celeron/Pentium Processor x5-E8000/J3xxx/N3xxx Series LPIO1 HSUART Controller #1 (rev 35)
    Subsystem: Intel Corporation Atom/Celeron/Pentium Processor x5-E8000/J3xxx/N3xxx Series LPIO1 HSUART Controller
00:1e.4 Communication controller: Intel Corporation Atom/Celeron/Pentium Processor x5-E8000/J3xxx/N3xxx Series LPIO1 HSUART Controller #2 (rev 35)
    Subsystem: Intel Corporation Atom/Celeron/Pentium Processor x5-E8000/J3xxx/N3xxx Series LPIO1 HSUART Controller

lspci -k -s 00:1f

00:1f.0 ISA bridge: Intel Corporation Atom/Celeron/Pentium Processor x5-E8000/J3xxx/N3xxx Series PCU (rev 35)
    Subsystem: Intel Corporation Atom/Celeron/Pentium Processor x5-E8000/J3xxx/N3xxx Series PCU
    Kernel driver in use: lpc_ich
    Kernel modules: lpc_ich
00:1f.3 SMBus: Intel Corporation Atom/Celeron/Pentium Processor x5-E8000/J3xxx/N3xxx SMBus Controller (rev 35)
    Subsystem: Intel Corporation Atom/Celeron/Pentium Processor x5-E8000/J3xxx/N3xxx SMBus Controller
    Kernel driver in use: i801_smbus
    Kernel modules: i2c_i801

The SMBus device is detected and the i2c_i801 driver is loaded, but the UART device at 00:1e.3 does not have a driver yet.
A lookup of the vendor (8086) and device id (228a / 228c) leads to the 8250_lpss module. See Linux Kernel Driver DataBase: CONFIG_SERIAL_8250_LPSS: Support for serial ports on Intel LPSS platforms
They cleaned up the 8250 serial driver and the Intel Braswell code was moved out of the default serial module.
This driver is not included in the kernel, as can be seen in the kernel config at /boot/config-4.9.xxxx

# CONFIG_SERIAL_8250_LPSS is not set

Time to build our own kernel.
Get the 4.9 kernel (or get the current stable version, just drop the -4.9).

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

The source archive is now available in the /usr/src directory. Alternatively, you could’ve downloaded a source archive from http://www.kernel.org
Setup a working directory and unpack the source.

mkdir ~/kbuild && cd ~/kbuild
tar xf /usr/src/linux-source-4.9.tar.xz
cd linux-source-4.9

Use the current config as a basis.

make olddefconfig

Enable the CONFIG_SERIAL_8250_LPSS flag (and any other LPSS related flag) in the .config file.

editor .config
or use the menu based installer

Install ncurses and set it in Device Drivers - Character devices - Serial drivers.

make nconfig

Press F8 to search for LPSS, verify that it is enabled.

Now make the kernel debian package

make -j 4 KDEB_PKGVERSION=1.tflinux deb-pkg

This took 2 hours when building on the NAS. You may explore kernel-package to build faster.

Install the kernel (and the headers if you want to use virtualbox/zfs) and reboot

sudo dpkg -i ../linux-image-4.9.88_1.0.TFL_amd64.deb
sudo dpkg -i ../linux-headers-4.9.88_1.0.TFL_amd64.deb
sudo reboot

Check the kernel version

uname -a

Check support for the uart modules

lspci -k -s 00:1e

00:1e.0 DMA controller: Intel Corporation Atom/Celeron/Pentium Processor x5-E8000/J3xxx/N3xxx Series LPIO1 DMA Controller (rev 35)
    Subsystem: Intel Corporation Atom/Celeron/Pentium Processor x5-E8000/J3xxx/N3xxx Series LPIO1 DMA Controller
    Kernel driver in use: dw_dmac_pci
00:1e.3 Communication controller: Intel Corporation Atom/Celeron/Pentium Processor x5-E8000/J3xxx/N3xxx Series LPIO1 HSUART Controller #1 (rev 35)
    Subsystem: Intel Corporation Atom/Celeron/Pentium Processor x5-E8000/J3xxx/N3xxx Series LPIO1 HSUART Controller
    Kernel driver in use: 8250_lpss
00:1e.4 Communication controller: Intel Corporation Atom/Celeron/Pentium Processor x5-E8000/J3xxx/N3xxx Series LPIO1 HSUART Controller #2 (rev 35)
    Subsystem: Intel Corporation Atom/Celeron/Pentium Processor x5-E8000/J3xxx/N3xxx Series LPIO1 HSUART Controller
    Kernel driver in use: 8250_lpss

Confirm uart support

sudo setserial -g /dev/ttyS*

/dev/ttyS0, UART: 16550A, Port: 0x03f8, IRQ: 4
/dev/ttyS1, UART: 16550A, Port: 0x0000, IRQ: 18
/dev/ttyS2, UART: 16550A, Port: 0x0000, IRQ: 19
/dev/ttyS3, UART: unknown, Port: 0x02e8, IRQ: 3

However, the default baud rate is not correct yet…
I’m now using these commands, but this should be done with /etc/serial.conf

sudo stty -F /dev/ttyS2 0:0:0cbd:0:3:1c:7f:15:4:0:0:0:11:13:1a:0:12:f:17:16:0:0:0:0:0:0:0:0:0:0:0:0:0:0:0:0
sudo setserial /dev/ttyS2 closing_wait 3000 
sudo setserial /dev/ttyS2 baud_base 4608000

And finally

echo -ne 'STA\r' | sudo tee /dev/ttyS2
echo -ne 'FAN=25\r' | sudo tee /dev/ttyS2
echo -ne 'LN1=Cool Story Bro\r' | sudo tee /dev/ttyS2
echo -ne 'LN2=--------------\r' | sudo tee /dev/ttyS2

Almost done…
Now setup the python3 version of the WD Hardware tools. This is a fork of the original project by Michael Roland, I’ve added the required changes for a PR4100, as discussed in the following 10 posts.

Hey There!
I am new here and found the guide through an online search.
i recently bought an WD PR2100 and for the my PR2100 its pretty bad to use one HDD slot just for a operation system.

i installed debian on an external usb 3 harddrive through a manual installation. (thanks for the Çľuide!)

within the installation progress i saw that the internal emmc is 4GB with several small partitions and a free space of 2.1gb.

would it be possible to make a complete backup of the internal 4GB emmc and afterwards installing debian directly on the emmc? 4GB should be enough

did anyone tried something like this before?

@Tfl
i tried your fan driver guide but i dont get throught it.
i took the debian 4.x part but already by “make olddefconfig” i have the problem that its not working, i am getting that there is no rule for creating olddefconfig. i installed “make” before and copied config-4.9.* to .config like in the description of the description before.

for the first step with the sensors i was not sure to just press enter all the time (sometimes yes, sometimes no is automaticly chosen and if i should save it in the end…

i gonna give it a try if i have more time for it

The make command looks in the current directory for a Makefile… but you’re probably not in the right directory.
I’ll clarify the kernel build setup in the instructions.

Installing debian to the emmc will void your warranty and remember that flash storage wears out quickly (like usb drives).
You can create a backup with dd. Some examples:

dd if=/dev/mmcblk0 of=full_emmc_image bs=1M
dd if=/dev/mmcblk0p1 of=bootpart bs=1M

To restore, just swap input and output. Use at own risk!

What do you mean with “it should be done with /etc/serial.conf”?

i found a autoserial.conf in /var/lib/setserial with

/dev/ttyS0 uart 16550A port 0x03f8 irq 4 baud_base 115200 spd_normal skip_test
/dev/ttyS1 uart 16550A port 0x0000 irq 18 baud_base 4915200 spd_normal
/dev/ttyS2 uart 16550A port 0x0000 irq 19 baud_base 4915200 spd_normal


compiling the kernel etc. was working probably and after the final 4 commands

the fan is turning down.

afterwards i installed WD Hardware tools and tried to set up the wdhwd.service and wdhwd.conf correctly but after installing the deamon and starting it followed by a reboot the fan is running on fullspeed…

could you maybe post your wdhwd.conf and wdhwd.service?

i dont know what i am doing wrong actually :frowning:

EDIT:
And while i was installing the kernel i got


sudo dpkg -i linux-image-4.9.110_1.tflinux_amd64.deb 
Vormals nicht ausgew�hltes Paket linux-image-4.9.110 wird gew�hlt.
(Lese Datenbank ... 59152 Dateien und Verzeichnisse sind derzeit installiert.)
Vorbereitung zum Entpacken von linux-image-4.9.110_1.tflinux_amd64.deb ...
Entpacken von linux-image-4.9.110 (1.tflinux) ...
linux-image-4.9.110 (1.tflinux) wird eingerichtet ...
update-initramfs: Generating /boot/initrd.img-4.9.110
W: Possible missing firmware /lib/firmware/rtl_nic/rtl8107e-2.fw for module r8169
W: Possible missing firmware /lib/firmware/rtl_nic/rtl8107e-1.fw for module r8169
W: Possible missing firmware /lib/firmware/rtl_nic/rtl8168h-2.fw for module r8169
W: Possible missing firmware /lib/firmware/rtl_nic/rtl8168h-1.fw for module r8169
W: Possible missing firmware /lib/firmware/rtl_nic/rtl8168g-3.fw for module r8169
W: Possible missing firmware /lib/firmware/rtl_nic/rtl8168g-2.fw for module r8169
W: Possible missing firmware /lib/firmware/rtl_nic/rtl8106e-2.fw for module r8169
W: Possible missing firmware /lib/firmware/rtl_nic/rtl8106e-1.fw for module r8169
W: Possible missing firmware /lib/firmware/rtl_nic/rtl8411-2.fw for module r8169
W: Possible missing firmware /lib/firmware/rtl_nic/rtl8411-1.fw for module r8169
W: Possible missing firmware /lib/firmware/rtl_nic/rtl8402-1.fw for module r8169
W: Possible missing firmware /lib/firmware/rtl_nic/rtl8168f-2.fw for module r8169
W: Possible missing firmware /lib/firmware/rtl_nic/rtl8168f-1.fw for module r8169
W: Possible missing firmware /lib/firmware/rtl_nic/rtl8105e-1.fw for module r8169
W: Possible missing firmware /lib/firmware/rtl_nic/rtl8168e-3.fw for module r8169
W: Possible missing firmware /lib/firmware/rtl_nic/rtl8168e-2.fw for module r8169
W: Possible missing firmware /lib/firmware/rtl_nic/rtl8168e-1.fw for module r8169
W: Possible missing firmware /lib/firmware/rtl_nic/rtl8168d-2.fw for module r8169
W: Possible missing firmware /lib/firmware/rtl_nic/rtl8168d-1.fw for module r8169
Generating grub configuration file ...
Found linux image: /boot/vmlinuz-4.9.110
Found initrd image: /boot/initrd.img-4.9.110
Found linux image: /boot/vmlinuz-4.9.0-6-amd64
Found initrd image: /boot/initrd.img-4.9.0-6-amd64
Adding boot menu entry for EFI firmware configuration
done

Thanks for the feedback. You are really close to get it working :slight_smile:
The rtl warnings can be resolved by installing the non-free realtek drivers

sudo apt-get install firmware-realtek

See here

I didn’t know about the autoserial config file yet, but it seems that would be the proper way to set the baud rate.
My file only had entries for ttyS0 so I use the manual config and your setup (with baud rate 4608000 for ttyS2).
The documentation about setserial is a bit scattered so I thought this was to be set in /etc/serial.

This is my /etc/wdhwd.conf

[wdhwd]

# Unprivileged user/group to drop privileges to
user=wdhwd
group=wdhwd

# PMC
pmc_port=/dev/ttyS2
pmc_test_mode=on

# Temperature monitoring
disk_drives=["/dev/sda", "/dev/sdb", "/dev/sdc", "/dev/sdd"]
# Memory sensor is measuring on other I2C address. TODO
memory_dimms_count=0

# Socket for interacting with the hardware controller daemon
socket_path=/run/wdhwd/hws.sock
#socket_max_clients=10

# Logging - use debug if necessary
log_file=/var/log/wdhwd/daemon.log
log_level=info

# Notification commands -- COMMENT these while debugging!
system_up_command=/usr/local/lib/wdhwd/scripts/system_up.sh
system_down_command=/usr/local/lib/wdhwd/scripts/system_down.sh
drive_presence_changed_command=/usr/local/lib/wdhwd/scripts/drive_presence_changed.sh
#drive_presence_changed_args=["{drive_bay}", "{drive_name}", "{state}"]
power_supply_changed_command=/usr/local/lib/wdhwd/scripts/power_supply_changed.sh
#power_supply_changed_args=["{socket}", "{state}"]
temperature_changed_command=/usr/local/lib/wdhwd/scripts/temperature_changed.sh
#temperature_changed_args=["{new_level}", "{old_level}"]

This is my /lib/systemd/system/wdhwd.service file

[Unit]
Description=WD Hardware Controller Daemon
#Wants=network-online.target
#After=network-online.target

[Service]
Type=simple
User=wdhwd
Group=wdhwd
SupplementaryGroups=i2c dialout
Environment=
WorkingDirectory=FILL_IN_INSTALL_PATH
StandardOutput=inherit

ExecStart=/usr/bin/python3 -m wdhwdaemon.daemon -q
ExecStartPre=/bin/mkdir -p /run/wdhwd
ExecStartPre=/bin/chown -R wdhwd /run/wdhwd
ExecStartPre=/bin/echo -ne 'LN1=Look hot\r' > /dev/ttyS2
ExecStartPre=/bin/echo -ne 'LN2=Stay cool\r' > /dev/ttyS2
PermissionsStartOnly=true

Restart=always
RestartPreventExitStatus=10 11
#ExecReload=/usr/bin/python3 -m wdhwdaemon.client -q reload
ExecStop=/usr/bin/python3 -m wdhwdaemon.client -q shutdown
KillMode=mixed

[Install]
WantedBy=multi-user.target

Make sure you have the wdhwd fixes of last week included (git pull). I didn’t test Michaels latest version though.
To debug the blocking parts, I added debug logging each time the cooling level increased here.
E.g. add this

print('%s has temperature %s, increases level to %s', monitor._log_name, monitor.temperature, monitor.level)

And run the daemon directly (drop the -q quiet argument) with the correct user (or as root)

sudo -u wdhwd python3 -m wdhwdaemon.daemon

Thanks for your reply!
i fixed the driver issue.

i found an /dev/ttyS0 entry in the file wdpmcprotocol.py

after setting up the right port and everything i get

Debian GNU/Linux 9 unassigned-hostname ttyS0

while booting.

The main Issue is now, that the system is now immediately shutting down directly after finishing the boot process with the error that the temperature is to high Oo
But i am able to boot with the old kernel

starting the daemon directly is giving me

root@unassigned-hostname:/usr/local/lib/wdhwd# sudo -u wdhwd python3 -m wdhwdaemon.daemon
2018-07-29 23:09:34,793 - __main__ - ERROR - WdHwDaemon: Failed to drop supplementary groups: 1 (Operation not permitted)
2018-07-29 23:09:34,794 - __main__ - ERROR - WdHwDaemon: Daemon failed with SerialException: [Errno 13] could not open port /dev/ttyS2: [Errno 13] Permission denied: '/dev/ttyS2'; exiting
Traceback (most recent call last):
  File "/usr/lib/python3/dist-packages/serial/serialposix.py", line 265, in open
    self.fd = os.open(self.portstr, os.O_RDWR | os.O_NOCTTY | os.O_NONBLOCK)
PermissionError: [Errno 13] Permission denied: '/dev/ttyS2'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/usr/lib/python3.5/runpy.py", line 193, in _run_module_as_main
    "__main__", mod_spec)
  File "/usr/lib/python3.5/runpy.py", line 85, in _run_code
    exec(code, run_globals)
  File "/usr/local/lib/wdhwd/wdhwdaemon/daemon.py", line 915, in <module>
    ret = d.main(sys.argv)
  File "/usr/local/lib/wdhwd/wdhwdaemon/daemon.py", line 800, in main
    pmc.connect(cfg.pmc_port)
  File "/usr/local/lib/wdhwd/wdhwlib/wdpmcprotocol.py", line 383, in connect
    stopbits = _PMC_UART_STOPBITS)
  File "/usr/lib/python3/dist-packages/serial/serialutil.py", line 236, in __init__
    self.open()
  File "/usr/lib/python3/dist-packages/serial/serialposix.py", line 268, in open
    raise SerialException(msg.errno, "could not open port {}: {}".format(self._port, msg))
serial.serialutil.SerialException: [Errno 13] could not open port /dev/ttyS2: [Errno 13] Permission denied: '/dev/ttyS2'
root@unassigned-hostname:/usr/local/lib/wdhwd# Connection to 192.168.0.112 closed by remote host.
Connection to 192.168.0.112 closed.

After reading the shutdown details in the python files, it should be because there is no access to the fan control.

Uncomment all scripts and uncomment these 3 shutdown calls while debugging - https://github.com/michaelroland/wdnas-dl2100-hwtools/blob/master/wdhwdaemon/daemon.py#L420-L440
Boot with the new kernel and find out which temperature monitor is causing trouble.

I added user wdhwd to the i2c and dialout group too.

my user “wdhwd” doesnt has access to /dev/ttyS2
i used the sudoers file from github

i think this is the issue

Myeah I did a distupgrade from debian 8 to 9 so my setup may not be exactly the same. The wdhwd user setup is not final yet, see the issue on github for this. These are the groups of my wdhwd user.

# sudo -u wdhwd groups
wdhwd dialout sudo
# check required access for /dev/ttyS2
ls -l /dev/ttyS2

:wink: this is what i am trying right now. i just need around 8 minutes to get an ssh access and i need to change the kernel everytime i put the service file back
thanks for your help - i will reply soon

I commented out all subprocess calls in daemon.py while debugging. Then gradually enable them again (when all sensors work properly). You don’t want to mess with switching kernels :slight_smile:
It’s annoying though that you can’t cleanly kill the daemon… I used CTRL-Z and some grep / kill cleanup a lot.

Ok, its not working - is still shutting down…

i gonne retry it tomorrow again

Okay. Maybe remove the systemd service file for now and make sure there are no reboot requests anymore.
First get it running manually and add the service file later… and remove the shutdown access from sudoers for now.

But how can i run it manually?
If i am booting without the wdhwd.service file

sudo -u wdhwd python3 -m wdhwdaemon.daemon
/usr/bin/python3: Error while finding module specification for 'wdhwdaemon.daemon' (ImportError: No module named 'wdhwdaemon')

in the file temperature.py i found the line

_CORETEMP_FILENAME_BASE = "/sys/class/hwmon/hwmon0/temp{0:d}_{1}"

in daemon.py its asking for the numbers d of CPUs the system has.
in our case this number would be 4 and with (0:4) there would be 5 CPUs

i checked my hwmon directory and for me the cpucore is in hwmon1 (not hwmon0) and the temp* files are from 2 to 5 (so first is temp2_input and so on)
so i changed hwmon0 to hwmon1 and temp(0:d) to temp(2:5)
(hwmon0 name is acpitz and in the folder there is temp1)
or should i leave it like before?

in the daemon.log i get

ERROR - WdHwDaemon: Daemon failed with PMCCommandRejectedException
ERROR - FanControllerImpl: Overheat condition requires immediate shutdown