LinuxCommandLibrary

zramctl

Set up and control zram devices

TLDR

Check if zram is enabled

$ lsmod | grep -i zram
copy
Enable zram with dynamic number of devices
$ sudo modprobe zram
copy
Enable zram with exactly 2 devices
$ sudo modprobe zram num_devices=2
copy
Find and initialize the next free zram device
$ sudo zramctl -f -s 2GB -a lz4
copy
List currently initialized devices
$ sudo zramctl
copy

SYNOPSIS

zramctl [options] [zram-device]

DESCRIPTION

zramctl sets up and controls zram devices, which are compressed RAM-based block devices. Zram is useful for creating compressed swap space or temporary filesystems, improving memory efficiency.
After creating a zram device with zramctl, use mkswap and swapon to use it as swap, or mkfs to create a filesystem.

PARAMETERS

-f, --find

Find and initialize the next free zram device
-s, --size _size_
Set the size of the zram device
-a, --algorithm _alg_
Set compression algorithm (lz4, lzo, zstd, etc.)
-t, --streams _number_
Set number of compression streams
-r, --reset
Reset the device
-o, --output _list_
Define output columns
--raw
Raw output format

CAVEATS

Requires the zram kernel module. Compression algorithms vary by kernel version. Zram swap can improve performance on memory-constrained systems but uses CPU for compression. Part of the util-linux package.

SEE ALSO

mkswap(8), swapon(8), free(1)

> TERMINAL_GEAR

Curated for the Linux community

Copied to clipboard

> TERMINAL_GEAR

Curated for the Linux community