Some clarification on Hibernate needed

I am just posting this because I thought that since Hibernate saves the system’s state, it would save data from applications and reopen them when I booted the machine back up, like sleep does. But when I set up Hibernation on my machine it seems to just power off, does some strange stuff to audio that a standard shutdown does not, and when I power it back up, and acts like I just booted it up from a shutdown and does not save applications. Is this exactly what it’s supposed to do? I am just trying to figure out if there is even a problem before I try to fix it.

Thanks

No.

Do so. Maybe this helps:

journalctl --boot -1 | sed -n -r "/Starting.+Hibernate/,/Finished.+Hibernate/p"

The output is:

Apr 17 23:00:05 Jakelinux-Framework systemd[1]: Starting Hibernate...
Apr 17 23:00:05 Jakelinux-Framework kernel: PM: Image not found (code -16)
Apr 17 23:00:06 Jakelinux-Framework systemd-sleep[3663]: Entering sleep state 'hibernate'...
Apr 17 23:00:06 Jakelinux-Framework kernel: PM: hibernation: hibernation entry

And the output of swapon is:

NAME      TYPE SIZE USED PRIO
/swapfile file  20G   0B   -2

Well the swap disk cannot be found.

Check the config files, which you edited for hibernation.

  • /etc/default/grub
  • /etc/mkinitcpio.conf
GRUB_DEFAULT=saved
GRUB_TIMEOUT=5
GRUB_TIMEOUT_STYLE=hidden
GRUB_DISTRIBUTOR="Manjaro"
GRUB_CMDLINE_LINUX_DEFAULT="quiet apparmor=1 security=apparmor udev.log_priority=3"
GRUB_CMDLINE_LINUX=""

#If you want to enable the save default function, uncomment the following
#line, and set GRUB_DEFAULT to saved.
GRUB_SAVEDEFAULT=true

#Preload both GPT and MBR modules so that they are not missed
GRUB_PRELOAD_MODULES="part_gpt part_msdos"

#Uncomment to enable booting from LUKS encrypted devices
#GRUB_ENABLE_CRYPTODISK=y

#Uncomment to use basic console
GRUB_TERMINAL_INPUT=console

#Uncomment to disable graphical terminal
#GRUB_TERMINAL_OUTPUT=console

#The resolution used on graphical terminal
#note that you can use only modes which your graphic card supports via VBE
#you can see them in real GRUB with the command 'videoinfo'
GRUB_GFXMODE=auto

#Uncomment to allow the kernel use the same resolution used by grub
GRUB_GFXPAYLOAD_LINUX=keep

#Uncomment if you want GRUB to pass to the Linux kernel the old parameter
#format "root=/dev/xxx" instead of "root=/dev/disk/by-uuid/xxx"
#GRUB_DISABLE_LINUX_UUID=true

#Uncomment to disable generation of recovery mode menu entries
GRUB_DISABLE_RECOVERY=true

#Uncomment this option to enable os-prober execution in the grub-mkconfig command
GRUB_DISABLE_OS_PROBER=false

#Uncomment and set to the desired menu colors.  Used by normal and wallpaper
#modes only.  Entries specified as foreground/background.
GRUB_COLOR_NORMAL="light-gray/black"
GRUB_COLOR_HIGHLIGHT="green/black"

#Uncomment one of them for the gfx desired, a image background or a gfxtheme
#GRUB_BACKGROUND="/usr/share/grub/background.png"
GRUB_THEME="/usr/share/grub/themes/manjaro/theme.txt"

#Uncomment to get a beep at GRUB start
#GRUB_INIT_TUNE="480 440 1"

#Uncomment to ensure that the root filesystem is mounted read-only so that
#systemd-fsck can run the check automatically. We use 'fsck' by default, which
#needs 'rw' as boot parameter, to avoid delay in boot-time. 'fsck' needs to be
#removed from 'mkinitcpio.conf' to make 'systemd-fsck' work.
#See also Arch-Wiki: https://wiki.archlinux.org/index.php/Fsck#Boot_time_checking
#GRUB_ROOT_FS_RO=true

