Home

zram

Zram is a Linux kernel feature that provides a compressed RAM-backed block device, typically used as a swap device. It creates one or more in-memory block devices that store data in RAM after compressing it, which can reduce the amount of physical memory needed to hold swapped-out pages and improve overall responsiveness on systems with limited or slow storage.

How it works: When the zram module is loaded, the system exposes one or more /dev/zramN devices.

Configuration and usage: After loading the module, administrators allocate space for the zram devices, initialize them

Advantages and use cases: Zram can reduce I/O pressure on slow storage, improve performance on systems with

Limitations: Compression and decompression consume CPU resources, and the effectiveness depends on data compressibility. If memory

The
size
of
each
device
is
configured
by
writing
to
its
disksize
attribute.
Pages
that
would
normally
be
swapped
to
disk
are
instead
written
to
the
zram
device
and
compressed
using
a
chosen
algorithm
(such
as
LZ4,
Zstd,
or
LZO).
When
those
pages
are
accessed
again,
they
are
decompressed.
Because
the
data
remains
in
RAM,
access
times
are
generally
faster
than
disk-based
swap.
Zram
can
be
used
as
swap,
or
as
a
RAM-based
cache
or
disk
substitute
in
some
scenarios.
as
swap
with
standard
tools
(for
example,
mkswap
followed
by
swapon),
and
adjust
the
number
of
devices
or
compression
algorithm
as
needed.
Some
distributions
provide
helper
utilities
or
scripts
to
automate
this
process
and
to
adjust
memory
pressure
dynamically.
limited
RAM,
and
enhance
responsiveness
under
memory
pressure.
It
is
commonly
used
on
mobile
devices,
embedded
systems,
and
some
Linux
desktops
and
servers
where
fast,
in-memory
swap
is
beneficial.
is
abundant,
zram
may
be
underutilized;
if
CPU
is
a
bottleneck
or
data
is
incompressible,
performance
gains
may
be
limited.
It
does
not
replace
a
traditional
disk-based
swap
for
long-term
memory
overflow.