Failed to hibernate system with swap file

Hi all!

I used this wiki page to enable hibernation on my encrypted systems. And I was able to get hibernation working on my laptop, but on my PC sadly I am not able to hibernate.
See following infos:

[kokko@endeavour ~]$ lsblk 
NAME                                          MAJ:MIN RM   SIZE RO TYPE  MOUNTPOINT
sda                                             8:0    0 223,6G  0 disk  
├─sda1                                          8:1    0   100M  0 part  
├─sda3                                          8:3    0     1K  0 part  
├─sda4                                          8:4    0   500M  0 part  
├─sda5                                          8:5    0 108,2G  0 part  
└─sda6                                          8:6    0   1,9G  0 part  [SWAP]
sdb                                             8:16   0 931,5G  0 disk  
└─sdb2                                          8:18   0 931,5G  0 part  
sdc                                             8:32   0   477G  0 disk  
├─sdc1                                          8:33   0   300M  0 part  /boot/efi
└─sdc2                                          8:34   0 476,7G  0 part  
  └─luks-211e4232-ac5f-4c73-9fa8-06d1de3bcea9 254:0    0 476,7G  0 crypt /
sr0                                            11:0    1  10,2M  0 rom   
[kokko@endeavour ~]$ swapon --show
NAME      TYPE      SIZE USED PRIO
/swapfile file       17G   0B   -2
/dev/sda6 partition 1,9G   0B   -3
free -h
              gesamt       benutzt     frei      gemns.  Puffer/Cache verfügbar
Speicher:        15Gi       1,5Gi        13Gi       136Mi       994Mi        13Gi
Swap:          18Gi          0B        18Gi

[kokko@endeavour ~]$ sudo systemctl hibernate
Failed to hibernate system via logind: Not enough swap space for hibernation
[kokko@endeavour ~]$

The main difference is that my laptop does only show 1 swap, whereas my PC has 2 (1 from ubuntu 1 from EOS).

Any ideas what I might have done wrong?

Cheers!

Hello @spacepig
Maybe this can help you?

https://wiki.archlinux.org/index.php/Power_management/Suspend_and_hibernate

Could you post your fstab?

cat /etc/fstab
1 Like

Thanks for your feedback!

Yes I know about that arch wiki-page. I am almost sure that I have it right, maybe there is some kind of typo somewhere down the lines.

Here is some more output

kokko@endeavour ~]$ sudo blkid
[sudo] Passwort für kokko: 
/dev/sda1: LABEL="System" UUID="D4F0C57FF0C56876" TYPE="ntfs" PARTUUID="6ebd551e-01"
/dev/sda4: LABEL="Recovery image" UUID="520EE7360EE711B1" TYPE="ntfs" PARTUUID="6ebd551e-04"
/dev/sda5: UUID="1d40cc53-032a-4696-9dc3-863df85352ae" TYPE="ext4" PARTUUID="6ebd551e-05"
/dev/sda6: UUID="38e73302-d834-441d-a90f-498f000266b9" TYPE="swap" PARTUUID="6ebd551e-06"
/dev/sdb2: UUID="6c30086b-f0cc-4d93-80a3-da30757e7131" TYPE="ext4" PARTUUID="fa81cfba-02"
/dev/sdc1: UUID="6C5C-97C5" TYPE="vfat" PARTUUID="12ae381d-89bd-b543-8007-e135ce094bff"
/dev/sdc2: UUID="211e4232-ac5f-4c73-9fa8-06d1de3bcea9" TYPE="crypto_LUKS" PARTUUID="0aae92da-0398-9149-943a-bdb755378690"
/dev/sr0: UUID="0a120a5c3135204e" LABEL="15 Nov 2019" TYPE="udf"
/dev/mapper/luks-211e4232-ac5f-4c73-9fa8-06d1de3bcea9: UUID="253a5831-4c44-4439-beea-f94c2cf09a76" TYPE="ext4"

[kokko@endeavour ~]$ cat /etc/fstab 

