[GUIDE] How to Install Debian Linux on the My Cloud PR4100 NAS


#36

Thanks a lot!


#37

Thank you so much for sharing this! I bought a PR4100 because of your post.

I’m super impressed at how you figured all of this out. I’ve been trying to replicate your results with Ubuntu for the last few hours and failing.

Has anyone done this with Ubuntu? It’s not a big deal but I have a slight preference for it over Debian because it comes with ZFS binaries.

BTW I installed a SSD in the first bay for boot using this 2.5" drive adapter: https://www.amazon.com/gp/product/B00H91BXJU/ref=oh_aui_detailpage_o01_s00?ie=UTF8&psc=1


#38

You didn’t say where it fails… what have you done so far?
Preseed config should be the same, so what is the output of

lspci -k -s 00:1e
ls -l /sys/class/tty/*/device/driver
sudo dmesg | grep tty

I’m using zfs on debian with the kernel headers as above and then

apt-get install zfs-dkms zfsutils-linux

#39

I tried using http://archive.ubuntu.com/ubuntu/dists/bionic-updates/main/installer-amd64/current/images/netboot/mini.iso in place of …/debian-cd/current/amd64/iso-cd/debian-9.2.1-amd64-netinst.iso. SSH never came up and I don’t have a UART port cable to diagnose why.

I did install Debian successfully with ZFS, thank you. I found this guide to be helpful: https://unix.stackexchange.com/a/396160/48189


#40

From https://help.ubuntu.com/community/Installation/MinimalCD

mini system in UEFI mode
While the minimal iso image is handy, it isn’t useful for installing on UEFI-based systems that you want to run in UEFI mode. The mini iso lacks the proper files for booting the computer in UEFI mode. Thus, the computer will boot in BIOS compatibility mode, and the installation will be in BIOS mode.

I’d use the ubuntu server iso.


#41

It should be fairly simple to install Ubuntu Server, but the required steps would likey be different from the Debian installation outlined in the OP. The desktop version of Ubuntu won’t work because it’s generally not compiled/configured to run in headless mode without a monitor/keyboard.


#42

Thanks for your hints. Encouraged, I gave it another go with Ubuntu. I tried testing it first on another Linux machine I just acquired so I could see what I was doing.

Big mistake. I wasted hours and regret it. Ubuntu has TWO server installers. The default is http://releases.ubuntu.com/18.04.1/ubuntu-18.04.1-live-server-amd64.iso which doesn’t appear to work with preseeding but there’s no good documentation explaining that or why.

The other, http://cdimage.ubuntu.com/ubuntu/releases/18.04/release/ubuntu-18.04.1-server-amd64.iso, supposedly does but fails with the error “Your installation CD-ROM couldn’t be mounted.” This is a bug that’s been known for years and requires manual intervention to pass.

Both images are available via HTTP only, no SSL! This is 2018! Shame on you, Ubuntu!

Conclusion: Ubuntu installers are a giant mess and I’m sticking with Debian.


#43

@dswv42 You may want to remove the nomodeset kernel parameter from the GRUB config.
This prevents the i915 intel video driver getting loaded, required for vaapi HW video transcoding.
Thanks reference

I removed it from /etc/default/grub default params and then did

# sudo update-grub
# sudo reboot
...
# ls -l /dev/dri/renderD128
# vainfo      
error: XDG_RUNTIME_DIR not set in the environment.
error: can't connect to X server!
libva info: VA-API version 0.39.4
libva info: va_getDriverName() returns 0
libva info: Trying to open /usr/lib/x86_64-linux-gnu/dri/i965_drv_video.so
libva info: Found init function __vaDriverInit_0_39
libva info: va_openDriver() returns 0
vainfo: VA-API version: 0.39 (libva 1.7.3)
vainfo: Driver version: Intel i965 driver for Intel(R) CherryView - 1.7.3
vainfo: Supported profile and entrypoints
      VAProfileMPEG2Simple            :	VAEntrypointVLD
      VAProfileMPEG2Simple            :	VAEntrypointEncSlice
      VAProfileMPEG2Main              :	VAEntrypointVLD
      VAProfileMPEG2Main              :	VAEntrypointEncSlice
      VAProfileH264ConstrainedBaseline:	VAEntrypointVLD
      VAProfileH264ConstrainedBaseline:	VAEntrypointEncSlice
      VAProfileH264Main               :	VAEntrypointVLD
      VAProfileH264Main               :	VAEntrypointEncSlice
      VAProfileH264High               :	VAEntrypointVLD
      VAProfileH264High               :	VAEntrypointEncSlice
      VAProfileH264MultiviewHigh      :	VAEntrypointVLD
      VAProfileH264MultiviewHigh      :	VAEntrypointEncSlice
      VAProfileH264StereoHigh         :	VAEntrypointVLD
      VAProfileH264StereoHigh         :	VAEntrypointEncSlice
      VAProfileVC1Simple              :	VAEntrypointVLD
      VAProfileVC1Main                :	VAEntrypointVLD
      VAProfileVC1Advanced            :	VAEntrypointVLD
      VAProfileNone                   :	VAEntrypointVideoProc
      VAProfileJPEGBaseline           :	VAEntrypointVLD
      VAProfileJPEGBaseline           :	VAEntrypointEncPicture
      VAProfileVP8Version0_3          :	VAEntrypointVLD
      VAProfileVP8Version0_3          :	VAEntrypointEncSlice
      VAProfileHEVCMain               :	VAEntrypointVLD

E.g. Emby media server can now use it

ps fax | grep vaapi
 2706 ?        Sl     0:15  \_ /opt/emby-server/bin/ffmpeg -hwaccel vaapi -hwaccel_output_format vaapi -vaapi_device /dev/dri/renderD128 -i file:/MM/Trailers/SomeMovie.mkv -threads 0 -map 0:0 -map 0:1 -map -0:s -codec:v:0 h264_vaapi -vf format=nv12|vaapi,hwupload,scale_vaapi=w=1280:h=692 -b:v 3680000 -maxrate 3680000 -bufsize 7360000 -profile:v 578 -level 41 -force_key_frames expr:if(isnan(prev_forced_t),eq(t,t),gte(t,prev_forced_t+3)) -copyts -vsync -1 -codec:a:0 libmp3lame -ac 2 -ab 320000 -f segment -max_delay 5000000 -avoid_negative_ts disabled -map_metadata -1 -map_chapters -1 -start_at_zero -segment_time 3 -individual_header_trailer 0 -segment_format mpegts -segment_list_type m3u8 -segment_start_number 0 -segment_list /var/lib/emby/transcoding-temp/74f5332ba1271fcece2c3cba79a6d129.m3u8 -y /var/lib/emby/transcoding-temp/74f5332ba1271fcece2c3cba79a6d129%d.ts

#44

Here’s how to get hardware control with much less effort / time by building an in-tree kernel module.

Install the 4.9 kernel, headers and source. At the moment this is a meta package for linux-image-4.9.0-8, or the 4.9.110-3 kernel. This may bump in the future

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

Verify that the current kernel is 4.9.0-8-amd64 with uname -r
If it isn’t, update the grub bootloader to select the correct menuentry by setting the grub default.

Prepare kernel build directory and extract the source

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

Get the module symvers from the headers. This file is generated when you build the full kernel, so we save a few hours by skipping this.

cp /usr/src/linux-headers-4.9.0-8-amd64/Module.symvers .

Get the corresponding kernel config

cp /boot/config-4.9.0-8-amd64 .config

Verify if the kernel source version matches the current version.

uname -r
make kernelversion

If these previous commands did not match, edit the first lines of the Makefile like this. (thanks @neversaydie)

SUBLEVEL = 0
EXTRAVERSION = -8-amd64

Enable the Intel LPSS UART driver in the kernel config.

Directly with an editor

Enable these 2 parameters in the .config in your favorite editor

CONFIG_SERIAL_8250_LPSS=m
CONFIG_DW_DMAC_PCI=m

Note that these parameters may change in future kernels.

or select it in the menu
sudo apt install libncurses5-dev
make nconfig

Enable support as a module.

   -> Device Drivers
     -> Character devices
       -> Serial drivers
        -> <M> Support for serial ports on Intel LPSS platforms. 

Save and exit.

Now compile the module

make prepare
make modules_prepare
make M=scripts/mod
make M=drivers/tty/serial

And install it

sudo make M=drivers/tty/serial modules_install
sudo depmod
sudo modprobe 8250_lpss

Verify it’s active

lsmod | grep 8250_lpss

This lighter module is easier to keep in sync with the mainline kernel.
All that’s left is to put all this in a post-install script.


#45

Openmediavault 4 (Arrakis) has finally been released for Debian 9 (Stretch), and after giving it a lot of thought, I’ve decided that this is probably the most viable option for the PR4100/PR2100 NAS boxes.

However, hardware control will need to be addressed, and this time I intend to do it properly. No more complicated instructions, just a downloadable ISO file that can be burned to USB for a full plug and play installation.

The only real caveat is the need for the OS to reside on one of the hard drives because eMMC memory is too small and it wears out quickly from too many write operations, but I have some ideas for that too.

This is going to take time… a lot of time.


#46

I’d suggest a 4GB image file with OMV already installed and just inflate the partitions on first boot.
Then the user only needs to update OMV to the latest version and change the password.
The image can be installed on a disk but I’d recommend to run it from a USB drive.


#47

I have something very similar in mind, but haven’t worked out the specifics yet. Currently, my main concern is PR4100 hardware identification so the Debian kernel can be configured/compiled to run with full hardware control. Linux distribution kernels tend to be rather bloated, so this will have the added benefit of keeping the kernel’s size and performance within reason.


#49

I have a new Linux kernel 4.9.127 packaged up for easy installation on Debian 9 (Stretch), with full PR4100 hardware support, if anyone wants to give it a try. I’ve tested it and everything seems to work fine, with only a few minor .config tweaks to iron out to make the kernel more efficient. The kernel source code was not modified prior to compilation, only the .config was changed to make it suitable to run on the PR4100 hardware.

Use at your own risk and only use on the PR4100/PR2100 with Debian 9 (Stretch).

Download from:

linux-headers-4.9.127_1.0.PRX_amd64.deb
linux-image-4.9.127_1.0.PRX_amd64.deb

Install it to Debian using:

sudo dpkg -i linux-headers-4.9.127_1.0.PRX_amd64.deb
sudo dpkg -i linux-image-4.9.127_1.0.PRX_amd64.deb

Reboot, then use uname -r to verify that the new Linux kernel 4.9.127 is running.

If you’d rather compile the Linux kernel yourself, simply download config-4.9.127.txt (95.4 KB) and save it to the /usr/src directory, then execute the following Linux commands as the root (or sudo) user. It may take several hours to compile, depending on many variables.

apt-get update && apt-get upgrade
apt-get install -y build-essential libncurses5-dev gcc libssl-dev libelf-dev u-boot-tools bc git

cd /usr/src
wget https://cdn.kernel.org/pub/linux/kernel/v4.x/linux-4.9.127.tar.gz
tar xvzf linux-4.9.127.tar.gz
cd linux-4.9.127
cp ../config-4.9.127.txt .config

make -j4 KDEB_PKGVERSION=1.0.PRX deb-pkg

dpkg -i ../linux-headers-4.9.127_1.0.PRX_amd64.deb
dpkg -i ../linux-image-4.9.127_1.0.PRX_amd64.deb

I’m developing a fully automated (plug and play) Debian/OMV install process, but I still need to work out a few kinks and test it for stability. And the best part is that the factory warranty (whatever it’s worth) should not be affected because no changes the firmware are made. The NAS is designed to boot from other media, so they can’t argue that it’s been altered.

BTW: The PR4100 is about to become so useful (without the crippled factory firmware) that I ordered a second one to use as a remote backup target.


#50

How to use sysvinit instead of systemd in Debian Stretch.

http://without-systemd.org/wiki/index.php/Debian_Stretch


#52

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

#53

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


#54

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/

#55

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…


#56

Indeed, it has full hardware support and should work fine. As mentioned previously, the configuration could use a few optimization tweaks, but nothing that is likely cause any problems. Again, use at your own risk.

Basically, my goal is to create a lean kernel that only includes drivers and configuration paramaters which are required by the actual hardware it’s intended for. The kernel I posted previously is close to achieving my goal, but all kernels (including mine) still require external programs to monitor the system temperature, control the fan, etc.


#57

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.