1.1.12 Zram

Zram compresses everything written to specified block devices in RAM, and is used typically for swap devices to improve the responsiveness of systems that have a limited amount of memory. The following example illustrates how to create and enable a zram swap device:

# mkswap /dev/zram0
# swapon /dev/zram0

The next example illustrates how to create a file system on a zram device and then mount this file system:

# mkfs.ext4 /dev/zram1
# mount /dev/zram1 /tmp

The following notable zram features are implemented in UEK R4:

  • Zram has been moved out of staging to drivers/block/zram.

  • Support for LZ4 compression in addition to LZO.

  • Performance improvements to concurrent compression of multiple compression streams.

  • Support for switching the compression algorithm in /sys/block/zramN/comp_algorithm.

  • Support for limiting the maximum amount of useable memory for a zram device in /sys/block/zramN/mem_limit. You can use memory unit suffixes when setting a value, for example:

    # echo 1G > /sys/block/zram0/mem_limit

    To disable the limit, set the value to 0.

  • Support for displaying the maximum memory that a zram device has consumed in /sys/block/zramN/mem_used_max. Writing 0 to this file resets the counter.