Linux 101 : Zram - Your swap space inside the RAM -

Linux module drivers:

In order to display the Linux module drivers that are stored in the module directory, we use the below command:

To look for the zram module, we use the below command:

The "zram", our block device in the RAM:

Zram allows us to have a RAM disk, a compressed virtual block device inside the RAM.

To display the swap sapce ( zram ) in our case, we use the below command:

Loading the "zram" module in the kernel:

We use the below command to load the "zram"module from the kernel and create three virtual block devices in our RAM ( dev/zram0, /dev/zram1, /dev/zram2 ).

We create the "zram" devices using the below command:

We set up the "/dev/zram0" device using the below command:

  • --find : uses the first found "zram" device "dev/zram0"
  • --streams: compression streams depends on the CPU core number
  • --size : specifies the size of our "zram" block device.
  • --algorithm lz4 : specifies the compression algorithm which can also be "lzo", "lz4", "lz4hc", "deflate" or "842".
We then create an "ext4" filesystem on the "/dev/zram0" block device:

And we turn it into a "swap partition" using the below command:

Then, we enable our swap space using the below command:

To get information about the swap space, we use:


Leave as a comment: