Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Resume Hook (Hibernation) #41

Merged
merged 6 commits into from
Nov 4, 2023
Merged

Resume Hook (Hibernation) #41

merged 6 commits into from
Nov 4, 2023

Conversation

loadfred
Copy link
Contributor

  • Added resume hook
  • Also added resume to docs and readme
  • Not for swap files, only for swap partitions

Uses resolve_device for the resume variable in config. Then uses printf and stat to get major:minor numbers of the partition and puts that into /sys/power/resume.
Works with my luks/lvm kiss linux with swap partition under luks/lvm (resumes after luks password is entered). Should work for any other swap setup (except swap files).

@illiliti
Copy link
Owner

I would do copy_exec printf too since printf can be implemented as a command and not available as shell builtin. Also I afraid we can't afford to use stat. Its interface is not portable because not all implementations have compatible flags. Therefore we need a different way to derive major:minor numbers from a devnode and luckily there is such way: read -r dev < /sys/class/block/<basename of devnode>/dev. With it you don't even need printf, but to be honest I'm not sure if it's usable at all. Would you mind to test if it works for you?

@loadfred
Copy link
Contributor Author

To get the basename I got the original device with readlink. And instead of using read to put the major:minor into another variable, I just used cat to place it in /sys/power/resume. Also, instead of having the readlink in a separate variable I could have used: cat /sys/class/block/$(basename $(readlink "$device"))/dev > /sys/power/resume.
Both methods work with no errors, I just didn't use basename because it was one more program to copy_exec.
It might be able to be simplier, I'm not sure.

@illiliti illiliti merged commit de2d6ae into illiliti:master Nov 4, 2023
sighook added a commit to zeppe-lin/mkinitramfs that referenced this pull request Jan 19, 2024
... also reduces copy_exec dependencies.

Thanks to @loadfred & @illiliti:
illiliti/tinyramfs#41
@loadfred loadfred deleted the resume-hook branch February 7, 2024 21:49
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants