Score:1

How to permanently remove /dev/zram0 as swap in Armbian

jp flag

My Armbian Bullseye system insists on setting up swap space on /dev/zram0. I don't want it to, as I have created a swap partition that I would prefer to use.

But I can't find how to permanently remove the swap space /dev/zram0. It can be removed temporarily with swapoff but returns on reboot. There is nothing relevant in /etc/fstab or anywhere else that I can find.

Installing zram-tools didn't help as the service failed.

Searching gives lots of pages that say something about swap or zram, but nothing appears to answer this apparently simple question! Any suggestions please?

Added following the answer below: The command

systemctl --type swap

after masking and reboot, shows:

dev-disk-by\x2duuid-1e389607\x2d8cdf\x2d4ce7\x2dacfb\x2dccb7426a336b.swap loaded active active /dev/disk/by-uuid/1e389607-8cdf-4ce7-acfb-ccb7426a336b 

● dev-zram0.swap masked active active /dev/zram0 

The first line is the swap partition. Unfortunately the zram swap has not gone according to swapon --show:

NAME TYPE SIZE USED PRIO 
/dev/sda2 partition 2G 0B -2 
/dev/zram0 partition 995.2M 0B 5
slightly_toasted avatar
bd flag
Try running `swapoff /dev/zram0` before the steps in my answer. Does zram0 still show up as swap?
mbrampton avatar
jp flag
The zram0 swapping was already swapoffed when I ran the commands - I turn it off after a reboot.
Score:2
jp flag

As with so many things, the answer is simple once you have found it! Although it took me quite a while to get there. The critical file has a name specific to Armbian and it needs to be edited:

# sudo vim /etc/default/armbian-zram-config

A few lines down the file, uncomment the line that says SWAP=false:

# Zram swap enabled by default, unless set to disabled
SWAP=false

Reboot, and the zram swap is gone.

Score:0
bd flag

The /dev/zram0 swap could be managed by systemd, which is why it keeps reappearing on reboot.

Try finding the .swap unit:

systemctl --type swap

Once found, you can mask it:

sudo systemctl mask "dev-XYZ.swap"

Then reboot.

mbrampton avatar
jp flag
Thanks. I've added a response in the question, because comments don't seem able to have any format.
mangohost

Post an answer

Most people don’t grasp that asking a lot of questions unlocks learning and improves interpersonal bonding. In Alison’s studies, for example, though people could accurately recall how many questions had been asked in their conversations, they didn’t intuit the link between questions and liking. Across four studies, in which participants were engaged in conversations themselves or read transcripts of others’ conversations, people tended not to realize that question asking would influence—or had influenced—the level of amity between the conversationalists.