Bonum Certa Men Certa

Messing With ZRAM Again Because IBM Software is Barely Possible to Document and Changes if You Do

Reprinted with permission from Ryan Farmer.

It turns out that when I was setting up Debian, I set up my “zram-generator” systemd configuration file wrong.



systemd is Hell because they never commit themselves to the idea that once you learn how to do anything with it, it will stay working, most of its components are full of bugs and security vulnerabilities, and many things replace something that some other part of the operating system was already doing a lot better.



I cringe every time I give it some new responsibility over my system, waiting for how it will go wrong. I would be using systemd-oomd to handle potential out-of-memory situations, but I’ve read so much about how it handles memory pressure bizarrely and worse than the kernel’s oom-killer, even with the Fedora defaults, that I figure I’ll just leave it alone unless it becomes “mandatory” at some point.



I hear (on Reddit) that systemd-oomd does crazy shit, like, “There are 32 GB of RAM in this system. 12 GB are in use. 20 GB are free. Let’s go on a murder spree and shut down some Chrome tabs and LibreOffice with unsaved work!”



ZRam is a compressed block device that you can use for a compressed swap file in memory. The idea isn’t a bad one, but IBM has made figuring out how to set it up unnecessarily painful because of course it is handled by systemd. You’d think setting up ZRam would be too simple for systemd to bring too much of its usual incompetence to, but nooooo.



Today I actually looked at zramctl and it told me the compression type was lzo-rle, not zstd as I wanted (and was the default on openSUSE and I’m sure that’s what it said when I set it up on Debian and started the service).



Whatever.



Looking around the Web, I found that I needed the line compression-algorithm = zstd in my /etc/systemd/zram-generator.conf file.



So I added it and rebooted, and checked sudo zramctl again and I had zstd compression. Yay!



But when I was looking at the manpage for “zram-generator”, it said that the method by which to specify the fraction of the size of RAM to use was obsolete.



zram-fraction = 1.00 does work, but it’s “obsolete”.



So now it tells me that the “current” way to do the same thing is zram-size=ram/x, where ram is the amount of ram and x is the amount to divide by.



So ram/2 would make the device half of RAM, ram/1 would make it all of your RAM, which is what I wanted.



So now my file looks like this:



# This config file enables a /dev/zram0 swap device with the following
# properties:
# * size: 50% of available RAM or 4GiB, whichever is less
# * compression-algorithm: kernel default
#
# This device’s properties can be modified by adding options under the
# `[zram0]` section, or disabled by removing the section header.
# Additional zram devices can be created by appending new `[zramX]`
# sections and setting the appropriate options for each device.
#
# See /usr/share/doc/systemd-zram-generator/zram-generator.conf.example
# and/or zram-generator.conf(5) for a list of available options.
[zram0]
zram-size=ram/1
compression-algorithm = zstd



I’m not exactly sure why IBM Red Hat keeps screwing around changing the way you do this. They make you memorize something only to make pointless changes to the way it’s done, but then the stupid thing doesn’t want to break existing setups, so they just say the old one is “obsolete”.



$ sudo zramctl
NAME ALGORITHM DISKSIZE DATA COMPR TOTAL STREAMS MOUNTPOINT
/dev/zram0 zstd 15.4G 4K 64B 4K 8 [SWAP]



At least this thing is finally set up right, I think.



They never let you get too sure that you did it right or it wouldn’t be “modern”.



As to the debate about zstd vs lzo-rle, they’re both decent choices.



I can see the logic of defaulting to either one, depending on who you think your users are.



If you have a multi-core x86 PC with lots of CPU performance to burn, zstd makes more sense because of higher compression ratios.



If you have some little ARM system that you bought down at the Micro-Center and don’t want to overload it, but still do want to use ZRam, lzo-rle is a respectable choice.



If anything, ZRam with zstd has gotten faster since the kernel developers have last updated the default and I suspect it deserves another look.

Recent Techrights' Posts

