git.iko.soy/typeable/nixpkgs
on master help sign in
nixos stage-1: wait for devices during resumption attempt

Also a microimprovement -- use `test -n` instead of `test -e` since we have already checked that the file exists.

commit986a40421a94528c55531719fb382160292c7e16 authorNikolay Amiantov <ab@fmap.me> dateMon 8 Aug 2016, 01:35 (10 years ago) parent3ae468e
1 file changed+9−7
nixos/modules/system/boot/stage-1-init.sh+9−7
nixos/modules/system/boot/stage-1-init.sh+9−7
@@ -346,7 +346,7 @@ waitDevice() {
346346}
347347
348348
349−# Try to resume - all modules are loaded now, and devices exist
349+# Try to resume - all modules are loaded now.
350350if test -e /sys/power/tuxonice/resume; then
351351 if test -n "$(cat /sys/power/tuxonice/resume)"; then
352352 echo 0 > /sys/power/tuxonice/user_interface/enabled
@@ -355,7 +355,7 @@ if test -e /sys/power/tuxonice/resume; then
355355fi
356356
357357if test -e /sys/power/resume -a -e /sys/power/disk; then
358− if test -n "@resumeDevice@"; then
358+ if test -n "@resumeDevice@" && waitDevice "@resumeDevice@"; then
359359 resumeDev="@resumeDevice@"
360360 resumeInfo="$(udevadm info -q property "$resumeDev" )"
361361 else
@@ -364,14 +364,16 @@ if test -e /sys/power/resume -a -e /sys/power/disk; then
364364 # https://bugs.launchpad.net/ubuntu/+source/pm-utils/+bug/923326/comments/1
365365 # when there are multiple swap devices, we can't know where the hibernate
366366 # image will reside. We can check all of them for swsuspend blkid.
367− resumeInfo="$(test -e "$sd" && udevadm info -q property "$sd")"
368− if [ "$(echo "$resumeInfo" | sed -n 's/^ID_FS_TYPE=//p')" = "swsuspend" ]; then
369− resumeDev="$sd"
370− break
367+ if waitDevice "$sd"; then
368+ resumeInfo="$(udevadm info -q property "$sd")"
369+ if [ "$(echo "$resumeInfo" | sed -n 's/^ID_FS_TYPE=//p')" = "swsuspend" ]; then
370+ resumeDev="$sd"
371+ break
372+ fi
371373 fi
372374 done
373375 fi
374− if test -e "$resumeDev"; then
376+ if test -n "$resumeDev"; then
375377 resumeMajor="$(echo "$resumeInfo" | sed -n 's/^MAJOR=//p')"
376378 resumeMinor="$(echo "$resumeInfo" | sed -n 's/^MINOR=//p')"
377379 echo "$resumeMajor:$resumeMinor" > /sys/power/resume 2> /dev/null || echo "failed to resume..."