Install Debian onto ZyXEL NAS326
as of June 13, 2020
Most/all of this is stolen from forum.doozan.com/read.php?2,32146 and https://forum.doozan.com/read.php?2,88619.
Download at Dropbox:
Debian-5.2.9-mvebu-tld-1-rootfs-bodhi.tar.bz2
1. Format a new USB drive with a single Ext3 partition, and label it rootfs. (assuming USB is /dev/sdd)
parted -s /dev/sdd rm 1
parted -s /dev/sdd mkpart primary ext3 "0% 100%"
mkfs.ext3 -L rootfs /dev/sdd1
2. Mount the drive on a Linux box. cd to top level directory and extract the rootfs. Assuming the USB drive is mounted at /media/sdd1
cd /media/sdd1
tar -xjf /where/you/stored/Debian-5.2.9-mvebu-tld-1-rootfs-bodhi.tar.bz2
3. Create uImage with DTB appended.
cd /media/sdd1/boot
cp -a zImage-5.2.9-mvebu-tld-1 zImage.fdt
cat dts/armada-380-zyxel-nas326.dtb >> zImage.fdt
mkimage -A arm -O linux -T kernel -C none -a 0x8000 -e 0x8000 -n Linux-5.2.9-mvebu-tld-1 -d zImage.fdt uImage
sync
sync
cd
umount /media/sdd1
(from https://forum.doozan.com/read.php?2,88619 , B2 Installation)
1. Use the Zyxel NAS326 instruction (came with the box) for logging as admin user through the web page of the box, set password, and Enable SSH.
Click "Control Panel"
"Terminal" (under Network section)
Click "Enable SSH Service"
Apply
2. Open a termimal and connect to the NAS326 with SSH, and login to the box as root user.
3. After logging in, get a listing of your current u-boot envs, and save it to a notepad in case you want to restore it later.
fw_printenv
4. Enter the following commands (copy/paste each line to the stock OS command line).
fw_setenv curr_bootfrom 1
fw_setenv next_bootfrom 1
fw_setenv bootcmd_custom 'run usb_bootcmd; reset'
fw_setenv change_boot_part 1
fw_setenv usb_set_bootargs 'setenv bootargs "console=ttyS0,115200 root=LABEL=rootfs rootdelay=2 $mtdparts earlyprintk=serial"'
fw_setenv usb_bootcmd 'echo Booting from USB ...; setenv fdt_skip_update yes; run usb_init; ext4load usb 0:1 $load_image_addr /boot/uImage ; ext4load usb 0:1 $load_dtb_addr /boot/dts/armada-380-zyxel-nas326.dtb ; ext4load usb 0:1 $load_initrd_addr /boot/uInitrd; run usb_set_bootargs; bootm $load_image_addr $load_initrd_addr'
Note that I've change "bootcmd_custom". It ONLY runs usb_bootcmd. The original version (from Doozan's site) would fail-over to OEM-OS if Debian failed to boot. This has caused [me] issues, this version will just retry Debian.
And then list the u-boot envs again, and save it to a notepad in case there is problem with booting and it needs to be referenced.
fw_printenv
5. Plug in the USB rootfs Debian-5.2.9-mvebu-tld-12-rootfs-bodhi.tar.bz2, and reboot
sync
sync
/sbin/reboot
7. After a period of time, the NAS326 will start rebooting. Wait for about 30 seconds and login through SSH.
ssh root@debian
password is "root" , change it!
passwd root
change hostname
echo "my-nas" > /etc/hostname
reboot
Update software
ssh root@my-nas
apt update
apt upgrade
apt install gdisk parted mdadm mutt exim4 acpid acpi-support
sync
Format drives
sync
lsblk
The disk drives are attached to Sata hence "ata-"
for a in /dev/disk/*/*ata-? ; do echo ${a} ; sgdisk -Z ${a} ; done
for a in /dev/disk/*/*ata-? ; do echo ${a} ; sgdisk -Z ${a} ; done
for a in /dev/disk/*/*ata-? ; do echo ${a} ; sgdisk -Z ${a} ; done
let dr=0 ; for a in /dev/disk/*/*ata-? ; do echo ${a} ; parted -s ${a} mklabel gpt mkpart NAS1boot_drive_${dr} ext4 "1 10G" mkpart NAS1swap_drive_${dr} linux-swap "10G 11G" mkpart NAS1data_drive_${dr} "11G -1" set 3 raid on ; let dr++ ; done
mdadm --create --verbose /dev/md0 --auto=yes --level=0 --raid-devices=2 /dev/disk/by-id/ata-*part3
mdadm -Es >> /etc/mdadm/mdadm.conf
mkfs.ext4 -L rootHD0 /dev/sda1
mkfs.ext4 -L rootHD1 /dev/sdb1
mkfs.ext4 -L NAS1data /dev/md0
mkswap -L NAS1swap0 /dev/sda2
mkswap -L NAS1swap1 /dev/sdb2
reboot
Copy "root" ("/") from USB to disk drive(s)
mkdir A1 B1
mount /dev/sda1 A1
mount /dev/sdb1 B1
rsync -avPx --exclude /lost+found / A1/
rsync -avPx --exclude /lost+found / A1/
rsync -avPx --exclude /lost+found / B1/
rsync -avPx --exclude /lost+found / B1/
umount A1 B1
rmdir A1 B1
fw_setenv usb_set_bootargs 'setenv bootargs "console=ttyS0,115200 root=LABEL=rootHD0 rootdelay=2 $mtdparts earlyprintk=serial"'
reboot
The system should start boot from USB, then finish boot & run off of /dev/sda1 as "/" .
Edit /etc/fstab and set root and add RAID0 to system. Add following line to /etc/fstab
LABEL=rootHD0 / ext4 noatime,errors=remount-ro 0 1
LABEL=NAS1data /data ext4 defaults 0 1
mkdir /data
mount -a
df -h
should show /dev/md0 mounted at /data with many(?) TeraBytes available!
reboot
and verify everything is mounted.
Red LED to show System Available (optional)
edit /etc/rc.local
#!/bin/sh -e## rc.local## This script is executed at the end of each multiuser runlevel.# Make sure that the script will "exit 0" on success or any other# value on error.## In order to enable or disable this script just change the execution# bits.## By default this script does nothing.
if [ -d /sys/class/leds/nsa326:red:sys ]; then echo default-on > /sys/class/leds/nsa326:red:sys/trigger echo none > /sys/class/leds/nsa326:white:sys/triggerfi
if [ -d /sys/class/leds/nsa326:white:sys ]; then# echo default-on > /sys/class/leds/nsa326:white:sys/trigger# echo none > /sys/class/leds/nsa326:red:sys/trigger echo ide-disk1 > /sys/class/leds/nsa326:white:sata1/trigger echo ide-disk2 > /sys/class/leds/nsa326:white:sata2/trigger echo usb-host > /sys/class/leds/nsa326:white:usb/triggerfi
Kernel update caveats
If the OS (kernel) is updated, it also needs to be updated on the USB stick BEFORE you reboot to disk again!
fw_printenv usb_set_bootargs
copy that somewhere
change root=LABEL=rootfs
reboot
update kernel to same version as disk
change root=LABEL=rootHD0
usb_set_bootargs should be back to what it was at beginning of this section
reboot