stage-1: autodetect resume swap partitions
This commit is contained in:
parent
74f6be0e5f
commit
18bd9917ed
@ -168,9 +168,24 @@ if test -e /sys/power/tuxonice/resume; then
|
|||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if test -n "@resumeDevice@" -a -e /sys/power/resume -a -e /sys/power/disk; then
|
if test -e /sys/power/resume -a -e /sys/power/disk; then
|
||||||
echo "@resumeDevice@" > /sys/power/resume 2> /dev/null || echo "failed to resume..."
|
if test -n "@resumeDevice@"; then
|
||||||
echo shutdown > /sys/power/disk
|
resumeDev="@resumeDevice@"
|
||||||
|
else
|
||||||
|
for sd in @resumeDevices@; do
|
||||||
|
# Try to detect resume device. According to Ubuntu bug:
|
||||||
|
# https://bugs.launchpad.net/ubuntu/+source/pm-utils/+bug/923326/comments/1
|
||||||
|
# When there are multiple swap devices, we can't know where will hibernate
|
||||||
|
# image reside. We can check all of them for swsuspend blkid.
|
||||||
|
if [ "$(blkid -o value -s TYPE "$sd")" = "swsuspend" ]; then
|
||||||
|
resumeDev="$sd"
|
||||||
|
break
|
||||||
|
fi
|
||||||
|
done
|
||||||
|
fi
|
||||||
|
if test -n "$resumeDev"; then
|
||||||
|
echo "$resumeDev" > /sys/power/resume 2> /dev/null || echo "failed to resume..."
|
||||||
|
fi
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
|
||||||
|
@ -181,6 +181,9 @@ let
|
|||||||
inherit (config.boot.initrd) checkJournalingFS
|
inherit (config.boot.initrd) checkJournalingFS
|
||||||
preLVMCommands postDeviceCommands postMountCommands kernelModules;
|
preLVMCommands postDeviceCommands postMountCommands kernelModules;
|
||||||
|
|
||||||
|
resumeDevices = map (sd: if sd ? device then sd.device else "/dev/disk/by-label/${sd.label}")
|
||||||
|
(filter (sd: sd ? label || hasPrefix "/dev/" sd.device) config.swapDevices);
|
||||||
|
|
||||||
fsInfo =
|
fsInfo =
|
||||||
let f = fs: [ fs.mountPoint (if fs.device != null then fs.device else "/dev/disk/by-label/${fs.label}") fs.fsType fs.options ];
|
let f = fs: [ fs.mountPoint (if fs.device != null then fs.device else "/dev/disk/by-label/${fs.label}") fs.fsType fs.options ];
|
||||||
in pkgs.writeText "initrd-fsinfo" (concatStringsSep "\n" (concatMap f fileSystems));
|
in pkgs.writeText "initrd-fsinfo" (concatStringsSep "\n" (concatMap f fileSystems));
|
||||||
@ -220,13 +223,14 @@ in
|
|||||||
options = {
|
options = {
|
||||||
|
|
||||||
boot.resumeDevice = mkOption {
|
boot.resumeDevice = mkOption {
|
||||||
type = types.nullOr types.str;
|
type = types.str;
|
||||||
default = null;
|
default = "";
|
||||||
example = "8:2";
|
example = "/dev/sda3";
|
||||||
description = ''
|
description = ''
|
||||||
Device for manual resume attempt during boot, specified using
|
Device for manual resume attempt during boot. This should be used primarily
|
||||||
the device's major and minor number as
|
if you want to resume from file. Specify here the device where the file
|
||||||
<literal><replaceable>major</replaceable>:<replaceable>minor</replaceable></literal>.
|
resides. You should also use <varname>boot.kernelParams</varname> to specify
|
||||||
|
<literal><replaceable>resume_offset</replaceable></literal>.
|
||||||
'';
|
'';
|
||||||
};
|
};
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user