This was an inspiration for me to try installing Debian on this kind of device.
On the NAS central web page you can find a lot of usefull information about this NAS. I'm speaking of the following page: http://zyxel.nas-central.org/wiki/Category:NSA-310
If you are planning to install Debian on a NAS device, a good place to look at is the doozan forum.
This is my brief instruction, that I've extract from the doozan forum, to install Debian and OpenMediaVault to this NAS.
Warning! Updating your NAS following this instructions may brick your device. Everything you do at your own risk.
First of all a quick investigation on this device reports that the booting problems I encountered was caused by nand bad sectorson the kernel_1 mtd.
- install the u-boot
- install the rootfs - Debian system
- setup Debian: install OpenMediaVault
This is the dangerous part. Updating the mtd0 partition may brick your device.
In order to install Debian on this device, we have to load the kirkwood uboot.
You can download the latest version of the kirkwood uboot for NSA310 from this doozan forum page: https://forum.doozan.com/read.php?3,12381. The one I'm using is uboot.2017.07-tld-1.nsa310.bodhi.tar.
Also download the environemnt file, which is uboot.2016.05-tld-1.environment.bodhi.tar
Remember to check the MD5 value for those files with the one provided at the doozan forum. If they match untar that files.
To makes things simpler rename the uboot to uboot.kwb and environment file to uboot.img
For me that is done with the command:
mv uboot.2017.07-tld-1.nsa310.mtd0.kwb uboot.kwb
mv uboot.2016.05-tld-1.environment.img uboot.img
We are going to install the uboot on the mtd0 partition.
To check your partitions login to the ssh shell of your NSA and run the following command
cat /proc/mtd
The mtd partitions of your NSA310 should look like this:
dev: size erasesize name
mtd0: 00100000 00020000 "uboot"
mtd1: 00080000 00020000 "uboot_env"
mtd2: 00080000 00020000 "key_store"
mtd3: 00080000 00020000 "info"
mtd4: 00a00000 00020000 "etc"
mtd5: 00a00000 00020000 "kernel_1"
mtd6: 02fc0000 00020000 "rootfs1"
mtd7: 00a00000 00020000 "kernel_2"
mtd8: 02fc0000 00020000 "rootfs2"
You should backup your mtd0 partition, just in case.
To dump your partition download the uboot tools from this page https://forum.doozan.com/read.php?3,27280 extract it to a folder of your NAS, it may be a shared one, jump to that folder using your terminal, and run the following commad:
nanddump --noecc --omitoob -l 0x80000 -f mtd0 /dev/mtd0
It should have built the mtd0 file, which is your original mtd0 partition.
You should also save your actual env running:
fw_printenv > current_envs.txt
This time the current_envs.txt file is the environments variables content.
Now that you have dumped your actual configuration, before loading the new u-boot you MUST check that your device does not have bad sector on the mtd0 partion, running the command:
dmesg | grep -i 'bad'
We are going to use a usb key to load the uboot to your NAS.
FAT format a usb key. Copy the uboot.kwb and uboot.img files to your key.
Connect your NAS using an UART adapter. The baudrate you have to use it's 115200.
Boot your NAS up, you should see a message on your UART terminal asking to press any key to interrupt the boot process, so press that key.
You can check RX, TX, GND ground contacts on the picture above. Also note that I've added an heat sink on the main processor, it helps.
Now you are in the u-boot command terminal.
Plug the USB key and load the kernel to ram
fatload usb 0 0x0 0x800000 uboot.kwb
If it's all ok, you are ready to erase the nand for mtd0 partition
nand erase 0x0 0x1000000
then write then new uboot
nand write.e 0x800000 0x0 0x100000
Now load the usb uboot_env
fatload usb 0 0x0 0x800000 uboot.img
and write the uboot_env
nand write 0x800000 0xc0000 0x20000
Run printenv for test purpose
printenv
and save environement
saveenv
Cross your finger and reboot using command
reset
If it reboot you can now set environments. Once again press enter to jump in the uboot terminal.
Run the following command in order to properly set environment
setenv arcNumber 4022
setenv machid
setenv mtdparts 'mtdparts=orion_nand:0x100000(uboot),0x80000(uboot_env)'
then save environement
saveenv
and reboot
reset
2) install the rootfs - Debian system
Now you can install the Debian system. This is going to be simpler then the uboot installation.
Download the latest Debian kirkwood rootfs from this link: https://forum.doozan.com/read.php?2,12096
I'm running Debian-4.12.1-kirkwood-tld-1-rootfs-bodhi.tar.bz2
My choice is to run the Debian distribution on a 8Gb usb key, and use the NSA hard drive as storage.
Format a usb key in ext3, you also can format it as ext4 with the newer kirkwood boot but to me ext3 is enough, and set the label of this disk as "rootfs".
Mount the usb key and login as root in your terminal, you must be logged as root, the sudo command is not enough.
Copy the bz2 file your have download to your key.
Jump to the usb root mount folder, and extract the file. For me it's the command:
tar -xjf Debian-4.12.1-kirkwood-tld-1-rootfs-bodhi.tar.bz2
apt-get update
apt-get upgrade
And change your root password using passwd.
If you want to change the hostname edit /etc/hostname and add the new name to /etc/hosts.
To boot with systemd you can touch the /boot/uEnv.txt file and add this content to that file:
custom_params=init=/bin/systemd
Then you have to install systemd
apt-get install systemd
You are now ready to install things on your Debian NAS.
3) setup Debian: install OpenMediaVault
The most usefull software you can install in your NAS, to me, it's OpenMediaVault.
Installing OpenMediaVault in your new NAS is really simple, you just have to add the openmediavault repository package, using the command:
cat <<EOF >> /etc/apt/sources.list.d/openmediavault.list
deb http://packages.openmediavault.org/public arrakis main
# deb http://downloads.sourceforge.net/project/openmediavault/packages arrakis main
## Uncomment the following line to add software from the proposed repository.
# deb http://packages.openmediavault.org/public arrakis-proposed main
# deb http://downloads.sourceforge.net/project/openmediavault/packages arrakis-proposed main
## This software is not part of OpenMediaVault, but is offered by third-party
## developers as a service to OpenMediaVault users.
# deb http://packages.openmediavault.org/public arrakis partner
# deb http://downloads.sourceforge.net/project/openmediavault/packages arrakis partner
EOF
Then run the following come to install the openmediavault software:
export LANG=C
export DEBIAN_FRONTEND=noninteractive
export APT_LISTCHANGES_FRONTEND=none
apt-get update
apt-get --allow-unauthenticated install openmediavault-keyring
apt-get update
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
# Initialize the system and database.
omv-initsystem
saveenv
and reboot
reset
2) install the rootfs - Debian system
Now you can install the Debian system. This is going to be simpler then the uboot installation.
Download the latest Debian kirkwood rootfs from this link: https://forum.doozan.com/read.php?2,12096
I'm running Debian-4.12.1-kirkwood-tld-1-rootfs-bodhi.tar.bz2
My choice is to run the Debian distribution on a 8Gb usb key, and use the NSA hard drive as storage.
Format a usb key in ext3, you also can format it as ext4 with the newer kirkwood boot but to me ext3 is enough, and set the label of this disk as "rootfs".
Mount the usb key and login as root in your terminal, you must be logged as root, the sudo command is not enough.
Copy the bz2 file your have download to your key.
Jump to the usb root mount folder, and extract the file. For me it's the command:
tar -xjf Debian-4.12.1-kirkwood-tld-1-rootfs-bodhi.tar.bz2
Now edit the file etc/network/interface cause eth0 will be named enp1s0 on NSA310 as follow:
auto enp1s0
allow-hotplug enp1s0
iface enp1s0 inet dhcp
If you want to set a static IP, suppose 192.168.1.20, with the gateway and main dns server 192.168.1.1 and the dns server 8.8.8.8, on a domain domain.com the those lines should look like
If you want to set a static IP, suppose 192.168.1.20, with the gateway and main dns server 192.168.1.1 and the dns server 8.8.8.8, on a domain domain.com the those lines should look like
auto enp1s0
allow-hotplug enp1s0
iface enp1s0 inet static
address 192.168.1.20
netmask 255.255.255.0
gateway 192.168.1.1
dns-search domain.com
dns-nameservers 192.168.1.1 8.8.8.8
Plug the usb key to the NSA310 and boot it.
address 192.168.1.20
netmask 255.255.255.0
gateway 192.168.1.1
dns-search domain.com
dns-nameservers 192.168.1.1 8.8.8.8
Plug the usb key to the NSA310 and boot it.
The NSA should boot up with Debian.
If you set your network interface as above you should found it on your DHCP leases.
You should be able to log in the ssh terminal using the default username and passwod: root for both.
One logged in renew the ssh keys by using the following
rm /etc/ssh/ssh_host*
ssh-keygen -Aapt-get update
apt-get upgrade
And change your root password using passwd.
If you want to change the hostname edit /etc/hostname and add the new name to /etc/hosts.
To boot with systemd you can touch the /boot/uEnv.txt file and add this content to that file:
custom_params=init=/bin/systemd
Then you have to install systemd
apt-get install systemd
You are now ready to install things on your Debian NAS.
3) setup Debian: install OpenMediaVault
The most usefull software you can install in your NAS, to me, it's OpenMediaVault.
Installing OpenMediaVault in your new NAS is really simple, you just have to add the openmediavault repository package, using the command:
cat <<EOF >> /etc/apt/sources.list.d/openmediavault.list
deb http://packages.openmediavault.org/public arrakis main
# deb http://downloads.sourceforge.net/project/openmediavault/packages arrakis main
## Uncomment the following line to add software from the proposed repository.
# deb http://packages.openmediavault.org/public arrakis-proposed main
# deb http://downloads.sourceforge.net/project/openmediavault/packages arrakis-proposed main
## This software is not part of OpenMediaVault, but is offered by third-party
## developers as a service to OpenMediaVault users.
# deb http://packages.openmediavault.org/public arrakis partner
# deb http://downloads.sourceforge.net/project/openmediavault/packages arrakis partner
EOF
Then run the following come to install the openmediavault software:
export LANG=C
export DEBIAN_FRONTEND=noninteractive
export APT_LISTCHANGES_FRONTEND=none
apt-get update
apt-get --allow-unauthenticated install openmediavault-keyring
apt-get update
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
# Initialize the system and database.
omv-initsystem
Now you should be able to login to the web interface of your NSA310 openmediavault using the default username and password, that are admin and openmediavault.
From the OpenMediaVault panel you can customize your NAS.
You can format and mount your hard drive, and setup your sharing.
You can find a lot usefull information on the openmendiavault documentation page https://openmediavault.readthedocs.io/en/latest/
If you like me used an external USB key for your primary hdd, you can set your storage disk to spin down. I was not able to make my disk spindown in time using hdparm, so I'm using hd-idle. In order to use it I've got to compile it. Here you can find the hd-idle 1.05 armel package I've compiled:
To install hd-init copy the package on your device and run
dpkg -i hd-idle_1.05_armel.deb
Remember to disable the spindown on hdparm and on Storage/Physical Disks openmediavault settings.
Now you can edit the file /etc/default/hd-idle
Suppose you want to disable spindown for all disk except sda, and set a 10 minutes spindown for sda, that file should look like:
START_HD_IDLE=true
HD_IDLE_OPTS="-i 0 -a /dev/sda -i 600"
To start hd-idle at boot add the following command on System/Scheduled Jobs openmediavault setting:
service hd-idle start
use options reboot and user root.
Notes
- read risk disclaimer
- excuse my bad english
Hello Davide,
ReplyDeletethank you for this guide. I've installed Debian-4.12.1-kirkwood-tld-1-rootfs-bodhi.tar.bz2 but have problems with network driver. At first I had not ethernet and needed to install Realtek drivers manually. Now I am experiencing problems with gigabit network. It goes up and down and works just with manual 100Mbit ethtool configuration. Does your box works with gigabit?
Thanks, Michal
Hello and thank you, i've not tested it on gigabit. I've just changed the network config file using the enp1s0 name for the device. If you make it works with gigabit please share it here.
DeleteHi,
ReplyDeleteFirstly thank you for this amazing tutorial, its very informative on how to upgrade a uboot device!
My NSA310 says the following for bad blocks:
Scanning device for bad blocks
Bad eraseblock 134 at 0x0000010c0000
Bad eraseblock 338 at 0x000002a40000
Bad eraseblock 607 at 0x000004be0000
Does this mean that I can't flash the device?
Is there any way around the bad blocks of is that it?
Cheers,
Finn
So.... thinking about this...
DeletePart Size Start End Name
mtd0: 100000 0 FFFFF uboot
mtd1: 80000 100000 17FFFF uboot_env
mtd2: 80000 180000 1FFFFF key_store
mtd3: 80000 200000 27FFFF info
mtd4: a00000 280000 C7FFFF etc
mtd5: a00000 C80000 167FFFF kernel_1
mtd6: 2fc0000 1680000 463FFFF rootfs1
mtd7: a00000 4640000 503FFFF kernel_2
mtd8: 2fc0000 5040000 7FFFFFF rootfs2
That would put my bad blocks in:
Bad eraseblock 134 at 0x0000010c0000 kernel_1
Bad eraseblock 338 at 0x000002a40000 rootfs1
Bad eraseblock 607 at 0x000004be0000 kernel_2
Do I understand correctly that the only bit we are using for a Debian boot is the uboot and uboot_env areas?
Therefore I sould be able to flash the device fine?
Are the parts of NAND with bad blocks completely unusable?
Many thanks,
Finn
Hello Finn, as long as you do not have bad blocks on mtd0 you should be able to flash the uboot. It seems to me your bad blocks are not in mtd0, anyway I suggest you to read further on the linked pages in the post. Consider that you May brick your device of something goes wrong in the uboot flashing. As stated above, anything you do Is on yout own risk. Your bad blocks will Be skipped, NAND with bad blocks are pretty common, they works, the problem Is Just flashing uboot on mtd0 vado blocked partitino.
DeleteIt's on. :)
DeleteEventually I found a working pendrive. (16GB USB3.0 :O)
Instead "apt-get --allow-unauthenticated install openmediavault-keyring", you can install the root certificate first. ;)
Thanks for your eforts with this article! Good work.
Wrong place to reply, ehhh...
DeleteHappy to hear all it's working on your side! Thank you for sharing your experience here.
DeleteHi Davide,
ReplyDeleteI stuck at the very begining. I'm a beginer in embed systems.
To connect to the board I use a 'Ch340' ttl to usb stick. Windows 10 recognise it in the device manager. But Putty says 'unable to open serial port'. I tried to connect after the board boot up.
Any guess, hint?
Many thanks!
Máté
Ok. Me big noob:
Delete1) connect via UART
2) power on board
3) see the magic in Putty terminal
Yes. THis is not a very noobie mod, so pay attention, you may brick your device if you do something wrong.
DeleteHello Davide, (again)
DeleteIt seems like, I have no compatible USB stick at home. I've tried even a 256MB one, but no luck. After digging in the internet, I come to the conclusion, that with my v1.1.4 U-Boot the only option for me, is the TFTP.
I found this material:
https://forum.openwrt.org/t/serial-install-problems-on-nsa310/37306/11
But I want to be sure, before doing something wrong.
1) Basically I need to change in your description, the 'fatload ...' lines to 'tftp...' lines, so the memory loads source change(?) It seems obvious, but... just in case.
2) What really bothers me is the different command signature in usage, between the 'fatload' and the 'tftp' command address parameters. In the linked description there's 'tftp 0x1000000 u-boot.kwb', but You use 'fatload usb 0 0x0 0x800000 uboot.kwb'. Why there 1 hex in the tftp and why 2 in the fatload cmd? Is the 2 arg version for start+length? Put it simple: How shall I use the tftp cmd?
Many thanks in advance!
Máté
Hello, I'm sorry but I've never use tftp for this kind of task, I repeat, pay attention, you may brick your device. I think tftp should work, you can load it to address 0x1000000, as long is a ram addressable position. the number of parameters depends of the command you use.
DeleteOpenmediavault is not anymore supporting armer architecture.
ReplyDeleteIs there any trick to use old version on my NSA ?
Hello, you have to use an old version of openmediavault.
Delete