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.
$this->bbcode_list('1')
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.
$this->bbcode_second_pass_code('', 'Marvell >>')
Now type the following:
$this->bbcode_second_pass_code('', '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:
$this->bbcode_list('1')
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:
$this->bbcode_second_pass_code('', '# 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.
$this->bbcode_second_pass_code('', '# ls /dev/sd*
# umount /dev/sda*')
You can either divide your /sys /proc /usr partitions or KISS with /boot / and swap as I did:
$this->bbcode_second_pass_code('', '# 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.
$this->bbcode_second_pass_code('', '# mkfs.ext2 /dev/sda1
# mkfs.ext4 /dev/sda2
# mkswap /dev/sda3')
And mount them:
$this->bbcode_second_pass_code('', '# 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:
$this->bbcode_second_pass_code('', '# 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:
$this->bbcode_second_pass_code('', '/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
$this->bbcode_second_pass_code('', '# 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:
$this->bbcode_second_pass_code('', '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:
$this->bbcode_second_pass_code('', '# 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:
$this->bbcode_second_pass_code('', '# export EDITOR=/usr/bin/nano')
Now let's make uboot compatible ramdisk, add the following to MODULES="" line in /etc/mkinitcpio.conf
$this->bbcode_second_pass_code('', 'evdev ext4 g762 marvell_cesa mvneta')
Continuing on:
$this->bbcode_second_pass_code('', '# 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!
$this->bbcode_second_pass_code('', '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.
$this->bbcode_second_pass_code('', '# pacman -S lm_sensors
# pwmconfig')
Follow through the steps provided in the link above, this is my config:
$this->bbcode_second_pass_code('', '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.
$this->bbcode_second_pass_code('', '# pacman -S macchanger')
Then nano /etc/netctl/interfaces/eth0
$this->bbcode_second_pass_code('', '#!/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:
$this->bbcode_second_pass_code('', '# 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.