From b2207538e0ed5ffa1c2c44497118e5e661b54d57 Mon Sep 17 00:00:00 2001 From: Fred Loader <16803702-frealo@user.noreply.gitlab.com> Date: Fri, 15 Sep 2023 13:37:39 -0400 Subject: [PATCH 1/5] hook/resume: hibernation support --- hook/resume/resume | 7 +++++++ hook/resume/resume.init | 12 ++++++++++++ 2 files changed, 19 insertions(+) create mode 100644 hook/resume/resume create mode 100644 hook/resume/resume.init diff --git a/hook/resume/resume b/hook/resume/resume new file mode 100644 index 0000000..3e34ea4 --- /dev/null +++ b/hook/resume/resume @@ -0,0 +1,7 @@ +# vim: set ft=sh: +# shellcheck shell=sh +# +# https://shellcheck.net/wiki/SC2154 +# shellcheck disable=2154 + +copy_exec stat diff --git a/hook/resume/resume.init b/hook/resume/resume.init new file mode 100644 index 0000000..b59a62f --- /dev/null +++ b/hook/resume/resume.init @@ -0,0 +1,12 @@ +# vim: set ft=sh: +# shellcheck shell=sh +# +# https://shellcheck.net/wiki/SC2154 +# shellcheck disable=2154 + +resolve_device "$resume" + +if [ -n "$device" ]; then + printf '%u:%u\n' $(stat -L -c '0x%t 0x%T' "$device") > /sys/power/resume || \ + panic "failed to resume" +fi From f5fd266225fce386d8657bc5b946864cd57ba578 Mon Sep 17 00:00:00 2001 From: Fred Loader <16803702-frealo@user.noreply.gitlab.com> Date: Fri, 15 Sep 2023 14:23:59 -0400 Subject: [PATCH 2/5] doc/*: added resume to docs --- doc/tinyramfs.5 | 8 ++++++++ doc/tinyramfs.5.scd | 6 ++++++ 2 files changed, 14 insertions(+) diff --git a/doc/tinyramfs.5 b/doc/tinyramfs.5 index f93ffa1..250b4c7 100644 --- a/doc/tinyramfs.5 +++ b/doc/tinyramfs.5 @@ -144,6 +144,14 @@ lvm_tag The tag of your LVM logical volume.\& .P .RE +.SS RESUME +.P +resume +.P +.RS 4 +The location of your swap partition.\& +.P +.RE .SS ZFS .P zfs_key diff --git a/doc/tinyramfs.5.scd b/doc/tinyramfs.5.scd index ea81ce6..c892218 100644 --- a/doc/tinyramfs.5.scd +++ b/doc/tinyramfs.5.scd @@ -103,6 +103,12 @@ lvm_tag The tag of your LVM logical volume. +## RESUME + +resume + + The location of your swap partition. + ## ZFS zfs_key From 584fb16daf719e4aece213f7ad4e101f1f811a37 Mon Sep 17 00:00:00 2001 From: Fred Loader <16803702-frealo@user.noreply.gitlab.com> Date: Fri, 15 Sep 2023 14:27:59 -0400 Subject: [PATCH 3/5] readme: added resume to readme --- README.md | 1 + 1 file changed, 1 insertion(+) diff --git a/README.md b/README.md index 66f78ed..becd4a6 100644 --- a/README.md +++ b/README.md @@ -11,6 +11,7 @@ Tiny initramfs written in POSIX shell - ZFS + native encryption support - LUKS (detached header, key), LVM - mdev, mdevd, eudev, systemd-udevd +- Resume from swap partition ## Dependencies From 16cb52f730f29d4c3e37b75a836df130e392a5c3 Mon Sep 17 00:00:00 2001 From: Fred Loader <145092902+loadfred@users.noreply.github.com> Date: Wed, 27 Sep 2023 21:16:49 -0400 Subject: [PATCH 4/5] hook/resume: replaced stat --- hook/resume/resume | 3 ++- hook/resume/resume.init | 4 +++- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/hook/resume/resume b/hook/resume/resume index 3e34ea4..f4137f8 100644 --- a/hook/resume/resume +++ b/hook/resume/resume @@ -4,4 +4,5 @@ # https://shellcheck.net/wiki/SC2154 # shellcheck disable=2154 -copy_exec stat +copy_exec readlink +copy_exec cat diff --git a/hook/resume/resume.init b/hook/resume/resume.init index b59a62f..3d39f8e 100644 --- a/hook/resume/resume.init +++ b/hook/resume/resume.init @@ -7,6 +7,8 @@ resolve_device "$resume" if [ -n "$device" ]; then - printf '%u:%u\n' $(stat -L -c '0x%t 0x%T' "$device") > /sys/power/resume || \ + dev_link=$(readlink "$device") + + cat /sys/class/block/${dev_link##*/}/dev > /sys/power/resume || \ panic "failed to resume" fi From db911cf08cc2a8b3616e3fe10926f1461acb4f63 Mon Sep 17 00:00:00 2001 From: Fred Loader <145092902+loadfred@users.noreply.github.com> Date: Wed, 27 Sep 2023 22:28:15 -0400 Subject: [PATCH 5/5] hook/resume/resume.init: shellcheck fix --- hook/resume/resume.init | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/hook/resume/resume.init b/hook/resume/resume.init index 3d39f8e..2c3de5e 100644 --- a/hook/resume/resume.init +++ b/hook/resume/resume.init @@ -9,6 +9,6 @@ resolve_device "$resume" if [ -n "$device" ]; then dev_link=$(readlink "$device") - cat /sys/class/block/${dev_link##*/}/dev > /sys/power/resume || \ + cat /sys/class/block/"${dev_link##*/}"/dev > /sys/power/resume || \ panic "failed to resume" fi