When pasting terminal output, add three backticks ` OR 3 tilde ~ above and below the text:

text

I did it this time for you. Please do it like this in the future.

Thank you :bowing_man:

You didn’t set any hibernation parameter, so no wonder that it does not work.

Short steps:

I am using a swap file, do those steps you linked to still apply because it references a swap partition?

Ah I see… it needs this:

# $uuid
findmnt -no UUID -T /swapfile
# $offset
filefrag -v /swapfile | awk '{ if($1=="0:"){print substr($4, 1, length($4)-2)} }'
resume=UUID=$uuid resume_offset=$offset

Everything else is the same. Hope you are not using BTRFS or LUKS, that needs more.

1 Like

I just went through a lot of googling to figure out if I was using BTRFS or not because I saw /etc/default/grub-btrfs/
and panicked, because I saw in all the guides to setting up swap that BTRFS needs more steps, that I did not take, then I finally figured out what file system I am running, and it’s ext4.

I’m sorry, what am I supposed to do with the offset? I don’t think that the other link mentions it.

Please read this here then: https://wiki.archlinux.org/title/Power_management/Suspend_and_hibernate#Hibernation_into_swap_file

Add it to the kernel parameter at grub.

So I did all the steps, and it still doesn’t work, and the logs give me the same errors. So I must have done the steps wrong, in /etc/default/grub, do I need to get rid of the “” around what I am supposed to add?

@jake3 Please show both files:

Did you run this:

and reboot the system?

GRUB_TIMEOUT=5
GRUB_TIMEOUT_STYLE=hidden
GRUB_DISTRIBUTOR="Manjaro"
GRUB_CMDLINE_LINUX_DEFAULT="quiet apparmor=1 security=apparmor udev.log_priority=3"
GRUB_CMDLINE_LINUX="resume=UUID=f6898bf0-f23e-4f8c-8f59-2b16eaa17936"

# If you want to enable the save default function, uncomment the following
# line, and set GRUB_DEFAULT to saved.
GRUB_SAVEDEFAULT=true

# Preload both GPT and MBR modules so that they are not missed
GRUB_PRELOAD_MODULES="part_gpt part_msdos"

# Uncomment to enable booting from LUKS encrypted devices
#GRUB_ENABLE_CRYPTODISK=y

# Uncomment to use basic console
GRUB_TERMINAL_INPUT=console

# Uncomment to disable graphical terminal
#GRUB_TERMINAL_OUTPUT=console

# The resolution used on graphical terminal
# note that you can use only modes which your graphic card supports via VBE
# you can see them in real GRUB with the command 'videoinfo'
GRUB_GFXMODE=auto

# Uncomment to allow the kernel use the same resolution used by grub
GRUB_GFXPAYLOAD_LINUX=keep

# Uncomment if you want GRUB to pass to the Linux kernel the old parameter
# format "root=/dev/xxx" instead of "root=/dev/disk/by-uuid/xxx"
#GRUB_DISABLE_LINUX_UUID=true

# Uncomment to disable generation of recovery mode menu entries
GRUB_DISABLE_RECOVERY=true

# Uncomment this option to enable os-prober execution in the grub-mkconfig command
GRUB_DISABLE_OS_PROBER=false

# Uncomment and set to the desired menu colors.  Used by normal and wallpaper
# modes only.  Entries specified as foreground/background.
GRUB_COLOR_NORMAL="light-gray/black"
GRUB_COLOR_HIGHLIGHT="green/black"

# Uncomment one of them for the gfx desired, a image background or a gfxtheme
#GRUB_BACKGROUND="/usr/share/grub/background.png"
GRUB_THEME="/usr/share/grub/themes/manjaro/theme.txt"

# Uncomment to get a beep at GRUB start
#GRUB_INIT_TUNE="480 440 1"

# Uncomment to ensure that the root filesystem is mounted read-only so that
# systemd-fsck can run the check automatically. We use 'fsck' by default, which
# needs 'rw' as boot parameter, to avoid delay in boot-time. 'fsck' needs to be
# removed from 'mkinitcpio.conf' to make 'systemd-fsck' work.
# See also Arch-Wiki: https://wiki.archlinux.org/index.php/Fsck#Boot_time_checking
#GRUB_ROOT_FS_RO=true
# MODULES
# The following modules are loaded before any boot hooks are
# run.  Advanced users may wish to specify all system modules
# in this array.  For instance:
#     MODULES=(piix ide_disk reiserfs)
MODULES=""

# BINARIES
# This setting includes any additional binaries a given user may
# wish into the CPIO image.  This is run last, so it may be used to
# override the actual binaries included by a given hook
# BINARIES are dependency parsed, so you may safely ignore libraries
BINARIES=()

# FILES
# This setting is similar to BINARIES above, however, files are added
# as-is and are not parsed in any way.  This is useful for config files.
FILES=""

# HOOKS
# This is the most important setting in this file.  The HOOKS control the
# modules and scripts added to the image, and what happens at boot time.
# Order is important, and it is recommended that you do not change the
# order in which HOOKS are added.  Run 'mkinitcpio -H <hook name>' for
# help on a given hook.
# 'base' is _required_ unless you know precisely what you are doing.
# 'udev' is _required_ in order to automatically load modules
# 'filesystems' is _required_ unless you specify your fs modules in MODULES
# Examples:
##   This setup specifies all modules in the MODULES setting above.
##   No raid, lvm2, or encrypted root is needed.
#    HOOKS=(base)
#
##   This setup will autodetect all modules for your system and should
##   work as a sane default
#    HOOKS=(base udev autodetect block filesystems)
#
##   This setup will generate a 'full' image which supports most systems.
##   No autodetection is done.
#    HOOKS=(base udev block filesystems)
#
##   This setup assembles a pata mdadm array with an encrypted root FS.
##   Note: See 'mkinitcpio -H mdadm' for more information on raid devices.
#    HOOKS=(base udev block mdadm encrypt filesystems)
#
##   This setup loads an lvm2 volume group on a usb device.
#    HOOKS=(base udev block lvm2 filesystems)
#
##   NOTE: If you have /usr on a separate partition, you MUST include the
#    usr, fsck and shutdown hooks.
HOOKS="base udev resume autodetect modconf block keyboard keymap consolefont filesystems fsck"

# COMPRESSION
# Use this to compress the initramfs image. By default, gzip compression
# is used. Use 'cat' to create an uncompressed image.
#COMPRESSION="gzip"
#COMPRESSION="bzip2"
#COMPRESSION="lzma"
#COMPRESSION="xz"
#COMPRESSION="lzop"
#COMPRESSION="lz4"
#COMPRESSION="zstd"

# COMPRESSION_OPTIONS
# Additional options for the compressor
#COMPRESSION_OPTIONS=()

I ran that command and I hibernated the system, like they said in the thread, since I just realized that they are not the same thing, I am going to go do that now.

well now there is a change, I can no longer try to hibernate, I am not given that option when I press the meta key

Is it now a partition or a swapfile? If it is a swapfile then you missed the offset which i mentioned.

Ok I have not explained that because it was self-explained for me:

  • mkinitcpio -P → create a new init linux image
  • update-grub → recreates a new grub boot menu

So on a reboot the new parameter will be set on the new linux image.

its a swapfile, I just put the offset number at /sys/power/resume_offset

or at least, I thought I had, I just checked and its back to 0

Ok, I just checked after running that command again, and resume_offset keeps getting set back to 0 after I reboot?

Set it on GRUB_CMDLINE_LINUX_DEFAULT= instead. Otherwise there must something wrong with the config.