Powere management - make it conditional, enable on UEFI targets, else disabled

This commit is contained in:
Igor Pecovnik 2025-11-18 09:08:10 +01:00 committed by Igor
parent 23dc0cc27c
commit 39d6bc8148
3 changed files with 25 additions and 10 deletions

View File

@ -63,6 +63,11 @@ If you are unsure about the documentation then invoke `$ grep -r -A5 -B5 "BUILD_
- Values:
- yes: Include (default)
- no: Do NO include
- **POWER_MANAGEMENT_FEATURES** (boolean): Controls whether system sleep functionality (suspend, hibernate, hybrid sleep) is allowed on the built image.
- Values:
- yes: Enable power-management sleep features (allow systemd sleep modes)
- no: Disable all sleep modes (default), as suspend/hibernate are unstable
on most single-board computers
- **HAS_VIDEO_OUTPUT** ( boolean ): defines whether the system has video output such as eye candy, bootsplash, etc..
- Values:
- yes: Enable video-related configuration

View File

@ -10,6 +10,7 @@ declare -g SERIALCON="${SERIALCON:-tty1}" # Consistent serial console
declare -g UEFI_GRUB_TIMEOUT=${UEFI_GRUB_TIMEOUT:-3} # Default 3-seconds timeout for GRUB menu.
declare -g BOARD_FIRMWARE_INSTALL="-full" # Install full firmware for UEFI boards
declare -g DISTRO_GENERIC_KERNEL=no
declare -g POWER_MANAGEMENT_FEATURES=yes # Suspend and resume might work well in UEFI, elsewhere is disabled by default
case "${BRANCH}" in

View File

@ -35,16 +35,25 @@ function install_distribution_specific() {
truncate --size=0 "${SDCARD}"/etc/apt/apt.conf.d/20apt-esm-hook.conf
fi
# Add power management override
# suspend / resume is very fragile on most of those board - lets disable it system wide
mkdir -p "${SDCARD}/etc/systemd/sleep.conf.d"
cat <<- EOF > "${SDCARD}/etc/systemd/sleep.conf.d/00-disable.conf"
[Sleep]
AllowSuspend=no
AllowHibernation=no
AllowHybridSleep=no
AllowSuspendThenHibernate=no
EOF
# Add power-management override.
# Suspend / hibernate / hybrid-sleep are known to be unreliable or completely
# non-functional on the majority of single board computers due to incomplete
# vendor kernels, broken device drivers, or lack of proper firmware support.
# To avoid random lockups, data loss, or boards failing to wake up, we disable
# all systemd sleep modes by default.
# Users who understand the risks and have hardware that supports stable sleep
# states can re-enable them by setting:
# POWER_MANAGEMENT_FEATURES=yes
if [[ "${POWER_MANAGEMENT_FEATURES:-"no"}" != "yes" ]]; then
mkdir -p "${SDCARD}/etc/systemd/sleep.conf.d"
cat <<- EOF > "${SDCARD}/etc/systemd/sleep.conf.d/00-disable.conf"
[Sleep]
AllowSuspend=no
AllowHibernation=no
AllowHybridSleep=no
AllowSuspendThenHibernate=no
EOF
fi
# install our base-files package (this replaces the original from Debian/Ubuntu)
if [[ "${KEEP_ORIGINAL_OS_RELEASE:-"no"}" != "yes" ]]; then