Black Friday 2025 – NPI EA (cat = Baeldung on Linux)
announcement - icon

Yes, we're now running our Black Friday Sale. All Access and Pro are 33% off until 2nd December, 2025:

>> EXPLORE ACCESS NOW

Baeldung Pro – Linux – NPI EA (cat = Baeldung on Linux)
announcement - icon

Learn through the super-clean Baeldung Pro experience:

>> Membership and Baeldung Pro.

No ads, dark-mode and 6 months free of IntelliJ Idea Ultimate to start with.

Partner – Orkes – NPI EA (tag=Kubernetes)
announcement - icon

Modern software architecture is often broken. Slow delivery leads to missed opportunities, innovation is stalled due to architectural complexities, and engineering resources are exceedingly expensive.

Orkes is the leading workflow orchestration platform built to enable teams to transform the way they develop, connect, and deploy applications, microservices, AI agents, and more.

With Orkes Conductor managed through Orkes Cloud, developers can focus on building mission critical applications without worrying about infrastructure maintenance to meet goals and, simply put, taking new products live faster and reducing total cost of ownership.

Try a 14-Day Free Trial of Orkes Conductor today.

1. Overview

zram is a Linux kernel feature that creates a compressed block device in RAM. Pages on this block device are compressed and kept in memory. This can boost speed in systems with limited RAM by eliminating the requirement for swap space on slower disk storage.

However, there are several scenarios in which we may want to deactivate zram, such as when diagnosing memory issues, assessing system performance without compression, or installing a different swap scheme.

In this tutorial, we’ll look at how to disable zram at boot in Linux.

2. Checking zram Status

We can verify if zram is active and in use on our system, simply by using the zramctl command. Running this command provides comprehensive information on all active zram devices:

$ sudo zramctl
NAME       ALGORITHM DISKSIZE  DATA  COMPR  TOTAL STREAMS MOUNTPOINT
/dev/zram0 lzo-rle       1.9G  512M   128M   132M       4 [SWAP]

In this example, the output shows details about each zram device, such as its name, compression algorithm, disk size, data written, compressed data size, total memory use, compression streams, and mount point. Additionally, if executing sudo zramctl yields no output, it indicates that zram is either not enabled or not in use on the system.

Using this method allows us to quickly verify the activation status of zram and understand its impact on system memory.

3. Using systemd

systemd is a system and service manager for Linux. It configures system components and controls services. Many recent Linux distributions use systemd to handle zram, therefore deactivating zram through systemd can often be the simplest option:

$ sudo systemctl disable zram.service
Removed /etc/systemd/system/multi-user.target.wants/zram.service.

In this example, we use the systemctl command to disable the service unit that manages zram, named zram.service in this instance:

$ sudo systemctl stop zram.service

Then we stopped the service to deactivate zram and free up whatever resources it was using:

$ systemctl status zram.service
   zram.service - LSB: Initializes ZRAM swap
   Loaded: loaded (/etc/init.d/zram; generated)
   Active: inactive (dead) since Thu 2024-07-04 12:34:56 UTC; 5s ago

After that, we stop the zram.service and confirm that it has stopped by checking its status. The output indicates that the service has been deactivated.

Additionally, using systemd to manage services is a reliable and flexible method for controlling which components of the system are active. This strategy is very effective for debugging and modifying our system to meet specific performance needs.

4. Using Kernel Parameters

To disable zram at the kernel level, we can modify the bootloader settings to provide specific parameters to the system. This approach ensures that the system deactivates zram during the boot process before any services or scripts can initialize it.

$ sudo nano /etc/default/grub

In this example, nano is used to access the GRUB configuration file. Next, we look for the line that begins with GRUB_CMDLINE_LINUX_DEFAULT:

GRUB_CMDLINE_LINUX_DEFAULT="quiet splash zram.enabled=0"

This line includes the default kernel parameters that GRUB sends to the Linux kernel during boot time. Then, we add a quiet splash option, which reduces the boot notifications. We also block zram related functionality by using the zram.enabled=0 option:

$ sudo update-grub
Generating grub configuration file ...
Found linux image: /boot/vmlinuz-5.4.0-42-generic
Found initrd image: /boot/initrd.img-5.4.0-42-generic
done

Additionally, to apply the changes and regenerate the GRUB configuration file, we run the GRUB update command:

$ sudo reboot

 Finally, we reboot the system for the changes to take effect.

5. Using Configuration Files

Some distributions use configuration files to set up zram. For example, in Debian-based systems, you can configure zram using a configuration script:

$ sudo nano /etc/default/zram

In this example, we use nano to open the zram configuration file. These files are commonly found in /etc/default/zram and /etc/default/zramswap:

ENABLED=0

In this file, we check for a line that enables zram, such as ENABLED=1. We then set the line ENABLED=0 to deactivate zram. This parameter directs the system not to establish zram during boot:

$ sudo update-rc.d zram remove

Furthermore, we save and exit the file after making these modifications. Additionally, we deactivate the initialization script with the last command.

Modifying configuration files and deactivating initialization scripts prevent zram from initializing on startup.

6. Conclusion

In this article, we discussed how to deactivate zram during boot in Linux. Methods such as systemd, modifying configuration files, and adding kernel settings all provide us with a means for controlling zram on our system.

Following these steps we can properly disable zram at startup time, allowing us to customize our system to meet specific needs.