Project start: January 2020

WD Sentinel DX4000 NAS




The WD Sentinel DX4000 is a small 4-Bay NAS from 2011. It is supposed to run Windows Storage Server 2008 R2, at least this is what the license sticker says. However, the OS would be on the harddrives and those in my unit were empty. After endlessly searching how to do a successfull "recreate" of the storage with whitelisted harddrives and then a "recovery" to reset the Server to Factory Defaults, I gave up at the point I am supposed to wait 6 hours just to then take a look at the log file on the usb thumb drive to see that there was an error.
Luckily Martin Meise already looked into installing Linux on the Sentinel and posted about it on community.wd.com.

I followed the four videos he had online regarding:
So this will be a short summary how to install Debian on the WD Sentinel DX4000 and a bit beyond.

First open the case by unscrewing the fife screws on the back. I also took the opportunity to have look at the mainboard. Mine was desperately in need of a thermal paste exchange.
The CPU is a Intel Atom D525 with 2 cores running at 1.8 GHz. Installed are 2 GB of DDR3 RAM "PC3-10600 DDR3 1332MHz / 9-9-9-24 / Samsung M471B5773DH0-CH9".


Flipping the board back over you should see J23 Martin mentioned. The four smaller Pads are 3V, RX, TX and GND (from top to bottom in this picture) and connected to ttyS1.
Using a typical USB Serial TTL adapter you only need to solder some wires to these pads and connect RX to TX, TX to the adapters RX and GND to GND. I recommend using some linux computer with screen instead of Putty on windows (all symbols are displayed correctly and it was possible to enter the bios without attaching a USB keyboard to the Sentinel).
screen /dev/ttyUSB0 115200 opens a terminal with 115200 Baud. Plug in an ethernet connection to the port labeled 1. You also need the powersupply and the installation media.


I decided to put the system on a small SSD. The bays are not designed for 2.5" drives and I had to remove the upper spring. Now the SSD could fit but can fall out easily. To fix this I cut some wood pices to the dimensions of a 3.5" HDD and leave a space for the SSD.

Installing Debian



Next a USB thumb drive has to be created from which the OS will be installed.
Go to www.debian.org/distrib/index.en.html and download the "64-bit PC netinst iso". (At the time of this writing the current Version is Debian 10 Buster). To put the iso on the USB drive I went with Rufus, too. This means I had to use some Windows machine. There make shure to use GPT as partition scheme and copy mode ISO.
Because the mainboard has no easy way of plugging in a monitor we have to get everything out of the serial port. On the finished boot stick open boot/grub/grub.cfg. Above the first menuentryblock insert the following:

menuentry --hotkey=g 'Serial Console install' {
 set background_color=black
 linux /install.amd/vmlinuz vga=off --- console=ttyS1,115200n8
 initrd /install.amd/gtk/initrd.gz
}

You also need to add console to the terminal_output like this: terminal_output gfxterm console.
Now the stick is ready for the sentinel.

With the USB drive plugged into one of the two rear USB 3 ports and the SSD inserted press the power button.
After just a few seconds the Sentinel welcomes you with:

Version 2.13.1216. Copyright (C) 2011 American Megatrends, Inc.
BIOS Date: 10/18/2011 10:30:10 Ver: 0ABYK015
Press <DEL> or <F2> to enter setup.

Or something similar. Follow it's advice and you'll see the all so familiar blue BIOS menu.
The console output type can be changed under Advanced → Serial Port Console Redirection → Console Redirection Settings → Terminal Type. I followed Martins advice and chose VT-UTF8.
Next go to Boot and disable all other boot options than the SSD (or whatever device you want to install the OS on). Go to Save & Exit and hit Save Changes. Then scroll down to the "Boot Override" section and select the usb stick we just prepared. The unit should boot from the stick and give you the added "Serial Console Install" option.
Now follows a typical installation precedure where I won't go into detail. Setting the timezone is apparently not important. I choose to install the OS onto the ssd without encryption ("Guided - use entire disk") because the NAS will be used for offsite backup and should be able to reboot without my interaction. When it asks for the network interface: enp3s0 is the one labeled (1), enp4s0 is labeled (2).
At some point you can "Choose software to install". Make sure to deselect everything but ssh and standart system utilities. Select/Deselect with the Space Key. [Enter] to continue.

With the system rebootet login with your username (not root).
I quickly noticed sudo is not installed and certain programs are only accessible by adding /sbin/ in front of them. To fix this:

su -
Enter the root password
apt install sudo
usermod -aG sudo [username] (with [username] beeing your username)
reboot

