diff --git a/src/hibernate-resume/hibernate-resume-generator.c b/src/hibernate-resume/hibernate-resume-generator.c index b6495a2581..666cd52e47 100644 --- a/src/hibernate-resume/hibernate-resume-generator.c +++ b/src/hibernate-resume/hibernate-resume-generator.c @@ -64,20 +64,21 @@ static int process_resume(const HibernateInfo *info) { if (r < 0) return log_error_errno(r, "Failed to generate device unit name from path '%s': %m", info->device); - /* If hibernate info is acquired from EFI variable, don't wait forever by default. Otherwise, if - * swap device is not present and HibernateLocation was not correctly cleared, we end up blocking - * the boot process infinitely. */ - r = write_drop_in_format(arg_dest, device_unit, 40, "device-timeout", - "# Automatically generated by systemd-hibernate-resume-generator\n\n" - "[Unit]\n" - "JobTimeoutSec=%s\n", - info->cmdline ? "infinity" : "2min"); - if (r < 0) - log_warning_errno(r, "Failed to write device timeout drop-in, ignoring: %m"); - r = generator_write_device_timeout(arg_dest, info->device, arg_resume_options ?: arg_root_options, NULL); if (r < 0) log_warning_errno(r, "Failed to write device timeout drop-in, ignoring: %m"); + if (r <= 0) { + /* No timeout explicitly defined? Wait infinitely if resume= is specified, 2min if from EFI + * HibernateLocation variable. In the latter case, we avoid blocking the boot process forever + * if a stale var is detected while the swap device is not present. */ + r = write_drop_in_format(arg_dest, device_unit, 40, "device-timeout", + "# Automatically generated by systemd-hibernate-resume-generator\n\n" + "[Unit]\n" + "JobTimeoutSec=%s\n", + info->cmdline ? "infinity" : "2min"); + if (r < 0) + log_warning_errno(r, "Failed to write fallback device timeout drop-in, ignoring: %m"); + } r = write_drop_in_format(arg_dest, SPECIAL_HIBERNATE_RESUME_SERVICE, 90, "device-dependency", "# Automatically generated by systemd-hibernate-resume-generator\n\n"