You are not logged in.

#1 2016-04-10 11:33:48

calavoow
Member
Registered: 2016-04-10
Posts: 3

[Solved] Systemctl Hibernate Swap Header Not Found

Hello Arch Forums,

I've recently installed Arch according to the wiki for a fully encrypted filesystem (https://wiki.archlinux.org/index.php/Dm … _with_LUKS) and followed the page to set up hibernation using a swapfile on an encrypted filesystem (https://wiki.archlinux.org/index.php/Dm … _swap_file). However, when I run `systemctl hibernate` the system momentarily looks to power down but starts up immediately after. I would like to be able to hibernate my laptop so that the data on it is encrypted when I close the lid to move around.

When I run `dmesg` I find  the error Swap header not found:

[   24.525481] wlp3s0: deauthenticating from 00:1f:3f:d5:56:c1 by local choice (Reason: 3=DEAUTH_LEAVING)
[   24.663960] PM: Hibernation mode set to 'platform'
[   24.665463] PM: Syncing filesystems ... done.
[   24.688057] Freezing user space processes ... (elapsed 0.001 seconds) done.
[   24.689373] PM: Marking nosave pages: [mem 0x00000000-0x00000fff]
[   24.689376] PM: Marking nosave pages: [mem 0x0009c000-0x0009cfff]
[   24.689377] PM: Marking nosave pages: [mem 0x0009e000-0x000fffff]
[   24.689379] PM: Marking nosave pages: [mem 0x20000000-0x201fffff]
[   24.689387] PM: Marking nosave pages: [mem 0x40004000-0x40004fff]
[   24.689388] PM: Marking nosave pages: [mem 0xcf346000-0xcf346fff]
[   24.689389] PM: Marking nosave pages: [mem 0xcf355000-0xcf356fff]
[   24.689391] PM: Marking nosave pages: [mem 0xcf366000-0xcf366fff]
[   24.689392] PM: Marking nosave pages: [mem 0xd01d0000-0xd03d1fff]
[   24.689400] PM: Marking nosave pages: [mem 0xd6a0b000-0xdaffefff]
[   24.689632] PM: Marking nosave pages: [mem 0xdb000000-0xffffffff]
[   24.690163] PM: Basic memory bitmaps created
[   24.690210] PM: Preallocating image memory... done (allocated 168995 pages)
[   24.938719] PM: Allocated 675980 kbytes in 0.24 seconds (2816.58 MB/s)
[   24.938722] Freezing remaining freezable tasks ... (elapsed 0.001 seconds) done.
[   24.940123] Suspending console(s) (use no_console_suspend to debug)
[   25.390514] PM: freeze of devices complete after 450.394 msecs
[   25.403477] PM: late freeze of devices complete after 12.955 msecs
[   25.406564] PM: noirq freeze of devices complete after 3.072 msecs
[   25.406942] ACPI: Preparing to enter system sleep state S4
[   25.543225] ACPI : EC: EC stopped
[   25.543225] PM: Saving platform NVS memory
[   25.543888] Disabling non-boot CPUs ...
[   25.564284] smpboot: CPU 1 is now offline
[   25.584337] smpboot: CPU 2 is now offline
[   25.600974] smpboot: CPU 3 is now offline
[   25.601545] PM: Creating hibernation image:
[   25.865265] PM: Need to copy 167677 pages
[   25.865269] PM: Normal pages needed: 167677 + 1024, available pages: 1883143
[   26.323904] PM: Hibernation image created (167677 pages copied)
[   25.602881] PM: Restoring platform NVS memory
[   25.603082] ACPI : EC: EC started
[   25.603467] Enabling non-boot CPUs ...
[   25.603530] x86: Booting SMP configuration:
[   25.603531] smpboot: Booting Node 0 Processor 1 APIC 0x1
[   25.607056]  cache: parent cpu1 should not be sleeping
[   25.685219] CPU1 is up
[   25.685251] smpboot: Booting Node 0 Processor 2 APIC 0x2
[   25.688339]  cache: parent cpu2 should not be sleeping
[   25.768519] CPU2 is up
[   25.768543] smpboot: Booting Node 0 Processor 3 APIC 0x3
[   25.771292]  cache: parent cpu3 should not be sleeping
[   25.848517] CPU3 is up
[   25.851146] ACPI: Waking up from system sleep state S4
[   26.001937] thinkpad_acpi: EC reports that Thermal Table has changed
[   26.101975] PM: noirq thaw of devices complete after 0.169 msecs
[   26.115604] PM: early thaw of devices complete after 13.608 msecs
[   26.116482] rtc_cmos 00:02: System wakeup disabled by ACPI
[   26.145203] tpm_tis 00:05: TPM is disabled/deactivated (0x6)
[   26.435178] ata1: SATA link up 6.0 Gbps (SStatus 133 SControl 300)
[   26.446516] ata1.00: ACPI cmd ef/02:00:00:00:00:a0 (SET FEATURES) succeeded
[   26.446520] ata1.00: ACPI cmd f5/00:00:00:00:00:a0 (SECURITY FREEZE LOCK) filtered out
[   26.466508] ata1.00: ACPI cmd ef/02:00:00:00:00:a0 (SET FEATURES) succeeded
[   26.466512] ata1.00: ACPI cmd f5/00:00:00:00:00:a0 (SECURITY FREEZE LOCK) filtered out
[   26.476483] PM: thaw of devices complete after 360.885 msecs
[   26.476918] ata1.00: configured for UDMA/133
[   26.488968] PM: writing image.
[   26.489789] PM: Using 3 thread(s) for compression.
               PM: Compressing and saving image data (168005 pages)...
