ReadyNasDUO-200 customisation guide

From NAS-Central Netgear Wiki
Jump to: navigation, search

In this guide I show how to install a debian to the Duo V2. Have Fun! --Jpt 12:22, 16 March 2013 (UTC)

For further technical details visit

He added a section on how to install kernel and debian. See --Jpt 08:10, 22 March 2013 (UTC)

Warning: I forgot to mention clearly you have to install and boot a initrd if you want to place your root filesystem into a RAID volume. This part is not yet included in the follwowing guide. See the Natisbad guide on how to install the initrd. -- Jpt 16:32, 13 May 2013 (UTC)

Added a section to overcome the initrd topic using Netgears Kernel providing /root on RAID 1 -- detech 16:44, 19 May 2013 (UTC)

Natisbad says, he is done with the kernel, which means all relevant code has been integrated into recent kernel 3.11. He has got a complete guide on how to build the kernel yourself: --Jpt 13:02, 13 October 2013 (UTC)



I do not take any responsibility if you brick your device or lose your data. If you know what you are doing and you have got a serial connection the risk of bricking should be very low. The risk of data loss might be significantly higher: Backup all of your data before you start! My approach is to install to empty disks. Of course you may use the stock root partition for your custom debian not touching the data partition. (I am not sure if the debian installer is able to deal with the RAID volumes and I won't give directions on this.) -- Jpt 10:22, 16 March 2013 (UTC)

Stock Boot Process

In the NAND there are 5 partitions:

  • U-Boot binary
  • U-Boot env (boot config)
  • uImage (uncompressed kernel Linux- with U-Boot wrapper)
  • uInitrd (initrd with U-Boot wrapper)
  • JFFS image (RAIDiator?) containing the basic root file system
STEP 0 Load Bootstrap 
The first code that is executed is Bootstrap. I believe this is a Marvell binary. I do not know where it is stored. It's not in the NAND. Usually you don't see anything from this code, except you boot into Bootstrap Debug Console (see below Boot while sending magic bytes), where you get the Message: "Bootrap 1.21 >>". I wasn't able to find any docs on how to use this console.
STEP 1 Load U-Boot 
Bootstrap boots U-Boot. If the system was powered off for a long time, the boot manager goes to standby mode instead of booting. If you press the power button or send Wake on LAN then it boots (again) and presents a count-down of 3 seconds (interupt with any key from the serial console).
STEP 2 Load Kernel and Initrd 
After the count-down ran out it loads kernel and initrd from ROM and starts them.
STEP 3 Initrd setup 
The initrd does a rather complex init job, where I am not sure about any detail. If there is no harddrive it stops. You may now login through telnet using the "tech support mode" password from V2DefaultPasswords. It mounts the root partition if available. If not it creates the system partitions (root and swap) then installs a new root from the JFFS image. This means it will DELETE ALL DATA (all partitions) from your drive without asking!
STEP 4 Mount root fs 
It replaces the initrd root with the real root filesystem.
STEP 5 Partition drive 
First boot on plain disks: You have to create you data partitions using the web wizard.

What do I need?

Serial Console

Using the serial console we are able to access the system in any boot stage. You need it for STEP 1 (U-Boot) and when you have got problems with network access.

REMARK: It might be possible to install a custom linux without using the serial console. But this is difficult because you don't know what happens if it does not work. Recovering from a wrong boot config would be nearly impossible.

Connecting to the serial port is really easy if you know how to do it.

  • Buy a cheap (Max232?) adapter from 3,3V serial to RS232 or USB
  • Attach according to SerialPort: GND, RxD, TxD, VCC where RxD and TxD must be connected to TxD and RxD (crossed) of course.
  • Open a terminal with port settings 115200,8,n,1 (on /dev/ttySx or /dev/ttyUSBx). I prefer GTKTerm.

If you recieve only garbage check your port settings.

Since there are no RTS/CTS wires we don't have hardware flow control. And I believe there is no software flow control (Xon/Xoff) either, since all chars sent to U-Boot while busy are lost when they exceed the (hardware) recieve buffer. So, cut&paste works only for single lines. Maybe Xon/Xoff is implemented in the linux kernel... but I didn't check.

REMARK: If you are using a USB serial adapter the device might disappear when the Duv V2 is off. I solved the problem by starting the console client directly after I switched on the Duo V2. (It takes only ~5 seconds until the autmatic boot process is started, so you have to be quick to press a key.)

Medium to load the Kernel from

You need a place where to load the kernel and initrd images from. You may for example use a USB thumb drive or a TFTP server.

Format the USB drive with ext2 or FAT.

For TFTP I use dnsmasq:

sudo dnsmasq -d --enable-tftp=eth0 --tftp-root=/path/

If you start it from the console, then it must run as root because you need access to the default TFTP port (UDP 69).


Get the kernel binary from

Building is really difficult. The old original kernel is heavily modified compared to the stock one. But the recent kernel versions already contain some of these patches. Well, for completeness find the Netgear GPL sources here:

Initrd Image

We use the install disk for an embedded system named Guruplug. Get it here: and place it on your boot medium.

If you have got your root partition on a RAID volume (or any other special config which requires additional modules), you need an initrd image for runtime as well. See for details.

Root Access to the Stock Linux

To make backup of the NAND partitions you should have root access to the linux already installed. Just install the root app:

Before start: Backup

Backup NAND Partitions

In Linux just dd all /dev/mtdblock? devices into files like this:

dd if=/dev/mtdblock0 of=mtd0

Keep in mind that these dumps usually contain garbage between the end of the actual binary and the end of the NAND partition. Eg. the mtd0 dump is 1,5 MiB in size, but the actual u-boot binary only is about 400 KiB. So for some of the trouble-shoot processes we have to strip the garbage in order to use the original images (see below).

Backup Your Data

Well. I won't give directions on how to back-up your data. If you don't know yourself maybe you should not use a NAS at all.

Let's go: Booting

The Duo V2 uses Das U-Boot. U-Boot is very flexible boot manager. When you are on the boot console you can load images from nearly everywhere (serial line, network, USB, disks etc). The problem is it does not know neither GUID Partition Table (GPT) nor ext3 or ext4 (RAID and LVM neither of course). This means U-Boot cannot load the kernel and initrd from the internal harddrive, which most likely are ext4 partitions (journaling!) on RAID on GPT (disks larger than 2 TB!). We have to store the kernel somewhere else: into ROM or USB drive. But let's start with initial boot.

To cancel automatic boot-up and get the boot console just press any (printable) key on the serial console. Have a look around, enter help to get the command list.

Loading from Network (TFTP)

Before booting, start the TFTP server.

dnsmasq -d --enable-tftp=eth0 --tftp-root=/path/

Now Enter the following commands. (!)Note: You have to enter set <name> <value> without equation sign but with a space between name and value (this is general U-Boot behaviour).

set serverip (IP adress)
tftpboot 0x1200000 /boot/kernel
tftpboot 0x2000000 /boot/initrd

Loading from USB thumb drive

Enter usb start to start the USB subsystem. The drive must be formatted as ext2 or FAT.

Use something like the following commands to load kernel and initrd:

usb start
ext2load usb 0:1 0x1200000 /boot/kernel
ext2load usb 0:1 0x2000000 /boot/initrd

Loading from (internal) SATA drive

Well, as mentioned earlier, U-Boot isn't able to read GPT or ext3/4. So you would have to partition and format your drive to use MBR and ext2 or FAT. Since it's not worth the effort, I'll skip this part. See the U-Boot manual for directions.

Booting the Kernel with initrd

After loading the images set the kernel parameters and boot the kernel:

set bootargs console=ttyS0,115200 
bootm 0x1200000 0x2000000

If your initrd is the debian install disk, then a installation wizard will be shown which guides you through the installation process. Ignore the messages regarding missing modules and debian being unable to install a boot manager. We don't need modules now and we already have a boot process.

Booting the Kernel on Custom Root File-System

Warning: If you've got your root partition on RAID you need a runtime initrd. Please see the natisbad guide on how to install this initrd.

When you sucessfully finished the installation, you may boot into your new system. Follows the steps above to load the kernel. You may skip loading the initrd. Now boot the kernel with these modified commands:

set bootargs console=ttyS0,115200 root=/dev/sda1
bootm 0x1200000

Change the root device to where you installed the debian root and omit the 0x2000000, so the initrd isn't loaded.

Finally Install the Kernel Permanently

If everything worked as expected we may make things permanent now. In theory this should be nothing more than writing the kernel to the third ROM area and modifying the U-Boot env.

Be careful, this may break your boot process! It's very important to check if the kernel was written correctly!

See also for how to write the kernel into ROM. For me it worked like this:

apt-get install mtd-utils
# Arnaud uses 0 for block count which failed, I tried 27 because this is what the nandwrite reported. Better not use more than 30, since this seems to be the sector count of mtd2.
flash_erase /dev/mtd2 0 27 
nandwrite -p /dev/mtd2 /boot/uImage

# read image back to disk and check if it's equal to our kernel file. If not you have to check your writing commands and write again. 
dd if=/dev/mtd2 of=/tmp/o bs=`wc -c /boot/uImage | cut -d' ' -f1` count=1
sha256sum /tmp/o /boot/uImage

I only installed the kernel, no initrd. I think you need the initrd if you have got RAID/LVM or other special configs.

To update the u-boot-env you either may use the u-boot console. Just edit using setenv <key> <value>, when finished issue saveenv. Or you can access the env from Linux:

Add /etc/fw_env.config:

# device    offset   size      Flash sector size   Number of sectors
/dev/mtd1   0x0      0x20000   0x20000             1


apt-get install u-boot-tools

Use fw_setenv <key> <value>. No need to apply an explicit save command.

No matter from which prompt, use the following as a guide on how to set the env. Do not use an equal sign (=). You may use single quotes to escape special chars like ";".

fw_printenv bootcmd
fw_setenv bootcmd.bak (result of above)
fw_setenv bootcmd 'nand read.e 0x1200000 0x200000 0x600000;bootm 0x1200000'
fw_printenv bootcmd.bak bootcmd
fw_printenv bootargs
fw_setenv bootargs.bak (result of above)
fw_setenv bootargs 'console=ttyS0,115200 root=/dev/sda3 raid=noautodetect mtdparts=nand_mtd:0x180000@0(u-boot),0x20000@0x180000(u-boot-env),0x600000@0x200000(uImage),0x1000000@0x800000(minirootfs),0x6800000@0x1800000(jffs2)'
fw_printenv bootargs.bak bootargs

Alternative Ways of Booting a Custom Root File-System TODO

OLD: This will boot the kernel, but the stock kernel is not able to load the root file-system. This is because it hasn't got a /dev/sda1 entry. The kernel is missing DEVTMPFS which would have created this device. So at the moment to boot a root file-system we need an initrd image. The stock initrd wants to boot the stock file-system, which is not what we want. My last attempt was to pass init=/bin/sh in bootargs (see above). This stops the default boot process after loading the initrd. Now we simply have to mount "our" root filesystem using pivot_root or switch_root. Until now, I failed with this step and I haven't got an idea how to continue.

Creating a Custom Root Filesystem using Multistrap TODO

  • have a debian based linux installation (Ubuntu for example)
  • install multistrap
    • sudo apt-get multistrap
  • have a multistrap.conf like this:
# delete the old tree before creating the new
# write into tarball

packages=apt-utils openssh-server ssl-cert 

Install Debian w/o changing NAND-Flash having /root on RAID1, w/o tftp Server

Another way freeing the ReadyNAS uses the following procedure, based on a "Factory default": we need to BACKUP all data already on the NAS. What do we get: a "free" Debian using the Netgear Kernel having no need to touch the NAND-Flash! This means: if you don't like your own Debian: do a "Factory-default" and come back to Netgear RAIDiator 5.3.xx Firmware.

Prepare the ReadyNAS Partitions

  • Select "Factory - default" from the ReadyNAS Duov2 Boot Menue (via Reset Button on the Back) according to your needs:
  • Select Mode from RAIDar Software: RAID 0/1 etc. Here: RAID 0 for Data Partition which gives RAID 1 for /root & /swap
  • Basically set up your System with the RAIDiator Web-IF
  • Install the root ssh access add-on via the Web-IF
  • Login to the ReadyNAS via ssh: user: root and pwd: =previously set admin-pwd in RAIDiator Web-IF.

To ease the copy operation i prefer the Midnight Comander:

apt-get update 
apt-get install mc

Copy ReadyNAS Kernel Modules and config

  • Connect an external Harddisk or USB Stick to the NAS which should be automounted from the standard Firmware (/USB/USB_HDD_1)
  • Copy at least /lib/modules/*
    • (i also copied /opt/ /etc /bin for further use, if necessary).

We are now prepared with the files needed for our own system Power down the NAS.

Prepare a Boot Media: USB Stick

  • Prepare a USB Stick to boot the ReadyNAS from.
    • Take care with the formatting: U-BOOT seems to only load from vfat partitions!
  • Use your PC to set up a USB Stick to boot the ReadyNAS from USB
    • downloading the Kernel from and
    • the initrd from the Guruplug, which fits to our ReadyNAS as described and linked above.
  • Copy both on a vfat formatted USB Stick
  • Use the USB 2.0 FRONT USB from our NAS.

Serial access as described above: minincom (e.g.) as Terminal to stop the boot procedure by pressing a key on the keyboard.

Let U-BOOT boot from USB Stick

  • Stop the Boot Process and let U-BOOT boot:
usb start; fatload usb 0:1 1200000 uImage; fatload usb 0:1 2000000 uInitrd 
set bootargs console=ttyS0,115200 earlyprintk, bootm 0x1200000 0x2000000

Install Debian with manual partitioning

  • taking over the Netgear Partitions which were in my case (2*2TB Drives)
Personalities : [linear] [raid0] [raid1] [raid10] [raid6] [raid5] [raid4] 
md2 : active raid0 sda3[0] sdb3[1]
      3897585664 blocks super 1.2 64k chunks
md1 : active raid1 sda2[0] sdb2[1]
      524276 blocks super 1.2 [2/2] [UU]
md0 : active raid1 sda1[0] sdb1[1]
      4193268 blocks super 1.2 [2/2] [UU]

Netgears original uses md0 and md1 directly, md2 via lvm. So we need to create a volume group using md2 and then a volume in this group during the manual partitioning process. I left /md0 as ext3 with formatting, /swap without change and my /vg0_data as ext4. After installing Debian we can safely reboot with the original Kernel & initrd in NAND, as we use them.

First Debian Boot: get Kernel Modules

  • During first boot the kernel reports missing modules (on our serial Terminal)
  • Connect the before prepared HD/Stick with the copied Kernel Modules again
  • Mount it were you like (automount is not yet active) and
  • copy at least /lib/modules/* from our backup.

With the next reboot you should see your system booting without errors and are free to install our preferred software.

Why not using the 3.8.3 Kernel?

  • Without Modules there were several issues having /root on RAID1, these can be solved:
    • Take a look at initrd preparation process with the second boot sequence: Setup the environment from the Debian installer initrd after having gone through the manual partioning process (without formatting) and leaving the installation process for a shell session:
# cd /; 
# mkdir tgt
# mkdir /tgt/share
# mount /dev/md0 /tgt  << the root file system
# mount /dev/mapper/vg0-data /tgt/share  << the file sharing LVM in this example
# cd tgt
# mount -o bind /proc /tgt/proc
# mount -o bind /dev /tgt/dev
# mount -o bind /dev/pts /tgt/dev/pts
# mount -o bind /sys /tgt/sys
# cd /
# chroot tgt /bin/bash
  • The Kernel did not mount NFS shares (may be a mistake?)
  • The NAND-Flash stays untouched and one keeps an easy way back to the nice RAIDiator FW!

Next step: move to a newer Kernel: TODO

Hopefully a recent kernel shall be made available soon, at the time beeing, stick to the old one.

Issues to be solved

  • The System does not cut power with poweroff command (to be checked with the original FW)
  • None yet

Other Config

Control Fan Speed TODO

Install smartmontools, fancontrol, lm-sensors packages.

Add /etc/sensors.d/readynas-duo-v2 to have labels for the sensor ports:

chip "g762-i2c-*-3e"
	label	fan1	"Fan"

chip "kirkwood_thermal-virtual-0"
	label 	temp1	"CPU"

Type sensors to read the sensors (and check the config).

Create /etc/fancontrol using pwmconfig. Mine looks like this:

DEVPATH=hwmon0=devices/platform/mv64xxx_i2c.0/i2c-0/0-003e hwmon1=
DEVNAME=hwmon0=g762 hwmon1=kirkwood_thermal
FCFANS= hwmon0/device/pwm1=hwmon0/device/fan1_input

See (in German)

Check if /etc/init.d/fancontrol exists. Use it to start fancontrol. On next bootup fancontrol should start automatically. If it doesn't you have to define the runlevels where fancontrol shall be started. Use something like sudo update-rc.d fancontrol defaults 99 01 (I haven't tried it, and don't know exactly what it does).

TODO Read harddrive temp through SMART and use for fan control.

Package hddtemp reads SMART values. But: 1) reading temp switches on the harddrive from standby?, 2) no way to integrate with fancontrol

Install Webmin - Web-Based System-Administration

Follow instructions:

At the time of writing, through the APT repo there is only a sarge (Debian 3.1) version available but this version works more or less on Squeeze (Debian 6.0) as well. I believe this is only cosmetic, ie. there is simply no other entry on the repo except sarge.

Make the POWER, BACKUP and RESET buttons work TODO

Hey, this one is easy. Get input-event-daemon, build and install.

The only doc is the included files and a thread in German:

Create a config file:

# Create file /etc/input-event-daemon.conf
listen = /dev/input/event0
POWER = shutdown -h -P -k +1
# Reset button at the back
RESTART = shutdown -r -k +1
# Backup button

Test with sudo input-event-daemon -D -v . When finished testing remove the "-k" parameters. They prevent actual execution of the shutdown/reboot.

Create an init-d start-script by copying the skeleton:

sudo cp /etc/init.d/skeleton /etc/init.d/input-event-daemon

Replace the vars with:

DESC="Button Listener"
#  NAME is not allowed to be longer than 15 chars

Make the script be executed at every boot:

chmod 744 /etc/init.d/input-event-daemon # set the file access rights to 744 (rwx--r--r)
/sbin/runlevel # find out your current runlevel (second digit) and create a link accordingly:
sudo ln -s ../init.d/input-event-daemon /etc/rc2.d/S18input-event-daemon

To increase security you may run the daemon under a separate user:

# add user and group (system?)
sudo addgroup --system input-daemon
sudo adduser --system input-daemon --ingroup input-daemon

# create file /etc/udev/rules.d/10-input-event-daemon.rules
# missing attributes. This way ANY input device will be readable by group input-daemon
SUBSYSTEM=="input", GROUP="input-daemon", MODE="0640"

# test with 
/sbin/udevadm test /dev/input/event0

# apply with 
/sbin/udevadm trigger -t devices  --subsystem-match=input -v

# check with 
ls -l /dev/input/*

# add to /etc/sudoers
# Cmnd alias specification
Cmnd_Alias SHUTDOWN = /sbin/shutdown, /sbin/halt, /sbin/reboot, /sbin/poweroff
# User privilege specification
# input-daemon is allowed to call all SHUTDOWN commands as root without entering a password.
input-daemon ALL=(root) NOPASSWD: SHUTDOWN

TODO run daemon as user input-daemon

Don't forget to add a sudo in front of the shutdown commands in /etc/input-event-daemon.conf if you aren't running as root.

Samba crashes when uploading files from windows TODO

Maybe a solution: ???

Trouble Shooting

Get u-boot, kernel and initrd images

To fix the boot process we might need working images of u-boot, kernel and initrd. You can either download them from Netgear or create them yourself from the mtd-images we dumped earlier.

Create from mtd TODO

Download from Netgear TODO

Boot while pressing Backup TODO

This is the most easy and most likely successful way of emergency boot.

You have to press the BACKUP button while switching on. This bypasses the u-boot-env and boots to a default boot config.

This boot config loads the following files from first USB drive, boots and flashes them:

uboot.bin (optional)
The U-Boot binary having u-boot NAND header and 4 byte CRC at the end.
Linux kernel having u-boot header
Linux initrd which flashes all the images and installs RAIDiator.
latest RAIDiator (optional)
This is the content of the last NAND partition, the JFFS2 filesystem or the RAIDiator download from the netgear website. Do not forget to unzip the file!

This boot does not change your u-boot-env. So if your env is broken, you have to fix it manually from either the u-boot-prompt or the linux prompt.

If you do not have access to the serial console, you have to wait until the system powers off. Next boot should work.

Boot while pressing Reset TODO

TODO: Describe where the boot menu is implemented which you can access from the front buttons.

Boot while sending magic bytes through serial line TODO