resume from hibernation broken when resume image is autodetected (UUID= syntax used)

Bug #1769297 reported by Dmitriy Geels
86
This bug affects 13 people
Affects Status Importance Assigned to Milestone
initramfs-tools (Ubuntu)
Fix Released
Medium
Benjamin Drung
Noble
Fix Released
Medium
Unassigned

Bug Description

[ Impact ]

I found a reason of non-functioning resume from hibernation when resume partition/file is autodetected by intiramfs hook /usr/share/initramfs-tools/hooks/resume.

Here is the scenario:
1) hook /usr/share/initramfs-tools/hooks/resume creates config conf/conf.d/zz-resume-auto saved in initrd image, containing one variable: RESUME=UUID=106238b0-707d-4422-866d-a7534da50702 in my case

2) during boot init script sets 'resume' variable to 'RESUME' value from conf/conf.d/zz-resume-auto, then it executes local-premount scripts including local-premount/resume

3) resuming script local-premount/resume (/usr/share/initramfs-tools/scripts/local-premount/resume) tries to get resume device major-minor numbers by these lines:
DEV=$(readlink ${resume})
DEV=/sys/class/block/${DEV##*/}/dev
if [ -r "$DEV" ]; then
        read MAJMIN < "$DEV"
fi

4) next check fails and resume process silently aborts:
if [ -z "$MAJMIN" ]; then
        exit 1
fi

Resuming script fails to get device major-minor because resume=UUID=106238b0-707d-4422-866d-a7534da50702 -- it's not resolved into device path in init script.

Commonly mentioned workaround is to explicitly specify kernel parameter resume=UUID=106238b0-707d-4422-866d-a7534da50702 -- only in this case init script resolves it to device path.

[ Test Plan ]

1. hibernate: `sudo systemctl hibernate`
2. resume from hibernate
3. `cat /sys/power/resume` should contain the major-minor of the swap

[ Other Info ]

ProblemType: Bug
DistroRelease: Ubuntu 18.04
Package: initramfs-tools 0.130ubuntu3
Uname: Linux 4.16.6-041606-generic x86_64
ApportVersion: 2.20.9-0ubuntu7
Architecture: amd64
CurrentDesktop: ubuntu:GNOME
Date: Sat May 5 11:32:31 2018
InstallationDate: Installed on 2018-03-27 (38 days ago)
InstallationMedia: Ubuntu 18.04 LTS "Bionic Beaver" - Alpha amd64 (20180327)
PackageArchitecture: all
SourcePackage: initramfs-tools
UpgradeStatus: No upgrade log present (probably fresh install)

Related branches

Revision history for this message
Dmitriy Geels (dmig) wrote :
description: updated
Dmitriy Geels (dmig)
description: updated
Revision history for this message
Dmitriy Geels (dmig) wrote :

How to check you have this issue:

1) get provided resume script, replace /usr/share/initramfs-tools/scripts/local-premount/resume with it
2) sudo update-initramfs -k $(uname -r) -u
3) sudo systemctl hibernate
4) edit grub menu entry, add 'debug' parameter to kernel command line, boot
5) look into /run/initramfs/initramfs.debug, if you see following lines, you have this issue:
+ /scripts/local-premount/resume
Success: Resume device: 'UUID=106238b0-707d-4422-866d-a7534da50702' ()
Failure: Failed to get /sys/class/block//dev major/minor

Revision history for this message
Dmitriy Geels (dmig) wrote :

Here is a fix for this bug. This makes hibernation functional for me.

Revision history for this message
Dmitriy Geels (dmig) wrote :

This bug is actually a regression. I remember hibernation was functional around a year ago in ubuntu 17.04 with any kernel, but at some point it became broken. Probably in 17.10.

tags: added: patch
Revision history for this message
Ubuntu Foundations Team Bug Bot (crichton) wrote :

The attachment "init.patch" seems to be a patch. If it isn't, please remove the "patch" flag from the attachment, remove the "patch" tag, and if you are a member of the ~ubuntu-reviewers, unsubscribe the team.

[This is an automated message performed by a Launchpad user owned by ~brian-murray, for any issues please contact him.]

