gissf1 / zram-hibernate

Allows dynamic swap changes to activate disk-based storage as swap for hibernation support when a system typically uses only zram swap during normal operation.
Apache License 2.0
35 stars 3 forks source link

no valid swaps found. cannot suspend to disk. #7

Open ostasevych opened 2 months ago

ostasevych commented 2 months ago

Hi! I would like to enable hibernation on my laptop with Pop_OS! 22.04 installed.

So, my pre-requisites:

swapon -v
NAME       TYPE       SIZE USED PRIO
/dev/zram0 partition 15,5G   0B 1000

I tried to run your script and got errors:

./zram-hibernate -tn
[6435] creating tmpfile...
[6435] lock acquired.
awk: line 15: syntax error at or near ,
awk: line 20: syntax error at or near else
awk: line 23: syntax error at or near else
awk: line 26: syntax error at or near return
awk: line 30: syntax error at or near [
ensureDiskSwap(): Initial swap status...
[00:07:51] Used=4508M MemFree=10G SwapUsed=0K/15G Overcommit=0K
FATAL: no valid swaps found. cannot suspend to disk.

What should be fixed?

gissf1 commented 2 months ago

Those awk syntax errors are probably the initial problem. What does your system have for awk? Can you show the output of: awk --version ? Typically it expects GNU Awk, but it may work with others. The same errors can be seen in #6, so you may need to install gawk on your system.

"no valid swaps found" is usually because it didn't detect any non-zram swap, but the syntax errors above could cause a detection failure.

Also, do you have a resume= argument in your /proc/cmdline kernel command line? You can try reporting back the results of: cat /proc/cmdline Typically the resume= value is configured by editing your bootloader configuration (grub, systemd-boot, etc).

Some background information: As hibernation is "suspend to disk", the system needs to know where to read the system state from in order to resume the saved state on the next boot cycle. The resume= kernel parameter is how the kernel knows where to read the saved system state data. This script is able to see that parameter from your kernel command line. It can use the specified device/partition to configure your system and save the system state data accordingly before triggering hibernation.