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.

    • theshatterstone54@feddit.ukOP
      link
      fedilink
      arrow-up
      3
      ·
      5 months ago

      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.

  • dingdongitsabear@lemmy.ml
    link
    fedilink
    arrow-up
    5
    ·
    edit-2
    5 months ago

    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.

  • Björn Tantau@swg-empire.de
    link
    fedilink
    arrow-up
    3
    ·
    5 months ago

    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.ukOP
      link
      fedilink
      arrow-up
      1
      ·
      5 months ago

      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
        link
        fedilink
        arrow-up
        1
        ·
        5 months ago

        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.

  • HarriPotero@lemmy.world
    link
    fedilink
    arrow-up
    1
    ·
    edit-2
    5 months ago

    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.