You are not logged in.

#1 2022-08-01 13:55:08

ee_yunn
Member
Registered: 2020-06-25
Posts: 8

(Solved) luks root, hibernate into swapfile

Solved-- need to add resume to /etc/mkinitcpio.conf (:

Just reinstalled using archinstall with pretty much all default settings including luks encrypted root partition. I've hibernated into swapfile on this device before this fresh install, not sure where my mess up is. I noticed the wiki says "Note: When resuming from a swapfile the resume parameter must point to the unlocked/mapped device that contains the file system with the swap file" but I don't understand quite what that means (:

Goal is encrypt on lid close without needing to enter both decrypt pw & user pw (so I have lightdm autologin enabled atm). Tried arch-luks-suspend which seems to work but is auto decrypting on lid open w/o entering decrypt pw.

Hibernate appears to start successfully but open lid -> fresh boot. Error & configs--

$ sudo journalctl --since '60 minutes ago' | grep -i hibernation
Aug 01 08:16:58 mba kernel: PM: hibernation: Registered nosave memory: [mem 0x00000000-0x00000fff]
<repeats a bunch of times...>
Aug 01 08:17:29 mba kernel: PM: hibernation: hibernation entry
Aug 01 08:20:39 mba kernel: PM: hibernation: Registered nosave memory: [mem 0x00000000-0x00000fff]
<repeats a bunch of times...>
$ free -m
               total        used        free      shared  buff/cache   available
Mem:            7853        1927        4710         402        1214        5278
Swap:          26926           0       26926
$ cat /proc/swaps
Filename				Type		Size		Used		Priority
/swapfile                               file		23551996	0		-2
/dev/zram0                              partition	4020732		0		100
$ sudo cat /etc/crypttab
# Configuration for encrypted block devices.
# See crypttab(5) for details.

# NOTE: Do not list your root (/) partition here, it must be set up
#       beforehand by the initramfs (/etc/mkinitcpio.conf).

# <name>       <device>                                     <password>              <options>
# home         UUID=b8ad5c18-f445-495d-9095-c9ec4f9d2f37    /etc/mypassword1
# data1        /dev/sda3                                    /etc/mypassword2
# data2        /dev/sda5                                    /etc/cryptfs.key
# swap         /dev/sdx4                                    /dev/urandom            swap,cipher=aes-cbc-essiv:sha256,size=256
# vol          /dev/sdb7                                    none
#swap      /dev/zram0    /dev/urandom   swap,cipher=aes-cbc-essiv:sha256,size=256
$ cat /etc/fstab
# Static information about the filesystems.
# See fstab(5) for details.

# <file system> <dir> <type> <options> <dump> <pass>
# /dev/mapper/ainstsda2
UUID=d881fa22-ef02-4eeb-94f3-7c8c266073b9	/         	ext4      	rw,relatime	0 1

# /dev/sda1
UUID=362D-7E91      	/boot     	vfat      	rw,relatime,fmask=0022,dmask=0022,codepage=437,iocharset=ascii,shortname=mixed,utf8,errors=remount-ro	0 2

/swapfile none swap defaults 0 0
$ sudo blkid
/dev/sda2: UUID="f39f52e8-d245-4be4-b407-3f5ed8e10feb" TYPE="crypto_LUKS" PARTLABEL="primary" PARTUUID="27111824-98f3-4692-b252-b9158047b587"
/dev/sda1: UUID="362D-7E91" BLOCK_SIZE="512" TYPE="vfat" PARTLABEL="primary" PARTUUID="7196882e-8928-4418-8a2d-ea8041c8f8d0"
/dev/mapper/luksdev: UUID="d881fa22-ef02-4eeb-94f3-7c8c266073b9" BLOCK_SIZE="4096" TYPE="ext4"
/dev/zram0: LABEL="zram0" UUID="655f8a26-fbb9-4d67-9658-09a4735cd42c" TYPE="swap"
$ findmnt -no UUID -T /swapfile
d881fa22-ef02-4eeb-94f3-7c8c266073b9
sudo filefrag -v /swapfile | awk '$1=="0:" {print substr($4, 1, length($4)-2)}'
3934208
$ cat /boot/loader/entries/2022-07-31_13-23-42_linux.conf (commented sections are trying different resume='s...)
# Created by: archinstall
# Created on: 2022-07-31_13-23-42
title Arch Linux (linux)
linux /vmlinuz-linux
initrd /intel-ucode.img
initrd /initramfs-linux.img
#options cryptdevice=PARTUUID=27111824-98f3-4692-b252-b9158047b587:luksdev root=/dev/mapper/luksdev zswap.enabled=0 rw intel_pstate=no_hwp rootfstype=ext4 # no hib
#options cryptdevice=PARTUUID=27111824-98f3-4692-b252-b9158047b587:luksdev root=/dev/mapper/luksdev zswap.enabled=0 rw intel_pstate=no_hwp rootfstype=ext4 resume=/dev/mapper/luksdev resume_offset=3934208
#options cryptdevice=PARTUUID=27111824-98f3-4692-b252-b9158047b587:luksdev root=/dev/mapper/luksdev zswap.enabled=0 rw intel_pstate=no_hwp rootfstype=ext4 resume=UUID=d881fa22-ef02-4eeb-94f3-7c8c266073b9 resume_offset=3934208
#options cryptdevice=PARTUUID=27111824-98f3-4692-b252-b9158047b587:luksdev root=/dev/mapper/luksdev zswap.enabled=0 rw intel_pstate=no_hwp rootfstype=ext4 resume=/dev/sda2 resume_offset=3934208
#options cryptdevice=PARTUUID=27111824-98f3-4692-b252-b9158047b587:luksdev root=/dev/mapper/luksdev zswap.enabled=0 rw intel_pstate=no_hwp rootfstype=ext4 resume=UUID=f39f52e8-d245-4be4-b407-3f5ed8e10feb resume_offset=3934208
options cryptdevice=PARTUUID=27111824-98f3-4692-b252-b9158047b587:luksdev root=/dev/mapper/luksdev zswap.enabled=0 rw intel_pstate=no_hwp rootfstype=ext4 resume=/dev/mapper/luksdev-d881fa22-ef02-4eeb-94f3-7c8c266073b9 resume_offset=3934208
$ cat /etc/mkinitcpio.conf
MODULES=()
BINARIES=()
FILES=()
HOOKS=(base udev autodetect keyboard keymap modconf block encrypt filesystems fsck shutdown suspend)

Last edited by ee_yunn (2022-08-01 19:26:57)

Offline

#2 2022-08-01 14:33:57

Raynman
Member
Registered: 2011-10-22
Posts: 1,539

Re: (Solved) luks root, hibernate into swapfile

ee_yunn wrote:

I noticed the wiki says "Note: When resuming from a swapfile the resume parameter must point to the unlocked/mapped device that contains the file system with the swap file" but I don't understand quite what that means (:

That means you must use (in your case) /dev/mapper/luksdev and not PARTUUID=27111824-98f3-4692-b252-b9158047b587 aka /dev/sda2

HOOKS=(base udev autodetect keyboard keymap modconf block encrypt filesystems fsck shutdown suspend)

Did you mistype "resume" as "suspend" (I would expect errors from mkinitcpio) or is that some nonstandard hook?

Offline

#3 2022-08-01 15:08:15

frostschutz
Member
Registered: 2013-11-15
Posts: 1,647

Re: (Solved) luks root, hibernate into swapfile

In order to resume from a swap file, you have to provide the block device as well as the offset (first block) of the swap file (resume= and resume_offset=). If the resume device is encrypted and only available after entering passphrase, you would need to add the resume hook after the encrypt hook.

Note that when you change your initramfs, kernel parameter, suspend/resume configuration, you should do one more regular reboot first before attempting to hibernate with the new settings. Otherwise you might end up suspending to the old setting and then try to resume from the new setting, which is bound to fail.

Offline

#4 2022-08-01 19:29:08

ee_yunn
Member
Registered: 2020-06-25
Posts: 8

Re: (Solved) luks root, hibernate into swapfile

Did you mistype "resume" as "suspend" (I would expect errors from mkinitcpio) or is that some nonstandard hook?

That's a hook for arch-luks-suspend. Ty for the /dev/mapper/luksdev tip! Helped. Problem is solved now from the 2 comments (also needed resume hook in mkinitcpio.conf)

Last edited by ee_yunn (2022-08-01 19:29:59)

Offline

Board footer

Powered by FluxBB