Skip to content

Support for resuming from swap file on the LUKS encrypted root #345

@DmytroSytnyk

Description

@DmytroSytnyk

Problem

Current version of ugrd ( ugrd-2.0.2 ) is not able to handle resuming from hibernate image located in swap file on the LUKS encrypted root partition (tested with swap file residing in the separate btrfs subvolume).
Normal image generation process works as expected in the case of normal booting (not resuming) but fails if the system is booted from the hibernated state.

The issue occurs on Gentoo with recent kernel (tested with gentoo-sources-6.16.4 and secure boot enabled).
Content of /etc/ugrd/config.toml:

modules = [
"ugrd.fs.resume",
]
kmod_autodetect_lspci = true

Image is generated using the sys-kernel/installkernel hook by invoking the usual make install from /us/src/linux.
Encrypted root and swap file within are created in accordance with BTRFS recommendations using the guide from Encrypted Root with LUKS and Opal.

Proper boot resume and resume_offset command-line options are supplied through the kernel config variable CONFIG_CMDLINE.

After booting from hibernated state the process get stuck inside handle_resume() portion of the image script informing that Resume device is not found.

Manual solution

Override the content of ugrd/fs/resume.toml by the following:

[imports.init_mount]
"ugrd.fs.resume" = [ "handle_resume" ]

[import_order.after]
handle_resume = "set_root_subvol"

[import_order.before]
handle_resume = "mount_root"

needed to make sure that the handle_resume() is called after the root partition was unlocked.

After regeneration of initramfs image the system is able to properly resume from the hibernated state.

More permanent fix would require implementation of the logic necessary to detect that the swap is located in file on the encrypted root.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions