My Synology DiskStation DS212j has gotten slower over the years ever since I bought in 2012. DSM operating system security and software upgrades introduced feature bloat that required more memory and caused memory to page to disk. Wikipedia gives an amazing overview of why paging is bad and why zRAM is amazing for memory constrained PCs.
zram (also called zRAM and, initially, compcache) is a Linux kernel feature that provides a form of virtual memory compression. zram increases performance by avoiding paging to disk and using a compressed block device in RAM instead, inside which paging takes place until it is necessary to use the swap space on a hard disk drive. Since using zram is an alternative way to provide swapping on RAM, zram allows Linux to make a better use of RAM when swapping/paging is required, especially on older computers with less RAM installed.
Pretty cool, huh? The Android community often uses zRAM as a way to bring back older devices back to life and I figured I could do the same with my aging DiskStation that only came with 256MB of RAM compared to the more recent DS216 that comes with twice that at 512MB.
I successfully compiled and added the zRAM module to my DS212j and wanted to share the steps. My DS212j uses the Linux kernel 2.6.32 so this guide should be applicable to any Synology DS that uses the same kernel.
Setting up the DSM 6.1 Tool Chain
Synology has provided excellent documentation on how to compile kernel modules. You should follow their tutorial on how to setup the toolkit to compile the kernel.
Steps for the DS212j are roughly:
- Setup toolkit:
Compiling the 2.6.32 Kernel
You will need to follow the Synology documentation to compile kernel modules here in order to build the LZO kernel module. This is a dependent kernel module for zRAM.
Steps are roughly:
Download the kernel source for the closest branch that is currently deployed on your Synology: https://sourceforge.net/projects/dsgpl/files/Synology%20NAS%20GPL%20Source/
Extract the source to
/toolkit/build_env/ds.x64-6.1/root/
Enter the tool chain chroot:
Build LZO modules because they’re dependencies for zRAM.
EnterCryptographic API
to selectLZO compression algorithm
as a module. Exit and save.Copy
lzo_compress.ko
,lzo_decompress.ko
,lzo.ko
to your Synology
Compiling the Compcache Kernel Module
I have successfully compiled the Compcache 0.6.2 kernel module and gotten it to work with the stock 2.6.32 kernel. The latest version doesn’t seem to work so we’re going to stick with 0.6.2 where we will follow the Compcache documentation here.
- Download Compcache 0.6.2 module source:
- Copy
ramzswap.ko
to your Synology
Installation
Copy kernel modules to Synology DSM
Test kernels by inserting them
Enable swap with:
- Verify everything worked by checking dmesg for errors
Add above
insmod
/swapon
commands to/etc/rc.local
to make the changes permanent
zRAM Results
It’s super effective! I’ve noticed that there was roughly ~100MB of paged memory usually and I’ve managed to get it all to fit within ~30MB of compressed memory space rather than going down to the hard drive. Responsiveness in the DSM OS has greatly improved as a result.