Synology ko
Preface
Synology DSM is Linux-based but customized for NAS usage and may lack certain kernel modules needed for other applications. This article explains how to compile kernel modules for Synology.
First, identify which modules you need. To deploy One-KVM in Docker on NAS, we need UVC (USB video) and CH340 (USB serial) drivers so DSM can recognize the USB capture card and USB serial adapter. The image below shows the final result: the driver stack loads and device nodes appear.
Info
Synology open-source archive: Synology Archive Download Site - Index of /download
You can download most sources here (kudos to Synology). To compile modules, you only need the toolchain and kernel source. Download the versions matching your model and DSM version.
Enable SSH and run uname -a
to get kernel info: Linux MofengNAS 4.4.302+ #72803 SMP Mon Aug 19 19:59:09 CST 2024 x86_64 GNU/Linux synology_apollolake_218+
. In DSM Control Panel -> Info Center, note the DSM version, e.g., DSM 7.2.2-72803
. This is important.
Then download the matching Linux kernel source and toolchain. Kernel sources are under ToolChain/Synology NAS GPL Source/<DSM version>
, toolchains under ToolChain/toolchain/<DSM version>
. The following screenshots and commands are for the author's NAS; adjust for your system.
Build
Enable module options
Use Ubuntu to build modules; compiling directly on DSM is cumbersome due to dependencies. Here we use WSL2.
In linux-4.4.x
, copy the config for your model from synoconfigs
(do not skip), then enable options in menuconfig. Use /
to search dependencies.
Enable the required options, save and exit.
Compile
Important: the module vermagic
must match the kernel. By default, the compiled module misses a trailing +
, causing insmod to fail, as shown below. Later, verify modules with sudo insmod <file>.ko
and sudo dmesg
.
Edit the top of the kernel Makefile
to match the Synology kernel version so that vermagic
matches.
Now build using Synology's gcc toolchain (not the system gcc). Install missing deps as needed.
You will get the following files. Copy them to /lib/modules
on the NAS, run sudo depmod -a
, and load drivers or reboot. The USB devices should be recognized.