Skip to content

Commit

Permalink
Resume Hook (Hibernation) (#41)
Browse files Browse the repository at this point in the history
* hook/resume: hibernation support

* doc/*: added resume to docs

* readme: added resume to readme

* hook/resume: replaced stat

* hook/resume/resume.init: shellcheck fix

---------

Co-authored-by: Fred Loader <[email protected]>
  • Loading branch information
loadfred and Fred Loader authored Nov 4, 2023
1 parent 0679dbe commit de2d6ae
Show file tree
Hide file tree
Showing 5 changed files with 37 additions and 0 deletions.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
8 changes: 8 additions & 0 deletions doc/tinyramfs.5
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
6 changes: 6 additions & 0 deletions doc/tinyramfs.5.scd
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,12 @@ lvm_tag

The tag of your LVM logical volume.

## RESUME

resume

The location of your swap partition.

## ZFS

zfs_key
Expand Down
8 changes: 8 additions & 0 deletions hook/resume/resume
Original file line number Diff line number Diff line change
@@ -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
14 changes: 14 additions & 0 deletions hook/resume/resume.init
Original file line number Diff line number Diff line change
@@ -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

0 comments on commit de2d6ae

Please sign in to comment.