Zram: Difference between revisions

From Alpine Linux
(updated based on https://gitlab.alpinelinux.org/alpine/aports/-/issues/17231)
(add trouble shooting)
 
Line 13: Line 13:
size0=8000
size0=8000
</nowiki>}}
</nowiki>}}
Advanced parameters can be found in the [https://github.com/vaeth/zram-init/blob/main/openrc/conf.d/zram-init source repo].


Start services:{{Cmd|# rc-service zram-init start}}
Start services:{{Cmd|# rc-service zram-init start}}
Line 27: Line 29:


== Troubleshooting ==  
== Troubleshooting ==  
Check whether ZRAM's module is loaded: {{Cmd|# lsmod &#124; grep zram}}
If not loaded, use <code>modprobe</code> to load it: (however, it should be automatically loaded if <code>load_on_start=yes</code> is in the configuration) {{Cmd|# modprobe zram}}


== See also ==
== See also ==

Latest revision as of 18:18, 4 June 2025

This page documents how to set up ZRAM in Alpine Linux. Zram can be used as an alternative to Swap partition.

Installation

Install the neccessary packages:

# apk add zram-init

Configuration

For a basic ZRAM swap, configure ZRAM by editing the file /etc/conf.d/zram-init as follows:

Contents of /etc/conf.d/zram-init

load_on_start=yes unload_on_stop=yes num_devices=1 type0=swap size0=8000

Advanced parameters can be found in the source repo.

Start services:

# rc-service zram-init start

View the ZRAM drive:

# cat /proc/swaps

Check Algorithms:

# cat /sys/block/zram0/comp_algorithm

Advanced setups may also add these parameters to /etc/sysctl.conf as follows:

Contents of /etc/sysctl.conf

vm.page-cluster=0 vm.extfrag_threshold=0 vm.swappiness=100

To ensure that service starts during next reboot:

# rc-update add zram-init

Troubleshooting

Check whether ZRAM's module is loaded:

# lsmod | grep zram

If not loaded, use modprobe to load it: (however, it should be automatically loaded if load_on_start=yes is in the configuration)

# modprobe zram

See also