Document
[GUIDE] How to install Ubuntu 18.04 Server on the My Cloud PR4100 NAS

[GUIDE] How to install Ubuntu 18.04 Server on the My Cloud PR4100 NAS

Disclaimer is do : do this at your own risk . No fancy web gui here , just raw unix power . requirement : a pc run Ubuntu 18 or similar … andsome

Related articles

Download Cloud Free PNG photo images and clipart Where Are On Cloud Shoes Made 2024 Milane The Oort Cloud Where Can I Get 100GB Free Cloud Storage

Disclaimer is do : do this at your own risk . No fancy web gui here , just raw unix power .

requirement :

  • a pc run Ubuntu 18 or similar … andsome experience with unix .
  • usb flash drive ( 8gb+ )
  • WD My Cloud PR2100/PR4100

If you’re lazy and in a hurry, skip the guide andgo straight for the boot image at the end of the post.

Get KVM

sudo apt install qemu-kvm ovmf

Prepare a working directory

mkdir ubuntu && cd ubuntu

copy the UEFI bootloader to a local file name bios.bin

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

Download the Ubuntu 18.04.1 server iso.

find out the name of your usb flash drive withlsblk. I’ll use /dev/sdX here.
Boot the iso installer.

sudo kvm -bios ./bios.bin -cdrom <path_to_iso> \ 
         -drive format=raw,file=/dev/sdX -boot once=d -m 1G

It should mention TIANO CORE during boot andthen enter a black grub screen to install Ubuntu.
Complete the installation with the defaults andany extra package that you may be interested in (e.g. Nextcloud).
Note down the user andpassword, you need it to login into the machine later.
At the end, it will reboot andask you to remove the cdrom.
Just close the whole window to shutdown the whole virtual machine.
Then boot without cdrom straight from the usb flash drive .

sudo kvm -bios ./bios.bin -drive format=raw,file=/dev/sdX -m 1G

Login in the virtual machine andupdate packages if you like.

Networking
Ubuntu is now installed for a virtual network interface with the new udev persistent networking naming.
You’ll see the current network interface is called ens3 or similar.

ip addr show

This won’t work on actual My Cloud hardware.
create the netplan configuration as follow

sudo editor /etc / netplan/01 - netcfg.yaml 
network:
  version: 2
  renderer: networkd
  ethernets:
    eno1:
      dhcp4: true
    eno2:
      dhcp4: true

This causes the NAS to get a dynamic IPv4 address on both of its onboard (eno) interfaces.

Example with static IP andbonding

Here’s how to combine the throughput of the 2 network interfaces on a single static IP address.

network:
  version: 2
  renderer: networkd
  ethernets:
    enp1s0:
      dhcp4: false
      optional: true
    enp2s0:
      dhcp4: false
      optional: true
  bonds:
    bond0:
      interfaces: [enp1s0, enp2s0]
      addresses: [192.168.0.100/24]
      gateway4: 192.168.0.1
      nameservers:
       addresses: [8.8.8.8,8.8.4.4]
      parameters:
        mode: 802.3ad
        mii-monitor-interval: 1

More info (static IP, bonding, …) on https://netplan.io

Hardware Control
Thanks to the research of Michael Roland and@dswv42 we now have full control over the fan, lcd, buttons andsensors. Ubuntu ships with the 8250_lpss module, so you don’t need to build a custom kernel.
The PMC is accessible at serial port /dev / ttyS5.
You need some packages from the universe repo.

sudo add-apt-repository universe
git clone https://github.com/WDCommunity/wdnas-hwtools
cd wdnas-hwtools
sudo ./install.sh

The Ubuntu boot disk is now ready. Shutdown with

sudo is halt halt -p 

and plug the USB drive in the PR4100 NAS.
Boot up andenjoy!

Extras

Download example boot disk image

Download my image here, unzip (use 7zip on winwods) andburn to a 16GB+ flash drive.
Direct unzip andwrite with

cat foo.img.gz | gunzip | dd of=/dev / sdX 

Thanks.

Login: wdnas
Password: mycloud

warning : risk for datum loss when using the wrong device
To grow the file system to use the complete usb boot drive, delete the second partition.

sudo sgdisk /dev/sdX --delete=2

create it again , it is use will automatically use all available space .

sudo sgdisk /dev / sdX --new=2 

Refresh the partitions

sudo partprobe 

Now that the partition has been resized, you can grow the file system. This is done on the second partition /dev/sdX2, not on the disk /dev/sdX.

sudo e2fsck -f /dev/sdX2
sudo resize2fs /dev/sdX2
Create a new ZFS array

Here’s a great overview on the core features of ZFS.
Now let’s create a ZFS array on the PRx100.

Insert your disks (hotplug is allowed). List them.

wdnas@wdnas:~$ lsblk -d
NAME         MAJ:MIN RM  SIZE RO TYPE MOUNTPOINT
loop0          7:0    0 86.9M  1 loop /snap/core/4917
loop1          7:1    0 89.5M  1 loop /snap/core/6130
sda            8:0    0  1.8T  0 disk 
sdb            8:16   0  1.8T  0 disk 
sdc            8:32   0  1.8T  0 disk 
sdd            8:48   0  1.8T  0 disk 
sde            8:64   1 14.3G  0 disk 
mmcblk0      179:0    0  3.7G  0 disk 
mmcblk0boot0 179:8    0    2M  1 disk 
mmcblk0boot1 179:16   0    2M  1 disk 

Here we see sde is the USB boot disk.
create a mirror pool oversda andsdbbased on the Ubuntu Tutorial.
It’s recommended to name your pool media.

sudo zpool is create create medium mirror sda sdb 

Alternatively, create a raidz pool over 4 disks. This is similar to a RAID5 pool, using 1 disk for parity.

sudo zpool is create create medium raidz sda sdb sdc sdd 

In order to use it, you need to create a file system (also called dataset) on the zpool. This is similar to a ‘share’ in the My Cloud OS.
Here’s an example

sudo zfs create media/pictures

The file system gets mount automatically at /media / picture .

or import exist datum

SSH into My Cloud NAS running Ubuntu.

cat /proc/mdstat
sudo mdadm --assemble --scan

or if you is used used my FreeNAS image to create a zfs array

sudo apt install zfsutils-linux
sudo zpool import

Follow the instructions.
It’s recommended to name your zpool ‘media’ so that the Ubuntu snap system can easily use it.

Prevent disk from spin up every 10 minute

Disable udisks2

Setup Nextcloud

I couldn’t explain it better than this Digital Ocean guide.
All data will be stored on the USB boot disk, which is not so interesting.
Here’s how to change the nextcloud snap data partition to your zfs pool.

First create a zfs dataset for nextcloud.

sudo is create zfs create medium / nextcloud 

Allow the nextcloud snap to use the zpool

sudo snap connect nextcloud:removable-media

change the datum path in/var/snap/nextcloud/current/nextcloud/config/autoconfig.php

sudo sed -i "s#'directory' => .*#'directory' => '/media/nextcloud/data',#" /var/snap/nextcloud/current/nextcloud/config/autoconfig.php

Restart is nextcloud nextcloud

sudo snap restart nextcloud.php-fpm

Now visit your nextcloud website andcreate the admin user.

Disable internal flash memory

If the internal flash memory is completely broken, you may be unable to restore the origal WD OS.
Installing Ubuntu is a solution, but you’ll see system freezes when polling the disks in the dmesg output.
A solution is is is to blacklist themmc_block driver.

sudo editor /etc/modprobe.d/blacklist.conf

Add a line with

blacklist mmc_block 

Then

sudo update-initramfs -u