How to enable hibernation with refind boot manager

I’ve successfully installed Cachy OS, the first time I try a arch based distro.

The only remaining issue to solve is how to hibernate.
I’ve researched a little before asking.

I’m using refind boot manager.
My setup is:

  • a partition for /boot/efi
  • another one for /boot
  • another one for swap, it has the same size as physical RAM.
  • the root partition: LUKS + btrfs. It is ciphered.

I don’t know how to specify the resume hook to initramfs.

Is it easy to change boot manager without reinstalling everything?

You do not need to switch boot managers to unlock resume functionality. It is boot manager agnostic. See Power management/Suspend and hibernate - ArchWiki

OK, with GRUB I know how to activate hibernation and with systemd boot, but don’t find how to do it with refind.

If you mean adding the kernel cmdline to the boot options, refer to Boot Manager Configuration | CachyOS.

2 Likes

Thanks to your answer it’s been easy.

1 Like

could you eventually help me on this one, I have similar setup. Except I want to swap into file, instead of a swap partition. Is it even possible with zram? Some say yes, some nope. So idk, and I did not manage to make it work.

Getting this response…

sudo systemctl hibernate
Call to Hibernate failed: Not enough suitable swap space for hibernation available on compatible block devices and file systems

Despite having free space available:

free
               total        used        free      shared  buff/cache   available
Mem:        65152244     5042780    58679440      198608     2245776    60109464
Swap:       70254588           0    70254588

A year ago with Pop OS! based on Ubuntu 22.04, I wasn’t able to hibernate to file inside an encrypted btrfs partitiion. With a separated swap partition, hibernation ran smoothly.

How much RAM do you have?
Swap file size should about the same size than phisIcal RAm.

1 Like

@xetra have a look what Archwikisites @naim did link

1 Like

Thank you @hotte, I did for multiple hours, and I dont understand it. So confusing to me.

I have around 2 gigs more than RAM.

Mem:        65152244 
Swap:       70254588
❯ zramctl 
NAME       ALGORITHM DISKSIZE DATA COMPR TOTAL STREAMS MOUNTPOINT
/dev/zram0 zstd           67G   4K   62B   20K      16 [SWAP]
❯ swapon --show
NAME       TYPE      SIZE USED PRIO
/dev/zram0 partition  67G   0B  100
❯ systemctl hibernate 
Call to Hibernate failed: Not enough suitable swap space for hibernation available on compatible block devices and file systems

@xetra
hi mate, what is your intention, what do you want to realize ?
you write

I want to swap into file, instead of a swap partition.

on cachyOS that’s by default zram
to see it, just run swapon -s
also have a look here
and here

but if you want to hibernate, a swap partition is required normally

Thanks for reply :slight_smile:

Yes, I want to hibernate. So its not possible to make hibernation work with swap file, only with swap partition?

guess that’s reality

1 Like

Thx my friend, gonna make a swap partition then :upside_down_face:

1 Like

I have not tried it yet but there is no reason why a swap file should not work with zram.

  1. See Power management/Suspend and hibernate - ArchWiki
    According to GitHub - 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. it is complicated, but that git might not be up-to-date.
  2. Adding a swap file in btrfs takes some additional steps, see
    Swapfile — BTRFS documentation
    swap - Can I have a swapfile on btrfs? - Ask Ubuntu
    Wie erstelle ich ein /swap subvolume nachträglich in Btrfs? - #7 by dalto - EOS Deutsch - EndeavourOS
  3. If it really doesn’t work with zram, switching to zswap is another option

Also consider that zram is a compressed space that is set to use the whole ram. zram compresses by a higher ration then lzo / lz4 and the ratio can go up to 5 (Zram - LinuxReviews). You need to allocate enough space for your swap partition/file.
Further Reading: Power management/Suspend and hibernate - ArchWiki