Skip to content
Contents
GuidesOpenWrt

Will zram-swap help a small OpenWrt router? Check RAM pressure and flash space

Check memory pressure, remaining flash space, and actual post-compression usage before deciding whether to enable zram on low-configuration devices.

zram keeps compressible data in memory. It consumes physical memory and CPU to gain logically available space, and additionally requires both a driver and user-space components to be included in the firmware. The 16/32 MB RAM examples from historical documentation cannot be directly applied as installation recommendations for a 4 MB flash-based router.

First, clearly determine which type of space is insufficient

grep -E '^(MemAvailable|SwapTotal|SwapFree):' /proc/meminfo
cat /proc/swaps
df -h
logread -e oom

If a configuration write fails due to insufficient space, first check the available space in the overlay; increasing swap does not resolve a full flash. If a running service is terminated by the kernel due to memory pressure, record the process, timestamp, and memory usage under normal load conditions, then consider disabling the service or adjusting cache settings. When building your own image, verify the device partition size limits and the actual file size after package inclusion.

How to verify the effect in a system that already has zram?

Compare latency, CPU usage, and OOM (Out-of-Memory) records under identical workloads, and examine the raw data—compressed data, and actual usage—from /sys/block/zram0/mm_stat (if kernel support is available). When the amount of compressible content is too small, significant gains may not be achieved. If the device is approaching memory exhaustion, do not directly disable swap while it is actively servicing large data loads; instead, reduce load during maintenance windows, restart with original configuration, and verify critical services. For devices that cannot accommodate compatible images, retain the current system and maintain available backups.

Reference

Related guide · Check for an out-of-memory event when the OpenWrt interface stops responding

Explore hardware

Comments