Contents
How to change the compression algorithm in zram?
Using comp_algorithm device attribute one can see available and currently selected (shown in square brackets) compression algorithms, or change the selected compression algorithm (once the device is initialised there is no way to change compression algorithm).
How to turn a zram block device into a RAM-backed compressed swap?
Turning a zram block device into a RAM-backed compressed swap is easy once the drive it initialized, it is merely a matter of running mkswap to make it a swap drive and swapon to enable that drive. Using the swapon argument -p 32767 will give a zram device the highest priority possible.
How to use loopdev for ZRAM WRITEBACK feature?
But I’ve successfully used a swap file too, by attaching it to a loop device After this, swapon -s shows zRAM device enabled, cat /sys/block/zram0/backing_dev returns /dev/loop0 and echo huge > /sys/block/zram0/writeback works with no problem, with cat /sys/block/zram0/bd_stats confirming that the write indeed succeeded
What can zram be used for in Linux?
zram is a Linux kernel module that allows you to create RAM-backed block devices with up to 5:1 compression. zram devices can be used like any other block device. They are typically used to make compressed swap devices using a machines RAM. They can also be used to store /tmp and anything else one might want to store on a compressed RAM-drive.
How to know the block state of zram?
With CONFIG_ZRAM_MEMORY_TRACKING, user can know information of the zram block. It could be useful to catch cold or incompressible pages of the process with*pagemap. If you enable the feature, you could see block state via /sys/kernel/debug/zram/zram0/block_state”.
Which is the latest version of the zram kernel?
Starting with kernel version 3.15, zram supports multiple compression streams and the ability to change the compression algorithms without a system restart. The zram kernel module enables support for creating compressed block devices in RAM.