QNAP NAS to Linux
Introduction
Old System
QNAP NAS is TS-431P with Annapurna Labs Alpine AL212 Dual-core ARM Cortex A15 @1.7GHz, 1000MB memory. I have 2x953GB and 2x7.28TB with two RAID 1 enclosures.
- AnnapurnaLabs Alpine AL-212, 2-core ARM Cortex-A15 @ 1.7 GHz
- 1 GB DDR3 RAM, non-upgradable
- 512 MB flash, specifically used for the system and dual-boot protection
- 4 × SATA drive bays
- 2 × Gigabit Ethernet
- no internal M.2/SATA SSD system slot.
QNAP explicitly lists the 512 MB flash as “Dual boot OS protection.” So there isn't really a QNAP "system HDD" that you need to replace.
Power consumption
- 11.65 W with disks in standby
- 26.7 W typical operating consumption, with all four bays populated
- 90 W external power adapter
- 12 VDC fan.
Ideas for the new Processor and motherboard
Use the old laptops
- ICY BOX IB-3640SU3 for 4-bay JBOD enclosure
- Photograph/label the four disks: sda, sdb, sdc, sdd as they are currently identified by QNAP.
- Connect the ICY BOX to the Lenovo.
- Verify that Linux sees all four disks and their partitions correctly.
- Do not format, initialize, or "repair" anything if Linux suggests it.
- Assemble the existing md1 and md2 RAID-1 arrays.
- Mount them read-only initially.
- Check that your photos and directory structure are intact.
- Only then start designing the permanent Linux NAS configuration.
- Install Immich and let it build its index/face recognition database.
| Component | Target |
|---|---|
| CPU | Intel N305 |
| Form factor | Mini-ITX 17×17 cm |
| RAM | 16 GB minimum, 32 GB preferred |
| SATA | 6 ports |
| NVMe | 2 slots |
| Network | 2.5 GbE |
| GPU | Intel integrated |
| OS | Debian |
A small Intel N100/N305-class machine with 8–16 GB RAM is a slow and not that capable for AI indexing.
- Intel N100/N305
- 8–16 GB RAM
- 250–500 GB NVMe/SSD
- 4+ SATA ports, or
- one PCIe slot with a proper SATA HBA
Analyzing the old hdd situation
cat /proc/mdstat
Personalities : [linear] [raid0] [raid1] [raid10] [raid6] [raid5] [raid4] [multipath]
md2 : active raid1 sda3[0] sdb3[1]
966808384 blocks super 1.0 [2/2] [UU]
md1 : active raid1 sdc3[0] sdd3[1]
7804071744 blocks super 1.0 [2/2] [UU]
md322 : active raid1 sdd5[3](S) sdc5[2](S) sdb5[1] sda5[0]
6702656 blocks super 1.0 [2/2] [UU]
bitmap: 0/1 pages [0KB], 65536KB chunk
md256 : active raid1 sdd2[3](S) sdc2[2](S) sdb2[1] sda2[0]
530112 blocks super 1.0 [2/2] [UU]
bitmap: 1/1 pages [4KB], 65536KB chunk
md13 : active raid1 sda4[34] sdd4[33] sdc4[32] sdb4[35]
458880 blocks super 1.0 [32/4] [UUUU____________________________]
bitmap: 1/1 pages [4KB], 65536KB chunk
md9 : active raid1 sda1[0] sdd1[33] sdc1[32] sdb1[1]
530048 blocks super 1.0 [32/4] [UUUU____________________________]
bitmap: 1/1 pages [4KB], 65536KB chunk
unused devices: <none>
df -hT
Filesystem Type Size Used Available Use% Mounted on
none tmpfs 400.0M 209.3M 190.7M 52% /
devtmpfs devtmpfs 490.0M 4.0K 490.0M 0% /dev
tmpfs tmpfs 64.0M 1.5M 62.5M 2% /tmp
tmpfs tmpfs 500.1M 176.0K 500.0M 0% /dev/shm
tmpfs tmpfs 16.0M 0 16.0M 0% /share
tmpfs tmpfs 16.0M 0 16.0M 0% /mnt/snapshot/export
/dev/md9 ext4 493.5M 143.5M 339.6M 30% /mnt/HDA_ROOT
cgroup_root tmpfs 500.1M 0 500.1M 0% /sys/fs/cgroup
/dev/mapper/cachedev1
ext4 5.6T 1.3T 4.3T 23% /share/CACHEDEV1_DATA
/dev/md13 ext4 416.7M 299.2M 117.5M 72% /mnt/ext
tmpfs tmpfs 32.0M 26.7M 5.3M 84% /samba_third_party
tmpfs tmpfs 4.0K 0 4.0K 0% /tmp/default_dav_root
tmpfs tmpfs 16.0M 32.0K 16.0M 0% /share/CACHEDEV1_DATA/.samba/lock/msg.lock
tmpfs tmpfs 16.0M 0 16.0M 0% /mnt/ext/opt/samba/private/msg.sock
tmpfs tmpfs 30.0M 0 30.0M 0% /tmp/wfm
overlay overlay 5.6T 1.3T 4.3T 23% /share/CACHEDEV1_DATA/.qpkg/container-station/system-docker/overlay2/b29dcb302ed3bbe82ca37349eae81b4a3fbba90d917a9c950a8f720c2326546f/merged
tmpfs tmpfs 54.0M 18.8M 35.2M 35% /mnt/ext/opt/FileStation5
/dev/loop0 ext3 54.0M 18.8M 35.2M 35% /mnt/ext/opt/FileStation5
lsblk -o NAME,SIZE,TYPE,FSTYPE,MOUNTPOINT
lsblk does not work in QNAP NAS.
cat /proc/mdstat
Personalities : [linear] [raid0] [raid1] [raid10] [raid6] [raid5] [raid4] [multipath]
md2 : active raid1 sda3[0] sdb3[1]
966808384 blocks super 1.0 [2/2] [UU]
md1 : active raid1 sdc3[0] sdd3[1]
7804071744 blocks super 1.0 [2/2] [UU]
md322 : active raid1 sdd5[3](S) sdc5[2](S) sdb5[1] sda5[0]
6702656 blocks super 1.0 [2/2] [UU]
bitmap: 0/1 pages [0KB], 65536KB chunk
md256 : active raid1 sdd2[3](S) sdc2[2](S) sdb2[1] sda2[0]
530112 blocks super 1.0 [2/2] [UU]
bitmap: 0/1 pages [0KB], 65536KB chunk
md13 : active raid1 sda4[34] sdd4[33] sdc4[32] sdb4[35]
458880 blocks super 1.0 [32/4] [UUUU____________________________]
bitmap: 1/1 pages [4KB], 65536KB chunk
md9 : active raid1 sda1[0] sdd1[33] sdc1[32] sdb1[1]
530048 blocks super 1.0 [32/4] [UUUU____________________________]
bitmap: 1/1 pages [4KB], 65536KB chunk
unused devices: <none>
mdadm --detail --scan
ARRAY /dev/md9 metadata=1.0 name=9 UUID=d61cc9d5:bbb553d5:db500c2c:2501a0eb
ARRAY /dev/md13 metadata=1.0 name=13 UUID=b3b4340b:2ef60331:788b45b8:bfc182a2
ARRAY /dev/md256 metadata=1.0 spares=2 name=256 UUID=d3e3e3bf:4cf14df1:5f23c611:5da6b759
ARRAY /dev/md322 metadata=1.0 spares=2 name=322 UUID=e6ba2f67:2a22c24c:e6026a43:b280a258
ARRAY /dev/md1 metadata=1.0 name=1 UUID=0b22b3d8:e2dc8bb9:17a103e6:da47a16d
ARRAY /dev/md2 metadata=1.0 name=2 UUID=0daee8fd:6dbb9f8a:3ff09b1d:c0affc5f
df -hT
Filesystem Type Size Used Available Use% Mounted on
none tmpfs 400.0M 209.1M 190.9M 52% /
devtmpfs devtmpfs 490.0M 4.0K 490.0M 0% /dev
tmpfs tmpfs 64.0M 1.4M 62.6M 2% /tmp
tmpfs tmpfs 500.1M 176.0K 500.0M 0% /dev/shm
tmpfs tmpfs 16.0M 0 16.0M 0% /share
tmpfs tmpfs 16.0M 0 16.0M 0% /mnt/snapshot/export
/dev/md9 ext4 493.5M 146.7M 336.4M 30% /mnt/HDA_ROOT
cgroup_root tmpfs 500.1M 0 500.1M 0% /sys/fs/cgroup
/dev/mapper/cachedev1
ext4 5.6T 1.3T 4.3T 23% /share/CACHEDEV1_DATA
/dev/md13 ext4 416.7M 299.2M 117.4M 72% /mnt/ext
tmpfs tmpfs 32.0M 26.7M 5.3M 84% /samba_third_party
tmpfs tmpfs 4.0K 0 4.0K 0% /tmp/default_dav_root
tmpfs tmpfs 16.0M 32.0K 16.0M 0% /share/CACHEDEV1_DATA/.samba/lock/msg.lock
tmpfs tmpfs 16.0M 0 16.0M 0% /mnt/ext/opt/samba/private/msg.sock
tmpfs tmpfs 54.0M 18.8M 35.2M 35% /mnt/ext/opt/FileStation5
/dev/loop0 ext3 54.0M 18.8M 35.2M 35% /mnt/ext/opt/FileStation5
tmpfs tmpfs 30.0M 0 30.0M 0% /tmp/wfm
overlay overlay 5.6T 1.3T 4.3T 23% /share/CACHEDEV1_DATA/.qpkg/container-station/system-docker/overlay2/7e19683c7843f6c851f7fd6c9423a235e7ebf895e61ec0693b1da6c4b7a08365/merged
[~] # pvs
PV VG Fmt Attr PSize PFree
/dev/md1 vg1 lvm2 a-- 7.27t 0
/dev/md2 vg2 lvm2 a-- 922.02g 0
[~] # vgs
VG #PV #LV #SN Attr VSize VFree
vg1 1 3 0 wz--n- 7.27t 0
vg2 1 2 0 wz--n- 922.02g 0
[~] # lvs
LV VG Attr LSize Pool Origin Data% Meta% Move Log Cpy%Sync Convert
lv1 vg1 Vwi-aot--- 5.67t tp1 100.00
lv544 vg1 -wi------- 74.42g
tp1 vg1 twi-aot--- 7.13t 79.51 0.57
lv545 vg2 -wi------- 9.22g
tp2 vg2 twi-aot--- 847.23g 0.00 0.01
Migrating to Debian
LVM metadata is intact, but the actual tp1 → tp1_tierdata_2 chain requires QNAP's flashcache target, which Debian kernel does not provide. The QNAP itself, however, should know how to read it.
The data on NAS is at /share/CACHEDEV1_DATA/Public
Creating larger system
A proper SATA/SAS HBA can connect the Linux machine to additional drive shelves/enclosures.
With the current four slot machine
- Replace the 7.28 TB pair with larger disks. Current 8 TB + 8 TB → RAID 1 → ~8 TB can be changed to eg 16 TB + 16 TB → RAID 1 → ~16 TB. Raid is done such that one disk at a time can be replaced (the RAID rebuild in between).
- Turn the 8 TB RAID-1 into RAID 5. RAID 1 → RAID 5 by adding a disk
The Linux server
AI Image indexing
Use some old laptop as a dedicated remote ML worker. Immich supports configuring separate machine-learning servers. The AI system should never become the owner of your originals.
Immich
- face recognition — identify and group people
- semantic/smart search — e.g. search for concepts rather than just filenames
- automatic photo/video indexing
- mobile apps and automatic phone backup
- albums and sharing
- metadata/EXIF handling
- timeline-based browsing
- Docker deployment
- local machine-learning models, so your photos don't have to be sent to a cloud service
[ttps://www.photoprism.app Photoprism]
- facial recognition
- image classification
- labels
- locations
- metadata handling
- RAW support
- computer vision
- optional AI-generated captions/labels
500 GB–1 TB NVMe SSD
- Linux
- Docker
- Immich database
- thumbnails
- ML models
- application data
Existing HDD RAID
- Original photos
- Videos
- RAW files
- Archives
Old Laptops
- Intel i3-7020U — 2 cores / 4 threads, 2.3 GHz
- 8 GB RAM
- Intel HD Graphics 620
- AVX2
- Intel VT-x
- likely Gigabit Ethernet
lscpu
Architecture: x86_64
CPU op-mode(s): 32-bit, 64-bit
Address sizes: 39 bits physical, 48 bits virtual
Byte Order: Little Endian
CPU(s): 4
On-line CPU(s) list: 0-3
Vendor ID: GenuineIntel
Model name: Intel(R) Core(TM) i3-7020U CPU @ 2.30GHz
CPU family: 6
Model: 142
Thread(s) per core: 2
Core(s) per socket: 2
Socket(s): 1
Stepping: 10
CPU(s) scaling MHz: 35%
CPU max MHz: 2300.0000
CPU min MHz: 400.0000
BogoMIPS: 4599.93
Flags: fpu vme de pse tsc msr pae mce cx8 apic sep mtrr pge mca cmov pat pse36 clflu
sh dts acpi mmx fxsr sse sse2 ss ht tm pbe syscall nx pdpe1gb rdtscp lm const
ant_tsc art arch_perfmon pebs bts rep_good nopl xtopology nonstop_tsc cpuid a
perfmperf pni pclmulqdq dtes64 monitor ds_cpl vmx est tm2 ssse3 sdbg fma cx16
xtpr pdcm pcid sse4_1 sse4_2 x2apic movbe popcnt tsc_deadline_timer aes xsav
e avx f16c rdrand lahf_lm abm 3dnowprefetch cpuid_fault epb pti ssbd ibrs ibp
b stibp tpr_shadow flexpriority ept vpid ept_ad fsgsbase tsc_adjust sgx bmi1
avx2 smep bmi2 erms invpcid mpx rdseed adx smap clflushopt intel_pt xsaveopt
xsavec xgetbv1 xsaves dtherm arat pln pts hwp hwp_notify hwp_act_window hwp_e
pp vnmi md_clear flush_l1d arch_capabilities
Virtualization features:
Virtualization: VT-x
Caches (sum of all):
L1d: 64 KiB (2 instances)
L1i: 64 KiB (2 instances)
L2: 512 KiB (2 instances)
L3: 3 MiB (1 instance)
NUMA:
NUMA node(s): 1
NUMA node0 CPU(s): 0-3
Vulnerabilities:
Gather data sampling: Vulnerable
Ghostwrite: Not affected
Indirect target selection: Not affected
Itlb multihit: KVM: Mitigation: Split huge pages
L1tf: Mitigation; PTE Inversion; VMX conditional cache flushes, SMT vulnerable
Mds: Mitigation; Clear CPU buffers; SMT vulnerable
Meltdown: Mitigation; PTI
Mmio stale data: Mitigation; Clear CPU buffers; SMT vulnerable
Old microcode: Not affected
Reg file data sampling: Not affected
Retbleed: Mitigation; IBRS
Spec rstack overflow: Not affected
Spec store bypass: Mitigation; Speculative Store Bypass disabled via prctl
Spectre v1: Mitigation; usercopy/swapgs barriers and __user pointer sanitization
Spectre v2: Mitigation; IBRS; IBPB conditional; STIBP conditional; RSB filling; PBRSB-eIB
RS Not affected; BHI Not affected
Srbds: Mitigation; Microcode
Tsa: Not affected
Tsx async abort: Not affected
Vmscape: Mitigation; IBPB before exit to userspace
free -h
total used free shared buff/cache available
Mem: 7.1Gi 1.8Gi 1.6Gi 403Mi 4.3Gi 5.3Gi
Swap: 4.0Gi 364Ki 4.0Gi
lspci | grep -Ei 'vga|3d|display'
00:02.0 VGA compatible controller: Intel Corporation HD Graphics 620 (rev 07)
Immich
External Libraries
Docker. Find the Docker path
docker compose ls
Edit docker-compose.yml to add new folders:
immich-server:
...
volumes:
- ${UPLOAD_LOCATION}:/data
- /media/nap/HDD8TB/Photos:/mnt/external/HDD8TB:ro
docker compose up -d
docker exec -it immich_server ls -la /mnt/external/HDD8TB
Static IP
Also set the hostname to clients /etc/hosts. No need to Avahi.
192.168.8.194 nap nap.local
Syncthing-fork
Use Syncthing for transferring images from the Android phone directly to the Immich server's hdd.
ssh -N -L 8384:127.0.0.1:8384 nap@nap
Mounting the hdds
NFS file server. Check exports
sudo exportfs -v
(and if needed, reload those
sudo exportfs -ra
and check it again. Also /etc/exports
/media/nap/HDD1 192.168.8.0/24(rw,sync,no_subtree_check)
/media/nap/HDD2 192.168.8.0/24(rw,sync,no_subtree_check)
/media/nap/HDD8TB 192.168.8.0/24(rw,sync,no_subtree_check)
and client's /etc/fstab
nap.local:/media/nap/HDD1 /mnt/icebox/HDD1 nfs4 _netdev,nofail 0 0
nap.local:/media/nap/HDD2 /mnt/icebox/HDD2 nfs4 _netdev,nofail 0 0
nap.local:/media/nap/HDD8TB /mnt/icebox/HDD8TB nfs4 _netdev,nofail 0 0
lsblk -o NAME,PATH,SIZE,FSTYPE,LABEL,UUID,MOUNTPOINTS,MODEL,SERIAL
Check the /etc/fstab.
Desktop (xfce) automount is giving problems. Settings Manager → Removable Drives and Media. Under Storage, disable:
- Mount removable drives when hot-plugged
- Mount removable media when inserted
You can also run:
xfconf-query -c thunar-volman -p /automount-drives/enabled -s false
xfconf-query -c thunar-volman -p /automount-media/enabled -s false
xfconf-query -c thunar-volman -p /autobrowse/enabled -s false
xfconf-query -c thunar-volman -p /autoopen/enabled -s false
Client mount points:
findmnt -t nfs,nfs4