Install Debian on a NetGear ReadyNas Ultra II
I'm still alive! Today, I will show you how to free your dusting NetGear ReadyNas Ultra II. This model is a simple device designed for home use: it only has two bays and is meant for RAID1. As it dates back to 2011, the official firmware is no longer supported. It's time to get some real freedom :)
Who's this guide for?
This guide was made for people with a decent linux experience: once we erase the original system from the nas there will be no turning back, and the most difficult steps all come after this. If you don't know how to partition a disk without help, it's probably a very bad idea to attempt this.
Which tool to use?
For this task, we are going to use Open Media Vault. It's free, open-source, actively developped and unlike the original interface, good for your eyesight. In theory, Open Media Vault provides an iso with a custom installer for you to easily install it on your computer. But you guessed it, for us things are not going to be that simple.
Why would we need a guide for that?
Open Media Vault only works under debian. Therefore, the iso they provide is actually an automated debian installer. However, it's not meant to be installed on something that exotic, and there are a lot of useful parameters you can't control (especially concerning the partition scheme to use). That's why we are going to install Debian first, and then configure Open Media Vault as a package.
First of all, make sure you have a usb to ttl converter to plug in the nas after removing the black sticker. RX and TX pins are in the center. You can use any serial terminal you like (I use Minicom but you can use putty).
The first step is obviously to get the latest debian iso.
But there's a trick. We are going to use the serial interface of the nas to go through the whole installation process, and by default the serial installer is disabled in debian's isos. We could rebuild an iso with the required parameters (and that's what a lot of people do), but another way easier path exists: using debian's official installer launcher.
This one can be configured to work with the serial interface, and will launch the iso directly! Start by extracting the archive to your usb key's partition table
su zcat boot.img.gz > /dev/sdX exit
Now, let's tell its bootloader to use the serial interface. First, mount your usb key.
sudo mount /dev/sdX /mnt
Replace the content of the syslinux.cfg file by the following lines
serial 0 9600 console 1 include menu.cfg default vesamenu.c32 prompt 0 timeout 0
Now, edit txt.cfg
label install menu label ^Install kernel linux append vga=normal initrd=initrd.gz --- quiet console=ttyS0,9600n8
And finally, copy your debian iso directly on the usb key
cp debian-9.3.0-amd64-netinst.iso /mnt/
You can unmount your usb key and plug it in one of the ports at behind the nas. Connect it to internet, plug your jumper wires on the two center pins of the serial interface and launch your serial terminal.
sudo umount /dev/sdX
Now, press and hold the backup button. Press and release the power button. Syslinux should appear after your nas' boot screen. Release the backup button.
Press the down arrow key to select the "install" option and press enter. If you kept the "Backup" button pressed for too long after syslinux started to appear, the cursor may not move. In that case, a command prompt will appear after you pressed a key. Don't panic and simply enter "install", it will boot as expected.
Once the installer has started, select the letter "C" above the "English" option. Another menu opens: choose your region (you can type its first letter to save time). Repeat this step for the country, and you're done with zone settings.
The installer will now try to detect an iso on available peripherals and load its content. However, unlike the OS itself, debian's installer is incredibly broken. This step may fail. In that case, continue and select "Load installer components fron an installer ISO". Here, try all the disks from the bottom of the list until the iso is detected.
If you are asked to choose the components to load, select everything except those, which are useless:
eject-udeb espeakup-deb sound-modules
If you are asked if you want to load drivers, select "No"
Wait for the network detection to finish and select the interface matching the port you plugged you ethernet cable in (it should default to the right one).
Now, enter some custom hostname, and enter "localdomain" as a domain name. Unless of course you are configuring a nas at school. Or at work. Don't do that. On the following screen, use your favourite password manager to enter a root password. Choose a username, just press enter on the next screen and enter a user passord.
The partitioner will now detect your disks and ask you how to proceed. We are going to erase everything and restart with a clean partition scheme. Select "Manual" and the partition used as swap. Make it unused and confirm.
Then, select "Configure Software RAID" and "Delete MD device". Delete them all, one by one (you have to select "Delete MD device" each time). Make the swap unused before you try to delete any raid, or it won't work!
Do the same for any LVM partition. Once all of this is done, we will partition the disks. Select the line starting with "SCSI1" and confirm. Do the same for "SCSI2".
We can finally partition the disks to our liking :) It should be pretty easy. Just make sure to create at least a swap partition of 2GB and a root partition of at least, say, 10GB. Don't create a boot partition here and make sure the partition scheme is identical on both your disks. Also, make all you newly created partitions unused: this is very important.
Once you are done, select "Configure Software RAID" again. Confirm the changes to write them. This time, choose "Create MD device". Choose RAID1, and confirm only 2 devices are to be used. Select 0 spare, and choose the first partiton of each of your disks with space. Confirm with enter. Repeat these steps for each of your partitions pairs.
Then you can select each of your raids and configure their mounting point. You should probably format all of them as well, it's just on option in the menu.
Last but not least, select the 125MB-ish partition. Use it as ext4, and mount it to /boot. Do not change these settings. The bootloader installation is incredibly unstable on debian's installer. Anything else could prevent your nas from booting. Also check if the bootable flag is set.
Now select "Finish" at the very bottom, and hold your breath.
Things here are pretty straightforward. When the installer asks you to choose a mirror, select one close to your location. When it asks you to select components to install, make sure nothing is selected except "SSH server" and "standard system utilities".
When Grub asks you if you want to install it on the MBR however, press escape. Choose "Continue without bootloader". When you are asked to finish the installation, press escape again. Start a shell and mount your system to /mnt like so :
mount /dev/md1 /mnt mount /dev/sdX1 /mnt/boot #this should be the 125MB boot partition mount -t proc /proc /mnt/proc mount -t sysfs /sys /mnt/sys mount -o bind /dev /mnt/dev
Now, chroot into /mnt
Become su to load environment variables
And install Grub by yourself
grub-install /dev/sdX #no partition number here update-grub
Then exit the shell
exit exit umount /mnt/boot umount /mnt/proc umount /mnt/sys umount /mnt/dev umount /mnt exit
Choose "Finish the installation"
Configuring your nas
Your device will reboot. Wait until the black screen turns into a linux welcome message. It can take some time (but not sonething like two minutes). If nothing happens though, you can insult debian's installer for being total garbage and try it again, being very careful to set the boot partition up exactly how I did. If you are desperate, try with LILO. It takes forever to boot, but works with default settings. This can only help you confirm Grub is the problem though: Open Media Vault will not work with LILO.
Otherwise, congratulations! Log in as a user, and set up sudo
su apt-get install sudo usermod -a -G sudo yourusername usermod -a -G ssh yourusername exit exit
You can of course disconnect your usb key if you didn't already. Log back in and configure apt to install Open Media Vault
sudo apt-get install software-properties-common sudo apt-get install apt-transport-https
deb http://packages.openmediavault.org/public arrakis main
Continue configuring apt
sudo apt-get update sudo apt-get --allow-unauthenticated install openmediavault-keyring sudo apt-get update
And install Open Media Vault
export LANG=C export DEBIAN_FRONTEND=noninteractive export APT_LISTCHANGES_FRONTEND=none sudo apt-get --yes --auto-remove --show-upgraded \ --allow-downgrades --allow-change-held-packages \ --no-install-recommends \ --option Dpkg::Options::="--force-confdef" \ --option DPkg::Options::="--force-confold" \ install postfix openmediavault
For the email settings chose "No Configuration". Initialize your brand-new nas system.
sudo omv-initsystem sudo apt-get install ssh sudo systemctl enable monit
Controlling the fan
As you probably noticed, the fan is insanely loud. Let's configure some packages to fix that.
sudo apt-get install lm-sensors sudo apt-get install fancontrol
What we first need to do is detecting the sensors af the nas. Answering yes every time you are asked something seems to be safe on NetGear's ReadyNas Ultra II.
Now load the required modules and reboot
sudo /etc/init.d/kmod start sudo shutdown -r now
It's time to make this fan a bit smarter. Type
Use the default answer every time. When you are asked to configure it, enter the following values :
1 (for the menu option) 1 (for the sensor to use) 40 (temperature to maintain) 60 (temperature requiring full-speed fan) 0 (etc, the configuration will be wrong anyway) 255 255 4 (save and exit)
Now, edit /etc/fancontrol to fix the mistakes. It should look exactly like this
INTERVAL=2 DEVPATH=hwmon0=devices/platform/coretemp.0 hwmon1=devices/platform/it87.2576 DEVNAME=hwmon0=coretemp hwmon1=it8721 FCTEMPS= hwmon1/pwm1=hwmon0/temp2_input FCFANS= hwmon1/pwm1=hwmon1/fan1_input MINTEMP= hwmon1/pwm1=40 MAXTEMP= hwmon1/pwm1=60 MINSTART= hwmon1/pwm1=255 MINSTOP= hwmon1/pwm1=80 MINPWM= hwmon1/pwm1=75 MAXPWM= hwmon1/pwm1=255
Great! Let's enable fancontrol
sudo crontab -e
Enter this line at the bottom of the file
sudo shutdown -r now
Log in and check nothing critical is happening
If the temperature is under 40 degrees, we're good.
coretemp-isa-0000 Adapter: ISA adapter Core 0: +37.0 C (crit = +100.0 C)
Otherwise, try changing the 80 into 90 in /etc/fancontrol, and even more if necessary, until the fan does not run at full speed.
Generate an ssh key on your computer
ssh-keygen -b 4096
Configure ssh to use that key for your nas (in ~/.ssh/config)
Host 192.168.0.XXX #the local ip of your nas IdentitiesOnly yes IdentityFile ~/.ssh/yourkey
And build a public key representation
ssh-keygen -e -f yourkey.pub
Open your web browser and enter the local ip adress of your nas. Log in with "admin" and "openmediavault". Please change this password immediately. Then, select your user and copy-paste the public key representation you generated.
Try disabling password authentication, you should still be able to ssh into your nas! You can now close that horrible 9600 bauds serial connection and continue configuring your nas.
We've done a lot together! You can now mount your raids in the dedicated section of Open Media Vault's interface, create a new shared folder on it and try connecting through nfs, for example. Have fun ;)