# /etc/fstab: static file system information.
#
# Use 'blkid' to print the universally unique identifier for a device; this may
# be used with UUID= as a more robust way to name devices that works even if
# disks are added and removed. See fstab(5).
#
# <file system>             <mount point>  <type>  <options>  <dump>  <pass>
UUID=38e73302-d834-441d-a90f-498f000266b9 swap           swap    defaults,noatime,discard 0 2
UUID=6C5C-97C5                            /boot/efi      vfat    umask=0077 0 2
/dev/mapper/luks-211e4232-ac5f-4c73-9fa8-06d1de3bcea9 /              ext4    defaults,noatime,discard 0 1
tmpfs                                     /tmp           tmpfs   defaults,noatime,mode=1777 0 0
/swapfile none swap defaults,pri=-2 0 0

etc/default/grub

GRUB_DEFAULT=0
GRUB_TIMEOUT=5
GRUB_DISTRIBUTOR="EndeavourOS"
GRUB_CMDLINE_LINUX_DEFAULT="quiet cryptdevice=UUID=211e4232-ac5f-4c73-9fa8-06d1de3bcea9:luks-211e4232-ac5f-4c73-9fa8-06d1de3bcea9 root=/dev/mapp>
GRUB_CMDLINE_LINUX=""

In /etc/mkinitcpio.conf I got

HOOKS="base udev autodetect modconf block keyboard keymap encrypt resume filesystems fsck"


and this here:

sudo filefrag -v /swapfile | awk '{if($1=="0:"){print $4}}'
337920..

When I look at journalctl I get this:

Jan 09 21:12:22 endeavour systemd-logind[521]: /sys/power/resume and /sys/power/resume_offset has no matching entry in /proc/swaps; Hibernation will fail: resume=8:6, resume_offset=337920

cat /sys/power/resume
8:6

cat /sys/power/resume_offset
337920

cat /proc/swaps
Filename                                Type            Size    Used    Priority
/swapfile                               file            17825788        0       -2
/dev/sda6                               partition       1952764 0       -3

Does all that ring a bell to someone maybe?

https://wiki.archlinux.org/index.php/Dm-crypt/Swap_encryption#With_suspend-to-disk_support

/etc/fstab:

Try to get rid of your swap partition by commenting out the entry shown above. Your 17G swapfile should be enough. :wink:

sudo nano /etc/fstab

Reboot and report back.


If this doesn’t work you may first have to turn off all swap devices and files with swapoff -a, then edit fstab and delete entries, reboot and recreate your swapfile.

Good hint! But unfortunately this did not make any difference.

[kokko@endeavour ~]$ cat /etc/fstab 
# /etc/fstab: static file system information.
#
# Use 'blkid' to print the universally unique identifier for a device; this may
# be used with UUID= as a more robust way to name devices that works even if
# disks are added and removed. See fstab(5).
#
# <file system>             <mount point>  <type>  <options>  <dump>  <pass>
#UUID=38e73302-d834-441d-a90f-498f000266b9 swap           swap    defaults,noatime,discard 0 2
UUID=6C5C-97C5                            /boot/efi      vfat    umask=0077 0 2
/dev/mapper/luks-211e4232-ac5f-4c73-9fa8-06d1de3bcea9 /              ext4    defaults,noatime,discard 0 1
tmpfs                                     /tmp           tmpfs   defaults,noatime,mode=1777 0 0
/swapfile none swap defaults,pri=-2 0 0
[kokko@endeavour ~]$ swapon --show
NAME      TYPE SIZE USED PRIO
/swapfile file  17G   0B   -2
[kokko@endeavour ~]$ systemctl hibernate 
Failed to hibernate system via logind: Not enough swap space for hibernation

+journal
Jan 09 22:41:32 endeavour systemd-logind[514]: /sys/power/resume and /sys/power/resume_offset has no matching entry in /proc/swaps; Hibernation will fail: resume=8:6, resume_offset=337920

So this is the same as before. I’ll check my laptop for differences in the setup, maybe I ll find something.

@joekamprad
Thanks for the link, I’ll read this when I have a little more patience-

@spacepig
How much RAM does your machine have?

I intentionally gave Swap a little more spice :wink: I’d say Swap > Ram

MiB Ram:  15956,3 total
MiB Swap:  17408,0 total

Did you solve your issue?

I had the same as you and redoing the whole swapfile creation with dd giving it 1gb more like you did fixed it.

Do you have the swap partition in your /etc/default/grub GRUB_CMDLINE_LINUX_DEFAULT, how does your resume entry look like?