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 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 diff --git a/hook/resume/resume b/hook/resume/resume new file mode 100644 index 0000000..f4137f8 --- /dev/null +++ b/hook/resume/resume @@ -0,0 +1,8 @@ +# vim: set ft=sh: +# shellcheck shell=sh +# +# https://shellcheck.net/wiki/SC2154 +# shellcheck disable=2154 + +copy_exec readlink +copy_exec cat diff --git a/hook/resume/resume.init b/hook/resume/resume.init new file mode 100644 index 0000000..2c3de5e --- /dev/null +++ b/hook/resume/resume.init @@ -0,0 +1,14 @@ +# vim: set ft=sh: +# shellcheck shell=sh +# +# https://shellcheck.net/wiki/SC2154 +# shellcheck disable=2154 + +resolve_device "$resume" + +if [ -n "$device" ]; then + dev_link=$(readlink "$device") + + cat /sys/class/block/"${dev_link##*/}"/dev > /sys/power/resume || \ + panic "failed to resume" +fi