The Complete Netgear ReadyNAS 104 Arch Linux Install Guide

Install Arch Linux ARM on other devices.

The Complete Netgear ReadyNAS 104 Arch Linux Install Guide

Postby Abzie » Mon Mar 21, 2016 4:14 pm

Welcome!
I am posting this for archival reasons and hopefully someone somewhere can make us of this guide to go from ReadyNas OS to a complete Arch Linux install.

The aim of this guide is to convert from ReadyNAS OS to a self-contained Arch Linux install that boots from a /boot partition on the first drive.

Credits / Sources
http://natisbad.org for the kernel image and various commands
https://wiki.archlinux.org
Various man page websites

Table of Contents
00. Prerequisites
01. Prepare u-boot
02. Prepare HDD
03. Initial steps
04. First boot
05. Configure uboot
06. Finishing steps

00. Prerequisites
Backup, Backup, Backup! - This process is destructive to your data on sda and / or any X-RAID array (obviously)
Have atftpd installed on your pc/laptop, also run # mkdir /srv/atftp
4.4.1 Generic Bootable Kernel for RN104 move this to /srv/atftp as above
Latest armv7 rootfs
3.3v Serial UART usb cable (ebay/amazon £4)
Only connect 1 ethernet cable to the TOP port. If you have another, disconnect it, or swap it to the top port.
Know what your IP address is for your pc/laptop you will need this for passing the kernel and ramdisk later.

There are several ways you can achieve the end result.
  1. Swap in a HDD in pre-partitioned with the rootfs extracted on it
  2. Use a usb device to hold a temp archlinux rootfs to rsync to sda and also requires editing bootargs in u-boot

I will be using the 2nd method in this guide. If you use method 1, you can skip section 02, but refer to it for setting up your HDD.

Before proceeding, ensure you have connected the UART cable both to the serial port on the rn104 and a USB port on your pc/laptop and have a terminal session up ( screen /dev/ttyUSB0 115200 ). Turn the ReadyNas 104 off.

Follow steps 2, 3, 4c, 4d, 6, 7 and 9 from here: https://archlinuxarm.org/platforms/armv ... ll/mirabox but use sdX1 as the partition NOT sdX2 as that guide gives. We only need the rootfs on the usb drive as the kernel is loaded from uboot.

01. Prepare u-boot
Power on your rn104 and you will see the output of u-boot. Press any key to halt the boot process.
You should now see the following, if not power off the device again and try again.
Code: Select all
Marvell >>

Now type the following:
Code: Select all
dhcp
setenv serverip xxx.xxx.xxx.xxx
tftpboot 1200000 uImage-4.4.1.rn104
printenv bootargs
printenv bootcmd
**copy and paste the outputs of both into the next relevant commands:
setenv bootargs_orig " XXXXXXXXXXX "
setevn bootcmd_orig " XXXXXXXXXXX "
setenv bootargs console=ttyS0,115200 earlyprintk root=/dev/sde1
saveenv
bootm $load_addr


What these steps do are:
  1. dhcp - establishes link with router or networking device and assigns an IP.
  2. setenv serverip - changes the uboot environment server parameter to your laptop/pc where it will fetch files
  3. ftfpboot - loads the specified image at the ram address
  4. setenv bootargs - what boot parameters are passed to the kernel on boot
  5. saveenv - saves the current uboot environment. It only saves some commands, others are always defaulted on reset
  6. bootm $load_addr - commands uboot to boot from memory at the specified address. We use $load_addr for user's ease.

Note /dev/sde1 should be your usb device. You may have to watch the kernel output on boot to see what it's mapped to if it throws a no root device kernel error.

If all goes well, you should see a login prompt on the terminal. Go ahead and login as root, password is root.

Let's do a sanity check before we do anything destructive:
Code: Select all
# cat /etc/arch-release


It shouldn't return any text, but if it throws a File not found error, you're not in arch! Go through the steps above again and check spellings or commands

