Keenetic routers have the option to enable a zRAM swap file. It provides more efficient use of RAM by compressing blocks that are rarely accessed or modified. It slightly increases the load on the processor. A swap file in a virtual RAM area (RAM disk) is sometimes required for the Transmission built-in torrent client to work correctly.
zRam - the Linux kernel module (formerly known as compcache) that increases performance by preventing data paging to the hard disk drive and using RAM compression (the lzo compression algorithm) until you need to use a swap file on the hard drive. This frees up space in the device's RAM, for storing data for the current requests from the processor.
The data exchange rate with RAM is much faster than with a hard disk drive; therefore, zRam allows more swap operations on devices with a small amount of RAM. Also, zRam will be useful for SSDs that use flash memory, which has a limited number of overwrite cycles.
From KeeneticOS 3.7 onwards, zRAM can be enabled in the router's web interface under 'Management' on the 'General system settings' page under 'Performance options'.
Set the 'Compressed RAM disk for syste, swap' switch to Enabled.
TIP: For more information, see the System performance settings: zRAM virtual swap file and HWNAT traffic accelerator article.
For devices with KeeneticOS 3.6 and earlier, zRAM can only be enabled from the command-line interface (CLI). Connect to CLI and execute the commands:
(config)> system zram
(config)> system configuration save
When you execute the system zram command, the system will automatically determine the recommended file size. As a rule, the size of the zRam file corresponds to the size of Keenetic RAM.
In our example, the RAM size of Keenetic Titan (KN-1810) is 256 MB or 262016 Kbytes (you can see it in CLI with show system):
(config)> show system
hostname: Keenetic_Titan
domainname: WORKGROUP
cpuload: 1
memory: 41908/262016
swap: 0/262012
memtotal: 262016
memfree: 183428
membuffers: 9248
memcache: 27432
swaptotal: 262012
swapfree: 262012
uptime: 824
In our case, the system automatically selected the swap file size equal to 256 MB.
You can use the show system zram command to view the zRam parameters:
(config)> show system zram
zram:
enabled: yes
compression-algo: lzo
disk-size: 262016456
compressed-size: 87
original-size: 4096
total-memory-used: 12288
compression-threads: 2
compressed-ratio-pcs: 300
To disable memory compression, you can use the command system no zram:
(config)> system zram
Zram::Manager: Enabled zram swap of size 262144Kb.
(config)> system no zram
Zram::Manager: Zram swap disabled.