path: root/initramfs-init.in
diff options
authorStefan Wagner <stw@bit-strickerei.de>2016-10-30 14:18:30 +0100
committerNatanael Copa <ncopa@alpinelinux.org>2016-11-28 17:35:04 -0200
commitf59f0ae6f9e4ac56dbb2c6f12dfb5251d974565d (patch)
tree6cf8f79987f1ec98a9011d642ab71147a819756b /initramfs-init.in
parent35937348a5b5cec5705e2a8defe5245d9ff8fa7b (diff)
mkinitfs: add support for resume
This patch tries to add resume from hibernation (aka suspend to disk) support to mkinitfs. The swap partition can be provided via the resume option. The default Alpine Linux kernel has no hibernation support compiled in, so a custom kernel is needed in order to use this. Some links on the topic: * https://wiki.gentoo.org/wiki/Custom_Initramfs/Hibernation * https://git.archlinux.org/mkinitcpio.git/tree/hooks/resume
Diffstat (limited to 'initramfs-init.in')
1 files changed, 13 insertions, 4 deletions
diff --git a/initramfs-init.in b/initramfs-init.in
index 50dc844..64b1b5b 100755
--- a/initramfs-init.in
+++ b/initramfs-init.in
@@ -263,7 +263,7 @@ set -- $(cat /proc/cmdline)
myopts="alpine_dev autodetect autoraid chart cryptroot cryptdm debug_init
dma init_args keep_apk_new modules ovl_dev pkgs quiet root_size root
usbdelay ip alpine_repo apkovl alpine_start splash blacklist
- overlaytmpfs rootfstype rootflags nbd"
+ overlaytmpfs rootfstype rootflags nbd resume"
for opt; do
case "$opt" in
@@ -371,16 +371,25 @@ if [ -n "$KOPT_root" ]; then
ebegin "Mounting root"
+ nlplug-findfs $cryptopts -p /sbin/mdev $KOPT_root
+ if [ -n "$KOPT_resume" ]; then
+ echo "Resume from disk"
+ if [ -e /sys/power/resume ]; then
+ printf "%d:%d" $(stat -Lc "0x%t 0x%T" "$KOPT_resume") >/sys/power/resume
+ else
+ echo "resume: no hibernation support found"
+ fi
+ fi
if [ "$KOPT_overlaytmpfs" = "yes" ]; then
mkdir -p /media/root-ro /media/root-rw $sysroot/media/root-ro \
- nlplug-findfs $cryptopts -p /sbin/mdev $KOPT_root \
- && mount -o ro $KOPT_root /media/root-ro
+ mount -o ro $KOPT_root /media/root-ro
mount -t tmpfs root-tmpfs /media/root-rw
mkdir -p /media/root-rw/work /media/root-rw/root
mount -t overlay -o lowerdir=/media/root-ro,upperdir=/media/root-rw/root,workdir=/media/root-rw/work overlayfs $sysroot
- nlplug-findfs $cryptopts -p /sbin/mdev $KOPT_root
mount ${KOPT_rootfstype:+-t} ${KOPT_rootfstype} \
-o ${KOPT_rootflags:-ro} \
$KOPT_root $sysroot