User Tools

Site Tools


doc:appunti:hardware:qnap_ts-120

This is an old revision of the document!


QNAP TS-120

Prima accensione senza disco fisso

In un paio di minuti il dispositivo richiede un indirizzo IP via DHCP, altrimenti si assegna un 169.254.100.100, quindi risulta attivo sulla rete con queste porte aperte:

PORT      STATE SERVICE
22/tcp    open  ssh
443/tcp   open  https
8080/tcp  open  http-proxy
8090/tcp  open  unknown
49153/tcp open  unknown
49154/tcp open  unknown

L'accesso SSH con utente admin e password admin dà in effetti accesso root.

Ecco le info su CPU e RAM:

# cat /proc/cpuinfo 
Processor name  : Feroceon 88F6282 rev 1 (v5l) @ 1.6 GHz 
BogoMIPS        : 1589.24
Features        : swp half thumb fastmult edsp 
CPU implementer : 0x56
CPU architecture: 5TE
CPU variant     : 0x2
CPU part        : 0x131
CPU revision    : 1
# free       
              total         used         free       shared      buffers
  Mem:       515524        95332       420192            0         1332
# cat /proc/mtd   
dev:    size   erasesize  name
mtd0: 00080000 00010000 "U-Boot"
mtd1: 00200000 00010000 "Kernel"
mtd2: 00900000 00010000 "RootFS"
mtd3: 00300000 00010000 "RootFS2"
mtd4: 00040000 00010000 "U-Boot Config"
mtd5: 00140000 00010000 "NAS Config"

Installazione Debian

Vedere questa guida: Installing Debian on QNAP TS-11x and TS-12x devices.

Qui una copia locale dell'installer Debian e del contenuto originale della flash: qnap_ts-120.

Avviando dal firmware di base (quello su flash installato di fabbrica) si ha a disposizione un server SSH minimale, che non permette neanche il comando scp. Per copiare qualcosa via rete (ad esempio una partizione della flash oppure il conenuto di una cartella) si possono usare questi trucchi dal PC:

ssh admin@169.254.100.100 "cat /dev/mtdblock0" > mtd0
ssh admin@169.254.100.100 "tar cf - /mnt/sda2" | tar xvf -

Installazione Debian in breve: da una sessione SSH si scarica l'installer ufficiale Debian per QNAP (da ftp.debian.org), si lancia la procedura che scrive la flash e si effettua il reboot:

cd /tmp
busybox wget http://ftp.debian.org/debian/dists/stable/main/installer-armel/current/images/kirkwood/network-console/qnap/ts-119/initrd.gz
busybox wget http://ftp.debian.org/debian/dists/stable/main/installer-armel/current/images/kirkwood/network-console/qnap/ts-119/kernel
busybox wget http://ftp.debian.org/debian/dists/stable/main/installer-armel/current/images/kirkwood/network-console/qnap/ts-119/flash-debian
busybox wget http://ftp.debian.org/debian/dists/stable/main/installer-armel/current/images/kirkwood/network-console/qnap/ts-119/model
sh flash-debian
reboot

Sempre via SSH, login successivo (utente installer, password install) parte la procedura di installazione. Con la modalità expert è stato possibile installare Debian Jessie con kernel 3.12. Ad oggi (2014-02-11) pare risolto il problema di kernel qui descritto: QNAP TS-210 will not boot >=3.12-1, needs dtb.

Upgrade Debian

È stato possibile fare l'aggiornamento Debian dalla versione 7 Wheezy8 Jessie9 Stretch fino a 10 Buster. Con il partizionamento originale della memoria flash non è possibile installare Debian 11 Bullseye poiché lo spazio per flashare l'immagine del kernel non è sufficiente. Esiste tuttavia una ricetta per cambiare lo schema di partizione oppure è possibile installare Debian 11 mantenendo il kernel di Debian 10.

Wake-on-LAN

Con Debian Jessie, kernel 3.12.9 e qcontrol 0.5.2-2 il bug 703888 è risolto e il Wake-on-LAN funziona esattamente come su un PC: prima di fare lo shutdown bisogna mettere la scheda di rete nella modalità opportuna, tale funzione poi resta abilitata fintanto che il device è collegato all'alimentazione. Nel caso in cui venga scollegato e poi ricollegato alla rete, il WoL non funziona.

