Zram, Zswap, Swap, and Hibernation

Hello! I have been looking into enabling hibernation. Have discovered that Bazzite uses Zram to do active compression in RAM as swap. From what I have been reading it should be possible to have both Zram and a traditional swap at the same time, with the Zram taking priority, and then setting up things in grub such that when hibernating the swap is used (for obvious reasons) I have also heard of a tool called "zram-hibernate" that automates the setup process. Is there some reason that this is not considered possible with Bazzite? I would really like to use Zram for normal use, then a dedicated swap partition for only hibernate.
75 Replies
CaramelCorn
CaramelCorn3w ago
EDIT: <answer that didn't solve the problem>
ETHREAL1
ETHREAL1OP3w ago
that disables zram
CaramelCorn
CaramelCorn3w ago
you're so correct
ETHREAL1
ETHREAL1OP3w ago
also brings up something called Zswap, also it would appear that Zram now has a "config_zram_writeback" command that seems to be what I'm after possibly?
iMightBeSpyduck
Yes this is possible you need setup secondary swap that will be used for hibernation.
ETHREAL1
ETHREAL1OP3w ago
but needs to be a partition, not file
iMightBeSpyduck
Is your pqrtition encrypted?
iMightBeSpyduck
Using Swap for Additional Memory or Hibernation - Bazzite Documenta...
Bazzite is a custom image built upon Fedora Atomic Desktops that brings the best of Linux gaming to all of your devices.
ETHREAL1
ETHREAL1OP3w ago
I'm assuming you mean partition, as in boot? home? no, but it is on the "look into" list, still in my evaluation stages again, disables zram
iMightBeSpyduck
Just dont diaable zram as mentioned in guide
ETHREAL1
ETHREAL1OP3w ago
so.... I would make a swap (how would I do that as a partition? as the included "disks" does not seem to offer a way to do this) add it to the FStable, then tell zram to use it as wrightback? do I need to do anything in Grub (ugh)
iMightBeSpyduck
You can make partition swap or to file. It's up to you. config_zram_writeback is for something else and not for hibernation
ETHREAL1
ETHREAL1OP3w ago
ok so just make the swap and add to fstable?
iMightBeSpyduck
Yes. You will use zram most of the time. Until it get full which is almost never and swap will be used for hibernation
ETHREAL1
ETHREAL1OP3w ago
This does not seem to work, made a swap partition, set it all up, tested a hibernate by simply leaving a few windows open like discord, dolphin, so on, and it did not work. here is a swapon output on the matter;
NAME TYPE SIZE USED PRIO
/dev/zram0 partition 4G 0B 100
/dev/sdb4 partition 32.2G 0B -2
NAME TYPE SIZE USED PRIO
/dev/zram0 partition 4G 0B 100
/dev/sdb4 partition 32.2G 0B -2
so my assumption is that the entire "systemd is smart enough to use swap for hibernation and ignore zram" is not true for Bazzite my suspicion that it is still using at least in part the zram for hibernation is to blame, opening Brave, it seems to know it was not closed properly last start,
iMightBeSpyduck
you should check dmesg to see why it failed ujust logs-last-boot
ETHREAL1
ETHREAL1OP3w ago
anything in particular I should be searching for since the log is like 3000+ lines....
iMightBeSpyduck
look for hibernation, you can limit it to only show kernel messages sudo journalctl --no-hostname -k -b -1
iMightBeSpyduck
similar to these
No description
ETHREAL1
ETHREAL1OP3w ago
there are only a few lines that even mention the word;
Oct 29 07:24:46 kernel: CPU topo: Rejected CPUs 16
Oct 29 07:24:46 kernel: PM: hibernation: Registered nosave memory: [mem 0x00000000-0x00000fff]
Oct 29 07:24:46 kernel: PM: hibernation: Registered nosave memory: [mem 0x000a0000-0x000fffff]
Oct 29 07:24:46 kernel: PM: hibernation: Registered nosave memory: [mem 0x09d1f000-0x09ffffff]
Oct 29 07:24:46 kernel: PM: hibernation: Registered nosave memory: [mem 0x0a200000-0x0a20dfff]
Oct 29 07:24:46 kernel: PM: hibernation: Registered nosave memory: [mem 0xc3111000-0xc3111fff]
Oct 29 07:24:46 kernel: PM: hibernation: Registered nosave memory: [mem 0xc553e000-0xc56eefff]
Oct 29 07:24:46 kernel: PM: hibernation: Registered nosave memory: [mem 0xc883d000-0xc883dfff]
Oct 29 07:24:46 kernel: PM: hibernation: Registered nosave memory: [mem 0xca2dc000-0xcb9fefff]
Oct 29 07:24:46 kernel: PM: hibernation: Registered nosave memory: [mem 0xcd000000-0xffffffff]
Oct 29 07:24:46 kernel: [mem 0xd0000000-0xfe9fffff] available for PCI devices
Oct 29 07:24:46 kernel: CPU topo: Rejected CPUs 16
Oct 29 07:24:46 kernel: PM: hibernation: Registered nosave memory: [mem 0x00000000-0x00000fff]
Oct 29 07:24:46 kernel: PM: hibernation: Registered nosave memory: [mem 0x000a0000-0x000fffff]
Oct 29 07:24:46 kernel: PM: hibernation: Registered nosave memory: [mem 0x09d1f000-0x09ffffff]
Oct 29 07:24:46 kernel: PM: hibernation: Registered nosave memory: [mem 0x0a200000-0x0a20dfff]
Oct 29 07:24:46 kernel: PM: hibernation: Registered nosave memory: [mem 0xc3111000-0xc3111fff]
Oct 29 07:24:46 kernel: PM: hibernation: Registered nosave memory: [mem 0xc553e000-0xc56eefff]
Oct 29 07:24:46 kernel: PM: hibernation: Registered nosave memory: [mem 0xc883d000-0xc883dfff]
Oct 29 07:24:46 kernel: PM: hibernation: Registered nosave memory: [mem 0xca2dc000-0xcb9fefff]
Oct 29 07:24:46 kernel: PM: hibernation: Registered nosave memory: [mem 0xcd000000-0xffffffff]
Oct 29 07:24:46 kernel: [mem 0xd0000000-0xfe9fffff] available for PCI devices
Oct 29 14:25:02 systemd[1]: Stopped systemd-fsck-root.service - File System Check on Root Device.
Oct 29 14:25:02 systemd[1]: systemd-hibernate-clear.service - Clear Stale Hibernate Storage Info was skipped because of an unmet condition check (ConditionPathExists=/sys/firmware/efi/efivars/HibernateLocation-8cf2644b-4b0b-428f-9387-6d876050dc67).
Oct 29 14:25:02 systemd[1]: Starting systemd-journald.service - Journal Service...
Oct 29 14:25:02 systemd[1]: Stopped systemd-fsck-root.service - File System Check on Root Device.
Oct 29 14:25:02 systemd[1]: systemd-hibernate-clear.service - Clear Stale Hibernate Storage Info was skipped because of an unmet condition check (ConditionPathExists=/sys/firmware/efi/efivars/HibernateLocation-8cf2644b-4b0b-428f-9387-6d876050dc67).
Oct 29 14:25:02 systemd[1]: Starting systemd-journald.service - Journal Service...
Oct 29 14:25:06 systemd[1]: Starting modprobe@loop.service - Load Kernel Module loop...
Oct 29 14:25:06 systemd[1]: systemd-hibernate-clear.service - Clear Stale Hibernate Storage Info was skipped because of an unmet condition check (ConditionPathExists=/sys/firmware/efi/efivars/HibernateLocation-8cf2644b-4b0b-428f-9387-6d876050dc67).
Oct 29 14:25:06 systemd[1]: systemd-pcrmachine.service - TPM PCR Machine ID Measurement was skipped because of an unmet condition check (ConditionSecurity=measured-uki).
Oct 29 14:25:06 systemd[1]: Starting modprobe@loop.service - Load Kernel Module loop...
Oct 29 14:25:06 systemd[1]: systemd-hibernate-clear.service - Clear Stale Hibernate Storage Info was skipped because of an unmet condition check (ConditionPathExists=/sys/firmware/efi/efivars/HibernateLocation-8cf2644b-4b0b-428f-9387-6d876050dc67).
Oct 29 14:25:06 systemd[1]: systemd-pcrmachine.service - TPM PCR Machine ID Measurement was skipped because of an unmet condition check (ConditionSecurity=measured-uki).
Oct 29 14:25:06 systemd[1]: Starting modprobe@loop.service - Load Kernel Module loop...
Oct 29 14:25:06 systemd[1]: systemd-hibernate-clear.service - Clear Stale Hibernate Storage Info was skipped because of an unmet condition check (ConditionPathExists=/sys/firmware/efi/efivars/HibernateLocation-8cf2644b-4b0b-428f-9387-6d876050dc67).
Oct 29 14:25:06 systemd[1]: systemd-pcrmachine.service - TPM PCR Machine ID Measurement was skipped because of an unmet condition check (ConditionSecurity=measured-uki).
Oct 29 14:25:06 systemd[1]: Starting modprobe@loop.service - Load Kernel Module loop...
Oct 29 14:25:06 systemd[1]: systemd-hibernate-clear.service - Clear Stale Hibernate Storage Info was skipped because of an unmet condition check (ConditionPathExists=/sys/firmware/efi/efivars/HibernateLocation-8cf2644b-4b0b-428f-9387-6d876050dc67).
Oct 29 14:25:06 systemd[1]: systemd-pcrmachine.service - TPM PCR Machine ID Measurement was skipped because of an unmet condition check (ConditionSecurity=measured-uki).
Oct 29 14:25:07 systemd[1]: systemd-confext.service - Merge System Configuration Images into /etc/ was skipped because no trigger condition checks were met.
Oct 29 14:25:07 systemd[1]: systemd-hibernate-clear.service - Clear Stale Hibernate Storage Info was skipped because of an unmet condition check (ConditionPathExists=/sys/firmware/efi/efivars/HibernateLocation-8cf2644b-4b0b-428f-9387-6d876050dc67).
Oct 29 14:25:07 systemd[1]: systemd-hwdb-update.service - Rebuild Hardware Database was skipped because of an unmet condition check (ConditionNeedsUpdate=/etc).
Oct 29 14:25:07 systemd[1]: systemd-confext.service - Merge System Configuration Images into /etc/ was skipped because no trigger condition checks were met.
Oct 29 14:25:07 systemd[1]: systemd-hibernate-clear.service - Clear Stale Hibernate Storage Info was skipped because of an unmet condition check (ConditionPathExists=/sys/firmware/efi/efivars/HibernateLocation-8cf2644b-4b0b-428f-9387-6d876050dc67).
Oct 29 14:25:07 systemd[1]: systemd-hwdb-update.service - Rebuild Hardware Database was skipped because of an unmet condition check (ConditionNeedsUpdate=/etc).
iMightBeSpyduck
do one more with sudo journalctl --no-hostname -k -b -2 this will show boot before that
ETHREAL1
ETHREAL1OP3w ago
this looks like it used the 4GB of the Zram, and the spillover went to the swap partition, and thats why its only like ~1.5 GB thats what I suspect
iMightBeSpyduck
can you run systemctl list-unit-files | grep nvidia your GPU VRAM is not suspending properly
ETHREAL1
ETHREAL1OP3w ago
nvidia-hibernate.service enabled enabled
nvidia-persistenced.service disabled enabled
nvidia-powerd.service enabled enabled
nvidia-resume.service enabled enabled
nvidia-suspend-then-hibernate.service enabled enabled
nvidia-suspend.service enabled enabled
nvidia-hibernate.service enabled enabled
nvidia-persistenced.service disabled enabled
nvidia-powerd.service enabled enabled
nvidia-resume.service enabled enabled
nvidia-suspend-then-hibernate.service enabled enabled
nvidia-suspend.service enabled enabled
iMightBeSpyduck
there is also this error
Oct 29 07:30:32 kernel: PM: Image not found (code -16)
Oct 29 07:30:34 systemd-sleep[7025]: [Error] > An error occurred: [Errno 2] No such file or directory
Oct 29 07:30:32 kernel: PM: Image not found (code -16)
Oct 29 07:30:34 systemd-sleep[7025]: [Error] > An error occurred: [Errno 2] No such file or directory
you can probably try to add resume kernel parameter pointing to your swap partition. I have hibernation to swap file and didn't need to do it rpm-ostree kargs --append-if-missing="resume=UUID=4209c845-f495-4c43-8a03-5363dd433153" change UUID to your swap partition restart and try hibernation again
ETHREAL1
ETHREAL1OP3w ago
Nope, still does not wake from hibernation, But it does seem to be some other issue, even disabled ZRAM as a test and still nope But I would prefer using a swap partition than a file, especially since eventually I would like to consider encryption, With that all said, at this point I need to do other stuff, so don’t know when I will be available again Swap file also does not work, even with zram disabled.... so it would seem as though hibernation is just broken completely... I’m thinking there is just something wrong with how Bazzite does this… literally following there docs to a T, even on a completely fresh install, does not work… Spun up a Manjaro install off a USB drive, hibernate works perfectly…
iMightBeSpyduck
Works on my machine with AMD gpu maybe some nvidia related bug? Do you have same nvidia version of driver on manjaro? Also open/closed driver could make difference.
ETHREAL1
ETHREAL1OP3w ago
My Manjaro install uses the closed drivers, it can be changed but, with that said I would have to boot it up again to know the exact version, but as it was just installed I will assume the latest. Also how would this really be relevant as to my knowledge the NV drivers for Bazzite are baked into the immutable image, and can not be changed by the end user without breaking things.
antheas
antheas3w ago
Don't use a resume parameter
ETHREAL1
ETHREAL1OP3w ago
-# oh ya, for got to mention that broke the install, but before messing with any of this I made a disk image with Rescuzilla so. Do you have any thoughts on why Hibernation is just broken it seems?
antheas
antheas3w ago
What's broken about it Sometimes it doesn't work because drivers
ETHREAL1
ETHREAL1OP3w ago
It does not work at all, can follow the Bazzite doc exactly, but it never successfully wakes from hibernation, even on a completely fresh install of Bazzite
antheas
antheas3w ago
Yes Nvidia you're cooked Does it wake up forgetting you hibernated?
ETHREAL1
ETHREAL1OP3w ago
From what I can tell from logs it tries, but the image saved to the swap is broken, so it falls back to booting normally
antheas
antheas3w ago
The image saved is not broken The closed drivers are broken If the image was broken it would scrap it
ETHREAL1
ETHREAL1OP3w ago
OK… then why does using the closed driver on Manjaro work fine?
antheas
antheas3w ago
Because this week bazzite has a kernel where hibernation does not work On your device And next week Manjaro will have a kernel where hibernation does not work on your device
ETHREAL1
ETHREAL1OP3w ago
Ao it’s a temporary bug???
antheas
antheas3w ago
Because randomness because nobody tests hibernation Especially nvidia And especially on the closed driver Try the f43 image New kernel
ETHREAL1
ETHREAL1OP3w ago
Well I kinda need hibernation… I often have to go abroad for work, and just sleeping is not adequate, and need WOL… (MB does not support WOL from shutdown)
antheas
antheas3w ago
But you bought an Nvidia laptop
ETHREAL1
ETHREAL1OP3w ago
Desktop, Built
antheas
antheas3w ago
Why does the desktop need hibernation Sleep barely works on desktops
ETHREAL1
ETHREAL1OP3w ago
For WOL And for when doing long handbrake encodes it can hibernate to not lose transcoder output information
antheas
antheas3w ago
Also use the open driver
ETHREAL1
ETHREAL1OP3w ago
How on Bazzite??? To my knowledge that’s all baked into the immutable image and can not be changed
antheas
antheas3w ago
When you say closed what do you mean
ETHREAL1
ETHREAL1OP3w ago
The NV property drivers, VS the open source ones
antheas
antheas3w ago
Are you on the open kernel module? Arch wiki is wrong Does your image say open on it
ETHREAL1
ETHREAL1OP3w ago
Getting there, (test install on a SSHD, take a little to boot) bazzite-nvidia-open:stable
antheas
antheas3w ago
Here we go again SSHD and hibernation?
ETHREAL1
ETHREAL1OP3w ago
TEST ENVIRONMENT
antheas
antheas3w ago
It's the correct image
ETHREAL1
ETHREAL1OP3w ago
-# though what really sad is Bazzite on an SSHD is often faster than Windows on a gen 4 SSD... But I digress
iMightBeSpyduck
it works on my machine i have zram and swap enabled and it hibernate correctly.
antheas
antheas3w ago
That's because you have the resume parameter
iMightBeSpyduck
I don't have it
antheas
antheas3w ago
Well when I did the testing for that article it didn't work
ETHREAL1
ETHREAL1OP3w ago
Unfortunately the DGPU is the only GPU I have, so I cant test it without... Also as I kinda found earlier, if Zram can a normal swap can not be used, how hard would it be to implement Zswap? I have not looked into it basically at all but it seems to fill a similar role, just uses RAM as a cache for the swap. Also for either Zswap or a traditional swap, I would think it would be a good idea to make this all into a ujust script? So a simple ujust enable-hibernation would make a swap based on the RAM in the system, disable Zram, what not.
antheas
antheas3w ago
You cannot use zram for hibernation because ram is powered off
ETHREAL1
ETHREAL1OP3w ago
I know, I’m talking about Zswap, a different system entirely, does a similar role but must have an attached normal swap as well, when a hibernation is triggered Zswap apparently dumps all it’s ram cache into the swap as one would assume With that all said, there really shouldn’t be any reason why zram with some logic (that according to multiple sources not just arch) is present should make it so all ram content (including the zram) get dumped to the actual swap. I will need to spin up that Manjaro install and A. See if it’s already using zram, B. If it’s not if installing/enabling it still allows hibernation to work Everything I have been reading says that it’s entirely possible to have zram and a normal swap at the same time, and it will (depending on the ago of kernel and low level components) automatically use the swap for hibernation, skipping zram entirely, or by designating the swap that should be used for hibernation (the resume command listed earlier) but it would seem as though the components in Bazzite are not new enough, and the resume (probably do to immutable?) breaks… P.S. not trying to argue, just really want/need this to work, and it seems to be some bazzite issue Though the issue at the moment seems to be hibernation AT ALL… But ya from 4 different sources (including fadora docs) Zram and a normal swap used for hibernation are totally compatible… given the proper swap priorities are set… - fedora - Manjaro (also tested works fine first hand) - CashyOS - Ubuntu So this is definitely some Bazzite deficiency…
antheas
antheas3w ago
Same drivers and kernel version on any of them? Did you install the Nvidia drivers on fedora?
ETHREAL1
ETHREAL1OP3w ago
The only one I tested was Manjaro, it’s kernel 6.12 closed NV drivers. However I did just think of something, it is out of the box X11, wonder if wayland somehow breaks it???
antheas
antheas3w ago
could be but probably what it is is the kernel
ETHREAL1
ETHREAL1OP3w ago
When I have some time I can mess around with stuff, X11 VS wayland, open VS closed NV driver, different kernels… But with that all said, it is still odd that basic hibernation with zram disabled does not work on Bazzite for me… (Though would point out that Bazzite is on a more recent kernel? (6.17) So if anything shouldn’t it work better?)
antheas
antheas3w ago
The kernel devs get it right once a yeat Usually makes it to the lts The rest of the versions don't hibernate
ETHREAL1
ETHREAL1OP3w ago
Well then I cant use Bazzite...
antheas
antheas3w ago
Use manjaro
jim_p
jim_p2w ago
I'm getting the same issue on a fresh install all AMD rig.
iMightBeSpyduck
hmm only thing that could affect this I made on my system could be that I edited kernel arguments and fstab to fix systemd-remount-fs.service
jim_p
jim_p2w ago
I've read it could be be an IOMMU issue but no idea how to debug and trace the offending item to patch out, new to all this.

Did you find this page helpful?