Slopwatch: Too Lazy to Write Real Articles, Offloading to Chatbots Instead (LLM Slop About "Linux")
The Web was already full of garbage before the LLM frenzy. Now it's even worse.
RMS 'Inauguration' in Montpellier (Government Administration) on January 20th
Happy hacking
Even Technical Articles and HowTos From UNIXMen Nowadays Seem to be LLM Slop
We've just permanently removed the RSS feed of UNIXMen
The FSF's 2024 End-of-Year Fundraiser Succeeds: Over $400k to Support Software Freedom
That's worth bringing up again because the SFC is trying to 'crash' this achievement of the FSF
[Meme] Fentanylware (TikTok) Banned in the United States, Next Up European Union (EU)
And the United Kingdom (UK)
President Biden is Right, "Free Press is Crumbling" and the United States Exports Its Media-Hostile Culture to Other Continents
perhaps Biden should pay closer attention to how Donald Trump-inspired Americans take their battles to other continents
 
Links 18/01/2025: Apple Getting Out of Hey Hi (AI) Slop (Too Much Misinformation), Chaffbots/Chatbots Try to Settle Copyright Infringement Lawsuits
Links for the day
What Fake News Sites Are Doing to GNU/Linux
The LLM slop about Linux serves two purposes
Links 18/01/2025: Microsofters Upset at Microsoft's Ridiculous Rebrands (Excuse for Massive Price Hikes), Chaffbot Company ('Open'AI) Faces More Lawsuits
Links for the day
Gemini Links 18/01/2025: Surge in Illnesses, ctags, and Gemsync
Links for the day
Over at Tux Machines...
GNU/Linux news for the past day
IRC Proceedings: Friday, January 17, 2025
IRC logs for Friday, January 17, 2025
Links 17/01/2025: TikTok Banned by the United Stated (SCOTUS Rejects Appeal)
Links for the day
Software Freedom Conservancy Inc (SFC) Makes It Obvious It's Just a Copycat Trying to Exploit or Leech Off the FSF's (and GNU's) Work
They swim next to the rich people (who "match")
Links 17/01/2025: Fentanylware (TikTok) Herds Its (Drug) Users Into Even More Harmful "Apps"
Links for the day
Guardian Digital, Inc (linuxsecurity.com) Uses Microsoft-Controlled Front Groups and LLM Slop in Order to Spread Microsoft-Directed Anti-Linux FUD
Microsoft garbage likely produced by Microsoft LLMs, spewing out Microsoft FUD
Likely Fake 'Article' About Linux Mint 22.1
BetaNews fired up its plagiarism machine (LLM)
Over at Tux Machines...
GNU/Linux news for the past day
IRC Proceedings: Thursday, January 16, 2025
IRC logs for Thursday, January 16, 2025
Links 16/01/2025: Conflicts, Overpopulation, and Software Patents
Links for the day
[Meme] Lock-down With DRM Server/s (in a Nutshell)
Companies like Microsoft and Apple have a 'God complex'
Thank You, London! There Was No Way to Still Reliably Host Gemini From Home (on a Raspberry Pi 4) Due to Scale
The only regret we've long had is that we hadn't made the move earlier
The Summit of Future (Kerala, 2025): Dr. Richard Stallman (RMS) to Give Keynote Talk
promotional video was uploaded
Richard Stallman's Talk This Coming Monday (European 'Tour')
bunch of talks in Europe
Total Lock-down Ambitions - Part II - Down to the Very Core, Including the Hardware (CPU, GPU, Peripherals, and More)
instead of distinguishing themselves and antagonising these broadly reviled "antifeatures", both Canonical and IBM decided to join Microsoft in advocating lockdown
FSF, Guardian of the GNU Project, to Reach $400,000 in Winter Fundraiser Ahead of 40th Anniversary
The GNU Project Turns 42 later this year
Links 16/01/2025: "Meduza, IRL" and the Clock is Ticking on TikTok in the US
Links for the day
Gemini Links 16/01/2025: Yesterday's Gone, The Hour of the Dragon by Robert E Howard
Links for the day
Computer Users Aren't Zoo Animals
Animals don't belong inside cages in zoos, either
Links 16/01/2025: Scale and Scope of Microsoft Layoffs Revealed (Two Waves of Layoffs in 2025 Already)
Links for the day
Gemini Links 16/01/2025: Meta Has a Pixelfed Problem and Space Time Scoping
Links for the day
Anti-Linux 'Articles' in linuxsecurity.com (Guardian Digital, Inc) Are Composed by Bots, Probably Microsoft's
linuxsecurity.com has become a mindless stream of LLM slop
"New Year, New Career"
published a few hours ago
Over at Tux Machines...
GNU/Linux news for the past day
IRC Proceedings: Wednesday, January 15, 2025
IRC logs for Wednesday, January 15, 2025