Revision history for this message
Launchpad Janitor (janitor) wrote :

Status changed to 'Confirmed' because the bug affects multiple users.

Changed in initramfs-tools (Ubuntu):
status: New → Confirmed
tags: added: regression-release
Revision history for this message
Steve Smith (tarkasteve) wrote :

FWIW, installing initramfs-tools(-core) 0.132 from Debian buster/sid fixed this for me. Both direct download and a build from source worked.

Revision history for this message
amk (9-launchpad-mikus-sk) wrote :

Reached to this bug because of a similar issue we were able to resolve using information here.

In 18.10, at least in our case, the RESUME variable is set with partition device name, not UUID. Yet the identification failed, because the device is not a link and readlink ${resume} returns nothing (or invalid argument when invoked with -v).

Got things working by assigning $resume into $DEV directly. This could be more universal approach:

DEV=$(readlink ${resume})
DEV="${DEV:-$resume}"
DEV=/sys/class/block/${DEV##*/}/dev

Revision history for this message
Emiliano (retorquere) wrote :

@Dmitry where would I set this resume= parameter?

tags: added: rls-ee-incoming
Changed in initramfs-tools (Ubuntu):
assignee: nobody → Dimitri John Ledkov (xnox)
Benjamin Drung (bdrung)
Changed in initramfs-tools (Ubuntu):
importance: Undecided → Medium
Benjamin Drung (bdrung)
summary: - resume from hibernation broken when resume image is autodetected
+ resume from hibernation broken when resume image is autodetected (UUID=
+ syntax used)
Revision history for this message
Benjamin Drung (bdrung) wrote :

This bug will be fixed in the next initramfs-tools upload.

Changed in initramfs-tools (Ubuntu):
assignee: Dimitri John Ledkov (xnox) → Benjamin Drung (bdrung)
status: Confirmed → In Progress
Changed in initramfs-tools (Ubuntu Noble):
importance: Undecided → Medium
Benjamin Drung (bdrung)
Changed in initramfs-tools (Ubuntu):
status: In Progress → Fix Committed
Benjamin Drung (bdrung)
description: updated
tags: removed: rls-ee-incoming
Revision history for this message
Launchpad Janitor (janitor) wrote :

This bug was fixed in the package initramfs-tools - 0.142ubuntu29

---------------
initramfs-tools (0.142ubuntu29) oracular; urgency=medium

  [ Jeffery To ]
  * Fix resume failure due to resume=UUID=... in certain cases (LP: #1769297)

  [ Benjamin Drung ]
  * resume: always write valid resume device to /sys/power/resume (LP: #1769297)
  * fsck: Mention file system name in failed identification warning
    (LP: #2068077)

 -- Benjamin Drung <email address hidden> Wed, 03 Jul 2024 13:55:55 +0200

Changed in initramfs-tools (Ubuntu):
status: Fix Committed → Fix Released
Revision history for this message
Chris Halse Rogers (raof) wrote : Please test proposed package

Hello Dmitriy, or anyone else affected,

Accepted initramfs-tools into noble-proposed. The package will build now and be available at https://launchpad.net/ubuntu/+source/initramfs-tools/0.142ubuntu25.2 in a few hours, and then in the -proposed repository.

Please help us by testing this new package. See https://wiki.ubuntu.com/Testing/EnableProposed for documentation on how to enable and use -proposed. Your feedback will aid us getting this update out to other Ubuntu users.

If this package fixes the bug for you, please add a comment to this bug, mentioning the version of the package you tested, what testing has been performed on the package and change the tag from verification-needed-noble to verification-done-noble. If it does not fix the bug for you, please add a comment stating that, and change the tag to verification-failed-noble. In either case, without details of your testing we will not be able to proceed.

Further information regarding the verification process can be found at https://wiki.ubuntu.com/QATeam/PerformingSRUVerification . Thank you in advance for helping!

N.B. The updated package will be released to -updates after the bug(s) fixed by this package have been verified and the package has been in -proposed for a minimum of 7 days.

Changed in initramfs-tools (Ubuntu Noble):
status: New → Fix Committed
tags: added: verification-needed verification-needed-noble
Revision history for this message
Ubuntu SRU Bot (ubuntu-sru-bot) wrote : Autopkgtest regression report (initramfs-tools/0.142ubuntu25.2)

All autopkgtests for the newly accepted initramfs-tools (0.142ubuntu25.2) for noble have finished running.
The following regressions have been reported in tests triggered by the package:

cryptsetup/unknown (s390x)
initramfs-tools/0.142ubuntu25.2 (s390x)
initramfs-tools/unknown (ppc64el)
kdump-tools/unknown (ppc64el)
mandos/unknown (ppc64el)
multipath-tools/0.9.4-5ubuntu8 (s390x)
multipath-tools/unknown (ppc64el)
zfs-linux/unknown (ppc64el, s390x)

Please visit the excuses page listed below and investigate the failures, proceeding afterwards as per the StableReleaseUpdates policy regarding autopkgtest regressions [1].

https://people.canonical.com/~ubuntu-archive/proposed-migration/noble/update_excuses.html#initramfs-tools

[1] https://wiki.ubuntu.com/StableReleaseUpdates#Autopkgtest_Regressions

Thank you!

Revision history for this message
Benjamin Drung (bdrung) wrote :

Jeffery To, may I ask you to test initramfs-tools 0.142ubuntu25.2 on noble? I has all the hibernation fixes that you developed included.

Revision history for this message
Hans van den Bogert (hbogert) wrote :

enabled proposed, but the update didn't come automatically. Manually selected the newer version with aptitude. Can confirm this works on 2 machines now. Awesome! But what a regression in the first place? I had to search pretty hard to find this.

Revision history for this message
Hans van den Bogert (hbogert) wrote :

actually, I jumped the gun on my 2nd machine which is a laptop. It's showing a completely wrong major/minor of: 2623:602885, the resume_offset in /sys/power is the same as my grub/cmdline though. My major/minor should be 259:1

Revision history for this message
Hans van den Bogert (hbogert) wrote :

Disregard my issue with my second machine, it didn't have the 'UUID=' part in /etc/default/grub. Adding that solved the issues with that machine as well. So definite +1 solved for me.

That does lead to the question, why doesn't forgetting to add 'UUID=' give a better error message, and instead give /sys/power/resume a seemingly random number for major and minor.

Revision history for this message
Benjamin Drung (bdrung) wrote :

Hans, can you create a separate bug report for analyzing why forgetting to add 'UUID=' results in such a strange behavior instead of a proper error message?

Revision history for this message
Benjamin Drung (bdrung) wrote :

I am marking this bug as verification done. See comment #15 to #17 for the verification.

tags: added: verification-done verification-done-noble
removed: verification-needed verification-needed-noble
Revision history for this message
Andreas Hasenack (ahasenack) wrote : Update Released

The verification of the Stable Release Update for initramfs-tools has completed successfully and the package is now being released to -updates. Subsequently, the Ubuntu Stable Release Updates Team is being unsubscribed and will not receive messages about this bug report. In the event that you encounter a regression using the package from -updates please report a new bug using ubuntu-bug and tag the bug report regression-update so we can easily find any regressions.

Revision history for this message
Launchpad Janitor (janitor) wrote :

This bug was fixed in the package initramfs-tools - 0.142ubuntu25.2

---------------
initramfs-tools (0.142ubuntu25.2) noble; urgency=medium

  [ Jeffery To ]
  * Fix resume failure due to resume=UUID=... in certain cases (LP: #1769297)
  * hooks/resume: Fix resume device type check

  [ Benjamin Drung ]
  * resume: always write valid resume device to /sys/power/resume (LP: #1769297)
  * mkinitramfs: Resolve hidden dependencies after all modules were copied
  * reduce number of dracut-install calls: group dracut-install calls for
    block modules in auto_add_modules and use copy_modules_dir code instead
    of dracut-install calls (LP: #2065180)

 -- Benjamin Drung <email address hidden> Fri, 05 Jul 2024 09:58:14 +0200

Changed in initramfs-tools (Ubuntu Noble):
status: Fix Committed → Fix Released
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.