02. Prepare HDD
Enter the following commands. Some commands are just to check your config and may need to be adjusted. Don't panic if errors are thrown, the process is simple.
Code: Select all
# ls /dev/sd*
# umount /dev/sda*


You can either divide your /sys /proc /usr partitions or KISS with /boot / and swap as I did:
Code: Select all
# fdisk /dev/sda
n
p
1
(press enter to accept default start sector)
+250M
(press enter to accept default partition type [Linux]
n
p
2
(press enter to accept default start sector)
**calculate 1.5gb less from max capacty enter here**
(press enter to accept default end sector)
n
p
3
(press enter twice to accept default start/end sectors)
t
82
w


Now format the partitions. We have to use ext2 for /boot as uboot only supports ext2load on the rn104.
Code: Select all
# mkfs.ext2 /dev/sda1
# mkfs.ext4 /dev/sda2
# mkswap /dev/sda3


And mount them:
Code: Select all
# mkdir -p /mnt/{boot,root}
# mount /dev/sda1 /mnt/boot
# mount /dev/sda2 /mnt/root
# swapon /dev/sda3


Copy over the rootfs from the usb to root mount and some housekeeping:
Code: Select all
# rsync -av / /mnt/root --exclude 'mnt'
# cp -R /mnt/root/boot/* /mnt/boot
# rm -R /mnt/root/boot
# nano /mnt/root/etc/fstab


Remove the existing line in fstab and add:
Code: Select all
/dev/sda1 /boot ext4 defaults 0 1
/dev/sda2 / ext4 noatime,errors=remount-ro 0 0
/dev/sda3 none swap sw 0 2


Ctrl-o and ctrl-x to save

Once complete, reboot and stop uboot from autobooting
Code: Select all
# reboot
press any key to stop uboot
Marvell >>


Unplug the usb device.

03. Initial Steps
Now change bootargs from /dev/sde1 to /dev/sda2 and load the kernel again:
Code: Select all
dhcp
serverip xxx.xxx.xxx.xxx
setenv bootargs console=ttyS0,115200 earlyprintk root=/dev/sda2
saveenv
tftpboot 1200000 uImage-4.4.1.rn104
bootm $load_addr


Fingers crossed you are now at a login prompt again. Log in as root again with password root. Don't be tempted to go off and experiment, we still have an initramfs to make! If you lose power now or reboot or whatever, you will have to repeat the commands above every time the device power cycles.

04. First boot
Now you're logged in under root, lets do some housekeeping:
Code: Select all
# passwd
# pacman -Syu
# pacman -S uboot-tools sudo
# useradd  -m -g users -p password -s /bin/bash username
# userdel -r alarm
# visudo


Here, we change root password, full system update, install essential utilities we need, create a new user and remove the default alarm user finally adding the new user to visudo, if you don't like vi, and want to use nano, type the following before the visudo command:
Code: Select all
# export EDITOR=/usr/bin/nano


Now let's make uboot compatible ramdisk, add the following to MODULES="" line in /etc/mkinitcpio.conf
Code: Select all
evdev ext4 g762 marvell_cesa mvneta


Continuing on:
Code: Select all
# mkinitcpio -k 4.5.0-2-ARCH -g initramfs
# mkimage -A arm -O linux -T ramdisk -C none -a 0x00000000 -e 0x00000000 -n "Arch Linux 4.5.0-2-ARCH RD" -d initramfs uInitramfs


Once complete, reboot the nas and halt uboot.

05. Configure uboot
The finish line is in sight!
Code: Select all
setenv bootcmd_dtb "scsi reset; scsi scan; ext2load scsi 0:1 0x1100000 dtbs/armada-370-netgear-rn104.dtb"
setenv bootcmd_krfs "run bootcmd_dtb; ext2load scsi 0:1 0x1200000 zImage; ext2load scsi 0:1 0x2000000 uInitramfs"
setenv bootcmd "run bootcmd_krfs; bootz 0x1200000 0x2000000 0x1100000"
saveenv
boot


Here, we create 2 new environment variables so to not disrupt the default commands, should we need to revert later. _dtb initiates the hdd and loads the device tree. _krfs initiates the dtb command, loads the zImage and uInitramfs we created earlier. We set the boot command to run _krfs (and thus _dtb before that) then load all files from their addresses.

Originally, I had to make uboot kernel and initramfs compatible images, copy them to a secondary pc, tftpboot them across and flash the nand, potentially causing an issue with badblocks later on. Using this set of boot commands allows pacman to update the kernel with no further intervention for the end user in uboot and prolongs the life of the nand.

Now it's booting from the first SCSI device. Login with your user created above.

06. Finishing steps
The ReadyNAS 104 has a pwm compatible fan and can be configured to run with Fan Control.

Code: Select all
# pacman -S lm_sensors
# pwmconfig


Follow through the steps provided in the link above, this is my config:
Code: Select all
MINTEMP= hwmon1/pwm1=40
MAXTEMP= hwmon1/pwm1=75
MINSTART= hwmon1/pwm1=185
MINSTOP= hwmon1/pwm1=135


uboot doesn't pass on the MAC address to the kernel and has to be set in userland.

Code: Select all
# pacman -S macchanger


Then nano /etc/netctl/interfaces/eth0
Code: Select all
#!/usr/bin/env sh
/usr/bin/macchanger -r eth0 --mac=XX:XX:XX:XX:XX:XX


You only need to set eth0's MAC address if you only use 1 ethernet cable. This makes port-forwarding etc easier in the long run.

This is optional, but if you have 2 ethernet cables and want bonding:
Code: Select all
# rm /etc/systemd/network/*
# depmod -a
# modprobe bonding

as an addendum from the macchanger step above, bonding only uses the MAC address from the master (eth0) so you do not need to set eth1's MAC address. Then, follow instructions given in https://wiki.archlinux.org/index.php/Netctl#Bonding

Now you have a fully functioning base Arch Linux install which boots from the first drive. You can now follow General Recommendations from the wiki or purpose the rn104 to your needs.

In closing, I hope this helped you and I will update as best I can if there suggestions or improvements in the future.
Last edited by Abzie on Fri Mar 25, 2016 8:28 pm, edited 18 times in total.
Abzie
 
Posts: 29
Joined: Tue Mar 15, 2016 6:05 pm

Re: The Complete Netgear ReadyNAS 104 Arch Linux Install Gui

Postby Abzie » Tue Mar 22, 2016 4:30 pm

Updates
  1. 03/22/16 - Removed unnecessary steps and added proper uboot configuration to boot kernel and initramfs from scsi. General cleanup. Added fancontrol setup.
  2. 03/23/16 - Clarified the reasoning behind using ext2 for the boot partition. Removed defaults from fstab for root device and used noatime. Expanded on uboot commands. General cleanup.
  3. 03/25/16 - Moved sanity check to section 1. Added generic armv7 rootfs and removed some redundant steps.
Last edited by Abzie on Fri Mar 25, 2016 8:28 pm, edited 2 times in total.
Abzie
 
Posts: 29
Joined: Tue Mar 15, 2016 6:05 pm

Re: The Complete Netgear ReadyNAS 104 Arch Linux Install Gui

Postby moonman » Thu Mar 24, 2016 5:08 am

You should be able to boot with generic armv7 kernel (linux-armv7) as it does have the right dtb:
Code: Select all
ls /boot/dtbs/ | grep armada-370                 
armada-370-db.dtb
armada-370-dlink-dns327l.dtb
armada-370-mirabox.dtb
armada-370-netgear-rn102.dtb
armada-370-netgear-rn104.dtb
armada-370-rd.dtb
armada-370-seagate-nas-2bay.dtb
armada-370-seagate-nas-4bay.dtb
armada-370-seagate-personal-cloud-2bay.dtb
armada-370-seagate-personal-cloud.dtb
armada-370-smileplug.dtb
armada-370-synology-ds213j.dtb
Pogoplug V4 | GoFlex Home | Raspberry Pi B 512 | CuBox-i4 Pro | ClearFog | BeagleBone Black | Odroid U2 | Odroid C1 | Odroid XU4
-----------------------------------------------------------------------------------------------------------------------
[armv5] Updated U-Boot | |[armv5] How to install my.pogoplug.com service | [armv5] NAND Rescue System
moonman
Developer
 
Posts: 3089
Joined: Sat Jan 15, 2011 3:36 am
Location: Calgary, Canada

Re: The Complete Netgear ReadyNAS 104 Arch Linux Install Gui

Postby Abzie » Thu Mar 24, 2016 10:52 am

The guide does use the generic armv7l kernel and the correct dtb for the device.
Abzie
 
Posts: 29
Joined: Tue Mar 15, 2016 6:05 pm

Re: The Complete Netgear ReadyNAS 104 Arch Linux Install Gui

Postby moonman » Fri Mar 25, 2016 9:52 am

Abzie wrote:The guide does use the generic armv7l kernel and the correct dtb for the device.


I meant the generic multi-platform kernel that we have in the repos. The package is named "linux-armv7". In this guide you linked to a 3rd party kernel.

EDIT: Nevermind, I see you installed the kernel after. Why mirabox rootfs then?
Pogoplug V4 | GoFlex Home | Raspberry Pi B 512 | CuBox-i4 Pro | ClearFog | BeagleBone Black | Odroid U2 | Odroid C1 | Odroid XU4
-----------------------------------------------------------------------------------------------------------------------
[armv5] Updated U-Boot | |[armv5] How to install my.pogoplug.com service | [armv5] NAND Rescue System
moonman
Developer
 
Posts: 3089
Joined: Sat Jan 15, 2011 3:36 am
Location: Calgary, Canada

Re: The Complete Netgear ReadyNAS 104 Arch Linux Install Gui

Postby Abzie » Fri Mar 25, 2016 10:47 am

No particular reason, there isn't a generic armv7 build.
Abzie
 
Posts: 29
Joined: Tue Mar 15, 2016 6:05 pm

Re: The Complete Netgear ReadyNAS 104 Arch Linux Install Gui

Postby moonman » Fri Mar 25, 2016 7:43 pm

Abzie wrote:No particular reason, there isn't a generic armv7 build.

Code: Select all
http://archlinuxarm.org/os/ArchLinuxARM-armv7-latest.tar.gz
Pogoplug V4 | GoFlex Home | Raspberry Pi B 512 | CuBox-i4 Pro | ClearFog | BeagleBone Black | Odroid U2 | Odroid C1 | Odroid XU4
-----------------------------------------------------------------------------------------------------------------------
[armv5] Updated U-Boot | |[armv5] How to install my.pogoplug.com service | [armv5] NAND Rescue System
moonman
Developer
 
Posts: 3089
Joined: Sat Jan 15, 2011 3:36 am
Location: Calgary, Canada

Re: The Complete Netgear ReadyNAS 104 Arch Linux Install Gui

Postby Abzie » Fri Mar 25, 2016 8:30 pm

Many thanks, updated!

Can we get a generic page for other arm versions too, using the armv8 template?
Abzie
 
Posts: 29
Joined: Tue Mar 15, 2016 6:05 pm

Re: The Complete Netgear ReadyNAS 104 Arch Linux Install Gui

Postby moonman » Fri Mar 25, 2016 9:56 pm

All rootfs are available here:
Code: Select all
http://archlinuxarm.org/os/
Pogoplug V4 | GoFlex Home | Raspberry Pi B 512 | CuBox-i4 Pro | ClearFog | BeagleBone Black | Odroid U2 | Odroid C1 | Odroid XU4
-----------------------------------------------------------------------------------------------------------------------
[armv5] Updated U-Boot | |[armv5] How to install my.pogoplug.com service | [armv5] NAND Rescue System
moonman
Developer
 
Posts: 3089
Joined: Sat Jan 15, 2011 3:36 am
Location: Calgary, Canada


Return to [Please read announcement] Community-Supported Devices

Who is online

Users browsing this forum: No registered users and 4 guests