Update QNAP NAS over SSH

Since the upgrade instuctions from QNAP are incomplete I’ll try to make a complete overview of the steps here.

I used this KB Article from QNAP as base, but there are some quirks.

Preparations

First we need to get the firmware update itself stored somewhere. So find the upgrade you want to install on the QNAP download page and store it on the nas somewhere. I did over SSH since I like using cli:

[~] # cd /share/MD0_DATA
[/share/MD0_DATA] # wget https://eu1.qnap.com/Storage/TS-809U-RP/TS-809U_20200821-4.2.6.zip
--2021-03-07 14:59:23--  https://eu1.qnap.com/Storage/TS-809U-RP/TS-809U_20200821-4.2.6.zip
Resolving eu1.qnap.com (eu1.qnap.com)... 80.74.156.130
Connecting to eu1.qnap.com (eu1.qnap.com)|80.74.156.130|:443... connected.
HTTP request sent, awaiting response... 200 OK
Length: 171236919 (163M) [application/zip]
Saving to: ‘TS-809U_20200821-4.2.6.zip’

TS-809U_20200821-4.2.6.zip                         100%[==================================================================================================================>] 163.30M  6.94MB/s   in 30s

2021-03-07 14:59:53 (5.42 MB/s) - ‘TS-809U_20200821-4.2.6.zip’ saved [171236919/171236919]
[/share/MD0_DATA] #

Next we need to extract the update:

[/share/MD0_DATA] # unzip TS-809U_20200821-4.2.6.zip
 Archive:  TS-809U_20200821-4.2.6.zip
   inflating: TS-809U_20200821-4.2.6.img
[/share/MD0_DATA] #

Now that the upgrade file is prepared, we need some preparations on the system. We need a temporary folder where the update is stored, and a symlink for the system to use during the update:

[/share/MD0_DATA] #  mkdir /mnt/HDA_ROOT/update
[/share/MD0_DATA] #  ln -sf /mnt/HDA_ROOT/update /mnt/update
[/share/MD0_DATA] #  

Start the update process

With all this out of the way we can start the real update:

[/share/MD0_DATA] # /etc/init.d/update.sh /share/MD0_DATA/TS-809U_20200821-4.2.6.img
 cksum=2916634212
 Check RAM space available for FW update: OK.
 Using 120-bit encryption - (QNAPNASVERSION4)
 len=1048576
 model name = TS-809U
 version = 4.2.6
 boot/
 bzImage
 bzImage.cksum
 config/
 fw_info
 initrd.boot
 initrd.boot.cksum
 libcrypto.so.1.0.0
 libssl.so.1.0.0
 qpkg.tar
 qpkg.tar.cksum
 rootfs2.bz
 rootfs2.bz.cksum
 rootfs_ext.tgz
 rootfs_ext.tgz.cksum
 update/
 update_img.sh
 4.2.6 20200821
 OLD MODEL NAME = TS-809U
 Allow upgrade
 Allow upgrade
 /mnt/HDA_ROOT/update
 1+0 records in
 1+0 records out
 tune2fs 1.41.4 (27-Jan-2009)
 Setting maximal mount count to -1
 Setting interval between checks to 0 seconds
 Update image using HDD …
 bzImage cksum … Pass
 initrd.boot cksum … Pass
 rootfs2.bz cksum … Pass
 rootfs_ext.tgz cksum … Pass
 rootfs_ext.tgz cksum … Pass
 qpkg.tar cksum … Pass
 Update RFS1…
 mke2fs 1.41.4 (27-Jan-2009)
 Filesystem label=QTS_BOOT_PART2
 OS type: Linux
 Block size=1024 (log=0)
 Fragment size=1024 (log=0)
 13832 inodes, 55296 blocks
 0 blocks (0.00%) reserved for the super user
 First data block=1
 Maximum filesystem blocks=56623104
 7 block groups
 8192 blocks per group, 8192 fragments per group
 1976 inodes per group
 Superblock backups stored on blocks:
         8193, 24577, 40961
 Writing inode tables: done
 Writing superblocks and filesystem accounting information: done
 This filesystem will be automatically checked every 24 mounts or
 180 days, whichever comes first.  Use tune2fs -c or -i to override.
 Checking bzImage … ok
 Checking initrd.boot … ok
 Checking rootfs2.bz … ok
 Checking rootfs_ext.tgz … ok
 Update RFS2…
 mke2fs 1.41.4 (27-Jan-2009)
 Filesystem label=QTS_BOOT_PART3
 OS type: Linux
 Block size=1024 (log=0)
 Fragment size=1024 (log=0)
 13832 inodes, 55296 blocks
 0 blocks (0.00%) reserved for the super user
 First data block=1
 Maximum filesystem blocks=56623104
 7 block groups
 8192 blocks per group, 8192 fragments per group
 1976 inodes per group
 Superblock backups stored on blocks:
         8193, 24577, 40961
 Writing inode tables: done
 Writing superblocks and filesystem accounting information: done
 This filesystem will be automatically checked every 24 mounts or
 180 days, whichever comes first.  Use tune2fs -c or -i to override.
 1+0 records in
 1+0 records out
 Update Finished.
 Make a Backup
 /share/MD0_DATA
 qpkg.tar cksum … Pass
 set cksum [2916634212]
[/share/MD0_DATA] # reboot
[/share/MD0_DATA] 

The system will reboot and after the boot your QNAP should be up and running on the new firmware.

Issues

/mnt/update: Cannot chdir: No such file or directory

At some point during the update I got the following error:

/share/MD0_DATA] # /etc/init.d/update.sh /share/MD0_DATA/TS-809U_20200821-4.2.6.img
[...]
 /bin/tar: /mnt/update: Cannot chdir: No such file or directory
 /bin/tar: Error is not recoverable: exiting now
 [Firmware Update] System update failed. Firmware failed to extract. Error code: FW006
 [/share/MD0_DATA] #

That meant the folder /mnt/HDA_ROOT/update did not exist. A simple mkdir /mnt/HDA_ROOT/update resolved this issue.

Error code: FW004

At some point I run into a “Firmware file format error”:

[/share/MD0_DATA] # /etc/init.d/update.sh /share/MD0_DATA/TS-809U_20190322-4.2.6.zip
cksum=3061299578
Check RAM space available for FW update: OK.
Using 120-bit encryption - (QNAPNASVERSION4)
sig: ,▒"
▒ icpnas
[Firmware Update] System update failed. Firmware file format error. Error code: FW004
[/share/MD0_DATA] #

This meant I did not extract the zip file before applying the update. The update.sh command expects an .img file, not a .zip.

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.