Systemd-swap : btrfs : Not enough swap space for hibernation

I am trying to setup systemd-swap with this Guide. Everything looks good, but I still can’t hibernate my system.

Service is running:

sudo systemctl status systemd-swap                                                                                                                                                                  
● systemd-swap.service - Manage swap spaces on zram, files and partitions.
     Loaded: loaded (/usr/lib/systemd/system/systemd-swap.service; enabled; preset: disabled)
     Active: active (running) since Mon 2023-03-27 19:29:58 CEST; 5min ago
   Main PID: 6245 (systemd-swap)
     Status: "Monitoring memory status..."
      Tasks: 1 (limit: 36991)
     Memory: 265.6M
        CPU: 359ms
     CGroup: /system.slice/systemd-swap.service
             └─6245 /usr/bin/python3 -u /usr/bin/systemd-swap start

Mär 27 19:29:58 t14 systemd-swap[6245]: INFO: Load: /etc/systemd/swap.conf.d/swap.conf
Mär 27 19:29:58 t14 systemd-swap[6245]: INFO: Removing working directory...
Mär 27 19:29:58 t14 systemd-swap[6245]: INFO: Removing files in /var/lib/systemd-swap/swapfc/...
Mär 27 19:29:58 t14 systemd-swap[6245]: INFO: Removed /var/lib/systemd-swap/swapfc/1
Mär 27 19:29:58 t14 systemd-swap[6245]: INFO: Load: /etc/systemd/swap.conf.d/swap.conf
Mär 27 19:29:58 t14 systemd-swap[6245]: INFO: Writing destroy info...
Mär 27 19:29:58 t14 systemd-swap[6245]: INFO: swapD: pick up devices from systemd-gpt-auto-generator
Mär 27 19:29:58 t14 systemd-swap[6245]: INFO: swapD: searching swap devices
Mär 27 19:29:58 t14 systemd-swap[6245]: INFO: swapFC: allocate chunk:  1
Mär 27 19:29:58 t14 systemd[1]: Started Manage swap spaces on zram, files and partitions..

File is created:

free                                                                                                                                                                                         
              gesamt       benutzt     frei      gemns.  Puffer/Cache verfügbar
Speicher:      30847        2596       23407         103        4843       27705
Swap:            255           0         255

This is my config:

nano /etc/systemd/swap.conf.d/swap.conf
zswap_enabled=0
zram_enabled=0
swapfc_enabled=1
swapfc_min_count=1

If I try to hibernate, I get:

systemctl hibernate                                                                                                                                                                         
Call to Hibernate failed: Not enough swap space for hibernation

My file system is btrfs. I read there is some special handling required. What else I have to do?

Please help in resolving the issue

Welcome to the forum!

256 MiB is by far not enough swap space for hibernating the system. You need at least 150% the size of your RAM, because it’ll have to hold whatever you had in RAM plus whatever you already had in swap.

In your case, given that you’ve got 32 GiB of RAM, 100% should probably be enough, so you’ll need a swap file of 32 GiB in size — or use a dedicated swap partition, which is faster.

2 Likes

Please head over to the wiki especially the section “How much swap do I need?”

(it’s also the first hit on google for “Manjaro swap”)

:bowing_man:

2 Likes

@Aragorn and @Fabby The Guide says: “It can create swap files dynamically based on memory needs.” I expected disk space will be dynamiclly taken. Is this sentence wrong or do I understand it wrong?

@Fabby I don’t use google and I know about the size of my RAM and the theoretical size of my swap file.

Sure I can setup a dedicated swap partition, but I would like to find a solution for the “dynamic systemd-swap”. It sounds interesting to me.

If I am totally on the wrong way, then say it and I will set up a dedicated partition.

There is no document about systemd-swap whether it supports hibernation. Then it would not be recommended for hibernation.

1 Like

With this approach, you will not be able to hibernate.

Yet, you refuse to act like it

It can create swap files dynamically in a running system, but that is a different thing to hibernating your system. For hibernation, the size of the swap device must be statically assigned first.

2 Likes

I didn’t know there is a difference between swap and swap for hibernation. Thank you for the information. I will set up a dedicated partition or a use a pre allocated swap file.

@Aragorn You said a dedicated partition is faster. Will I really feel the difference between swap partition and swap file in the SSD time?

You use Btrfs, Swap partition is recommend and is neutral for Btrfs.
Btrfs balance has the known issue with Swapfile.

3 Likes

Thank you for the help.

Now I set up a dedicated swap partition, hibernation works but I have some issues.

My computer needs around 2:15 minutes to show me a login screen after hibernation. I think this is too long Any Ideas how to solve the problem or make it faster? Btw. When I hibernate it has been just Firefox opened and less than 2GB in RAM used.

If I shut down after hibernation, my display gets black at the normal time, but power led is still showing up for more than 3 minutes.

My configuration

/etc/fstab
UUID=945d52c8-8279-46c1-992c-e223f6b60918 /swap          swap    defaults 0 0
/etc/default/grub  
GRUB_CMDLINE_LINUX_DEFAULT="quiet splash udev.log_priority=3 resume=UUID=945d52c8-8279-46c1-992c-e223f6b60918"
/etc/mkinitcpio.conf
HOOKS="base udev autodetect modconf block keyboard keymap consolefont plymouth filesystems resume"

Every computer wakes up from suspend faster than from hibernation, because suspend does not put everything into its hard disk, but current working state remains in RAM.

I checked the power consumption of my PC: suspend vs. hibernation, the difference is only 2 - 3 watts. That’s when I use suspend the most.

If you leave your computer for more than 1 day without shutdown, then choose hibernation.


If online download is running, then you should not enable suspend or hibernation until complete download, otherwise both will abort the download.

Never use suspend or hibernation while kernel update is in progress of pacman.

1 Like

This topic was automatically closed 2 days after the last reply. New replies are no longer allowed.