Setting up a swap file on top of using swap-to-zram for Hibernation purposes? (Fedora 40)
from theshatterstone54@feddit.uk to linux@lemmy.ml on 04 Jun 20:08
https://feddit.uk/post/12891227

So here’s my situation:

I’m on Fedora 40 on a laptop and I’ve recently decided to add a Hibernate option to my own logout/powermenu script that I use. The script executes systemctl hibernate but there’s a problem. It didn’t seem to work. When I ran the above command in terminal, I got an error stating that there’s not enough suitable swap space for that. Turns out that I’m using swap-to-zram hence why Hibernate doesn’t work.

So, I decided to ask ChatGPT and it recommended creating a swapfile. I can do that no problem.

The thing is, if I’m using swap-to-zram, I concluded it is likely that if I’m making use of that swap-to-zram all the time, I will probably need a larger swapfile for the hibernation.

So I asked our AI overlords if there’s a risk in that. It said there isn’t any real risk, other than increased drive wear-and-tear and potential performance issues.

Dear Linux users of Lemmy, are there any issues or concerns I should be aware of before attempting something like this (running multiple types of swap simultaneously, excess swapfile space, etc.)? Thank you.

Edit: Not sure how relevant it is, seeing as I’m not asking about swap partitions, but I’ll mention using BTRFS, just in case. And no, I don’t know anything about it, I just know it has cool features I’m yet to start learning about.

#linux

threaded - newest

we_avoid_temptation@lemmy.zip on 04 Jun 20:28 next collapse

Can I suggest reading documentation instead of asking LLM’s that are routinely known to just make shit up?

wiki.archlinux.org/title/…/Suspend_and_hibernate says it’s possible with a swap file as the backing device but that swap to zram isn’t supported. I haven’t personally tried it though.

theshatterstone54@feddit.uk on 04 Jun 22:17 collapse

So it IS possible, as I already found out. If the Arch wiki isn’t saying things like “doing this can break your system” then it’s fine by me.

boredsquirrel@slrpnk.net on 04 Jun 20:41 next collapse

Ask on discussion.fedoraproject.org, there are many people doing similar things

bjoern_tantau@swg-empire.de on 04 Jun 23:46 next collapse

I mean, the swap file just has to be large enough to accommodate your system RAM. Everything in zram is already in system RAM, just compressed.

theshatterstone54@feddit.uk on 05 Jun 06:14 collapse

Okay, my concern was that if I have, say 1.4G in zram, that would unpack to, say, 2G, which, when added to 7G, would go over the 8G limit. I was worried that RAM might be saved in its uncompressed manner, when saved in the swapfile for hibernation.

gnuhaut@lemmy.ml on 05 Jun 16:06 collapse

I think the hibernation image is compressed by default (all of it). Also, some of what is in your RAM is just files from disk. I think those don’t need to be saved into the hibernation image, since they’re already on disk. For example, libc.so.6 would definitely be in RAM and in use, but it’s also on disk, so no need to save it during hibernate.

So the hibernation image should be substantially smaller than your used RAM.

dingdongitsabear@lemmy.ml on 05 Jun 15:04 next collapse

you need a swap file, a swap subvolume, or a swap partition that’s RAM + 50%, on account of zram. then you need systemd scripts that disable zram and enable swap on suspend and do the reverse on resume. also, you need some selinux tuning to allow you to write to said file. you have a detailed howto in Fedora Magazine.

stop using bullshitgpt.

edit: here’s the article.

HarriPotero@lemmy.world on 07 Jun 06:39 collapse

I’d only use zram if I had no swap device/file.

In my experience zswap performs better, and doesn’t get in the way of hibernation. In fact, most distros enable it by default today, and it doesn’t always work so great with zram.