[   26.489811] PM: Image saving progress:   0%
[   26.637256] PM: Image saving progress:  10%
[   26.702875] PM: Image saving progress:  20%
[   26.794866] PM: Image saving progress:  30%
[   26.881008] PM: Image saving progress:  40%
[   26.967017] PM: Image saving progress:  50%
[   27.063591] PM: Image saving progress:  60%
[   27.157465] PM: Image saving progress:  70%
[   27.234620] PM: Image saving progress:  80%
[   27.290830] PM: Image saving progress:  90%
[   27.357455] PM: Image saving progress: 100%
[   27.512105] PM: Image saving done.
[   27.512114] PM: Wrote 672020 kbytes in 1.02 seconds (658.84 MB/s)
[   27.512503] PM: S
[   27.514563] PM: Swap header not found!
[   27.514568] |
[   27.578138] PM: Basic memory bitmaps freed
[   27.578147] Restarting tasks ... done.
[   27.712122] e1000e: enp0s25 NIC Link is Down

My `lsblk -f` looks as follows:

NAME          FSTYPE      LABEL UUID                                 MOUNTPOINT
sda                                                                  
├─sda1        vfat              091B-BF50                            /boot
└─sda2        crypto_LUKS       fccddb3a-626e-48a8-b6e6-e824075e9c92 
  └─cryptroot ext4              c09e48d7-08d4-47ca-810b-fc375af13972 /

And `/etc/default/grub`

GRUB_DEFAULT=0
GRUB_TIMEOUT=5
GRUB_DISTRIBUTOR="Arch"
GRUB_CMDLINE_LINUX_DEFAULT="resume=UUID=c09e48d7-08d4-47ca-810b-fc375af13972 resume_offset=2146304 quiet"
GRUB_CMDLINE_LINUX=""

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

# Uncomment to enable Hidden Menu, and optionally hide the timeout count
#GRUB_HIDDEN_TIMEOUT=5
#GRUB_HIDDEN_TIMEOUT_QUIET=true

# 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 `vbeinfo'
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 and set to the desired menu colors.  Used by normal and wallpaper 
# modes only.  Entries specified as foreground/background.
#GRUB_COLOR_NORMAL="light-blue/black"
#GRUB_COLOR_HIGHLIGHT="light-cyan/blue"

# Uncomment one of them for the gfx desired, a image background or a gfxtheme
#GRUB_BACKGROUND="/path/to/wallpaper"
#GRUB_THEME="/path/to/gfxtheme"

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

#GRUB_SAVEDEFAULT="true"

Which I've written to `/boot/grub/grub.cfg`using `grub-mkconfig`.

Where `resume_offset` is decided by running according to the wiki

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

which outputs

2146304..

The output of `swapon -s` is

Filename				Type		Size	Used	Priority
/swapfile                              	file    	8388604	0	-1

All of which looks okay. I'm not sure if its necessary to have a swap that large, but my memory is also 8G so just to be sure I made my swapfile the same size.

Finally, my `mkinitcpio.conf` looks as follows:

# vim:set ft=sh
# 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 autodetect modconf block encrypt resume filesystems keyboard 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_OPTIONS
# Additional options for the compressor
#COMPRESSION_OPTIONS=""

This hopefully also correctly executes the resume hook only after system has been decrypted.

Any ideas on how to resolve or debug this issue and hibernate my laptop?

Last edited by calavoow (2016-04-14 20:50:18)

Offline

#2 2016-04-10 13:51:10

Spider.007
Member
Registered: 2004-06-20
Posts: 1,175

Re: [Solved] Systemctl Hibernate Swap Header Not Found

Can you provide us with the output from

$ cat /proc/cmdline

It will confirm the parameters are passed to the kernel correctly

Offline

#3 2016-04-10 15:28:47

calavoow
Member
Registered: 2016-04-10
Posts: 3

Re: [Solved] Systemctl Hibernate Swap Header Not Found

Of course, here:

$ cat /proc/cmdline
initrd=\initramfs-linux.img cryptdevice=UUID=fccddb3a-626e-48a8-b6e6-e824075e9c92:cryptroot root=/dev/mapper/cryptroot

Offline

#4 2016-04-11 13:12:50

Spider.007
Member
Registered: 2004-06-20
Posts: 1,175

Re: [Solved] Systemctl Hibernate Swap Header Not Found

The resume_offset setting isn't present in that output; so somehow that didn't work out

Last edited by Spider.007 (2016-04-11 13:14:16)

Offline

#5 2016-04-13 11:15:30

calavoow
Member
Registered: 2016-04-10
Posts: 3

Re: [Solved] Systemctl Hibernate Swap Header Not Found

You were right so I dug deeper and solved the issue. It turns out it wasn't reading linux parameters from GRUB, because I use an UEFI boot with systemd-boot. Which for me is configured in `/boot/loader/entries/arch-encrypted.conf`. The following config succesfully hibernated and resumed:

title Arch Linux Encrypted
linux /vmlinuz-linux
initrd /initramfs-linux.img
options cryptdevice=UUID=fccddb3a-626e-48a8-b6e6-e824075e9c92:cryptroot root=/dev/mapper/cryptroot resume=/dev/mapper/cryptroot resume_offset=2146304 quiet

Offline

Board footer

Powered by FluxBB