Le indicazioni sono contenute in questo post: Wake-On-LAN with Debian on a qnap TS-119P2+, in pratica prima di fare shutdown bisogna impartire i comandi:

qcontrol eup off
ethtool -s eth0 wol g
qcontrol wol on

Console seriale

Tips

  • FIXME C'è un clock RTC a bordo?

Upgrading to 4 Tb Hard Disk

It is possibile to install a 4 Tb Hard Disk on the old QNAP TS-120: I successfully installed a Western Digital WD40PURZ.

The original disk was partitioned using a MSDOS partition table, but there is a 2 Tb limit on partition size when using MSDOS table, so I decided to partition the new disk using GPT. Fortunately enough the kernel does support GPT and I was able to use the following partition schema:

Number  Start   End     Size    File system     Name     Flags
 1      1049kB  5000MB  4999MB  ext4            primary
 2      5000MB  6000MB  1000MB  linux-swap(v1)  primary
 3      6000MB  4001GB  3995GB  ext4            primary

Partition, dump and restore

To avoid a complete reinstall, I connected the new disk to a GNU/Linux computer, then partitioned the disk and performed a dump/restore via SSH.

For partitioning I used parted. Fortunately the hard disk was seen correctly both on the computer and later on the QNAP, I mean in particular the overall size and the logical/physical sector size. This is a subtle matter, e.g. the QNAP bootloader seems limited to disk size of 2 Tb, during bootstrap you can read this on the serial console:

Model: WDC WD40PURZ-85AKKY0    Firm: 80.00B80 Ser#:    WD-WX12D81D4P9U
    Type: Hard Disk
    Supports 48-bit addressing
    Capacity: 1718295.8 MB = 1678.0 GB (-775897424 x 512)

but from the kernel point of view, everything seems ok:

scsi 1:0:0:0: Direct-Access     ATA      WDC WD40PURZ-85A 0B80 PQ: 0 ANSI: 5
sd 1:0:0:0: [sda] 7814037168 512-byte logical blocks: (4.00 TB/3.64 TiB)
sd 1:0:0:0: [sda] 4096-byte physical blocks
sd 1:0:0:0: [sda] Write Protect is off
sd 1:0:0:0: [sda] Write cache: enabled, read cache: enabled, doesn't support DPO or FUA
 sda: sda1 sda2 sda3
sd 1:0:0:0: [sda] Attached SCSI disk

Beware the UUID of root filesystem

Beware that the initramfs installed into the flash memory will search the root filesystem using the UUID, so you have to set the partition UUID on the new disk to match the old one, otherwise the boot process will fail.

If you forget this step (like I did) you can attach to the serial console and fix the problem.

When the boot process fails, you get the initramfs prompt, here you can temporarly fix the problem by making a symlink from the new UUID to the missing one:

(initramfs) cd /dev/disk/by-uuid/
(initramfs) ln -s <new-UUID> <old-UUID>
(initramfs) exit

The QNAP should boot. To make a permanent fix you have to create a file /etc/initramfs-tools/conf.d/root containing the following:

ROOT=/dev/disk/by-uuid/<new-UUID>

Update the initramfs with:

update-initramfs -k all -u

The update-initramsf on the QNAP will call the flash-kernel tool to write the kernel and the initramfs images to the proper flash partitions. Flashing the images requires some minutes.

You can verify that the proper rootfs device is written into the initramfs image: unpack the the content of your initramfs by executing:

unmkinitramfs /boot/initrd.img-4.19.0-18-marvell ./initramfs/

Verify that inside the file /conf/param.conf is declared the proper device:

ROOT="/dev/disk/by-uuid/423996a4-7a6c-497d-bc45-ecfa98385c47"

Now try to reboot. If the problem is fixed, you may remove the file /etc/initramfs-tools/conf.d/root and update-initramfs again: now the proper rootfs will be autodetected.

doc/appunti/hardware/qnap_ts-120.1644567994.txt.gz · Last modified: 2022/02/11 09:26 by niccolo