We still are attached via the serial cable. ip a reveals the current ip address. Just ssh to it with your username and you can unplug the usb serial adapter, we shouldn't need it hereafter.
At this point you have a working Debian on the WD Sentinel and should be able to slide in some drives (in my setup only up to 3) and make it do stuff you want it to.

Front LCD

INITIALIZING OK
SEARCHING...

If the LCD at least would be off. Oh well, lets see how to control this sucker.
Looking around I found out that the display is using the Hitachi HD44780 LCD driver. lcdproc is able to control it so I downloaded and installed it:

sudo apt-get install libusb-dev libncurses-dev libxosd-dev build-essential
cd ~
wget http://sourceforge.net/projects/lcdproc/files/lcdproc/0.5.7/lcdproc-0.5.7.tar.gz
tar xzf lcdproc-0.5.7.tar.gz
cd lcdproc-0.5.7
./configure --prefix=/usr --sysconfdir=/etc --localstatedir=/var --enable-drivers=curses,hd44780,picolcd,xosd
make
sudo invoke-rc.d LCDd stop
server/LCDd -f -c LCDd.conf

A red window should open up, close with ^C. Next open LCDd.conf in the current directory and change the DriverPath to: DriverPath=/usr/lib/lcdproc/ and save.

sudo make install
sudo cp scripts/init-LCDd.debian /etc/init.d/LCDd
sudo cp scripts/init-lcdproc.debian /etc/init.d/lcdproc
sudo chmod +x /etc/init.d/LCDd /etc/init.d/lcdproc

After copying the start scripts we can adjust the config to fit the actual LCD. Open the config file at its new location /etc/LCDd.conf, sudo needed.
Search for Driver=curses and change it to Driver=hd44780.
Next navigate to the [hd44780] section. ConnectionType=winamp and Size=16x2 are the line to change.
Save and exit.

sudo invoke-rc.d LCDd start sudo update-rc.d LCDd defaults

Immediately after the start command the LCD should show something different.
Because I want to display something rather static I went back to the /etc/LCDd.conf and uncommented and changed the following settings:
 ServerScreen=off and Heartbeat=off

LCD ip and uptime

Now the LCD shows the standard LCDd "I'm waiting for a client" message. You could use LCDproc to have some flashy screens showing all sorts of stuff, but for this NAS I want something simple and usefull on there.
I found a simple perl script to show some text. Together with the lcdproc documentation I the nasinfo.pl script which does exactly what I wanted.
Tip: If you need to grab a coffee (or a new bottle club mate) do so after cpan Net::Address.. and answering "yes".

cd ~
wget https://figch.de/wdsentinel/nasinfo.pl
sudo chmod +x nasinfo.pl
sudo cpan Net::Address::IP::Local
yes
sudo cpan Unix::Uptime

This downloads the script from my webpage and makes it executable. I recomment taking a look inside the file you've downloaded before blindly executing it. The perl modules to get the ip address and uptime need to be installed via cpan.
To test if it works execute it by typing ./nasinfo.pl. The console stays empty, watch the LCD. Exit via ^C.

To make this execute automatically I used sudo crontab -e and added the line:

@reboot screen -dmS nasinfo bash -c '/home/[username]/nasinfo.pl;exec bash'

For this you need to have screen installed: sudo apt install screen.
sudo reboot and see if it pops up after a minute or so. If not you can open the screen to see if theres an error with sudo screen -r nasinfo.

Fan

Next up is the Fan in the back. On my machine it was quite noticable.
I followed the instructions on "how to control fan speed" on askubuntu.com.

sudo apt install lm-sensors fancontrol
sudo sensors-detect

Answer everything with "yes".

sudo service module-init-tools restart

Now, to have the fan slow down if the temperature is low we first need to find out which sensor value means what.
watch sensors shows all available sensor reading. Choose one of the temperatures and remember how many temperature sensors are above it or roughly the current temperature reading. To setup the fan control enter sudo pwmconfig and follow the instructions.
"Do you want to set up its configuration file now?". "y" for Yes. Leave path at default with [Enter].
Select the fan output. Mine was on hwmon1/pwm2.
Now the different temperature sensors are displayed with the measured temperatures but no description or names. If you remember the output from watch sensors you can estimate or count from the top, they should be in the same order.
Then follow the instructions to set minimum an maximum temperatures and pwm values. When finished "Save and Quit". You can change these values later by editing /etc/fancontrol or running pwmconfig again.

To update the fancontrol: sudo service fancontrol restart
Lastly use sudo service fancontrol start to put it into autostart.
For reference, heres my fancontrol config: fancontrol

I would als suggest installing hddtemp: sudo apt install hddtemp so you can see the hdd temperature with sudo hddtemp /dev/sdx


Thats it. Have a nice evening.