Bug 911243 - SUSE_BTRFS_SNAPSHOT_BOOTING=true breaks resume after hibernate
Summary: SUSE_BTRFS_SNAPSHOT_BOOTING=true breaks resume after hibernate
Status: RESOLVED FIXED
Alias: None
Product: openSUSE Distribution
Classification: openSUSE
Component: Bootloader (show other bugs)
Version: 13.2
Hardware: x86-64 openSUSE 13.2
: P5 - None : Normal (vote)
Target Milestone: ---
Assignee: Michael Chang
QA Contact: Jiri Srain
URL: https://forums.opensuse.org/showthrea...
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2014-12-24 13:59 UTC by Wolfgang Bauer
Modified: 2018-04-20 22:02 UTC (History)
1 user (show)

See Also:
Found By: ---
Services Priority:
Business Priority:
Blocker: ---
Marketing QA Status: ---
IT Deployment: ---


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Wolfgang Bauer 2014-12-24 13:59:40 UTC
User-Agent:       Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.21 (KHTML, like Gecko) konqueror/4.14.3 Safari/537.21
Build Identifier: 

If SUSE_BTRFS_SNAPSHOT_BOOTING is set to true in /etc/default/grub (the default), the hibernate scripts (/usr/bin/systemd-sleep-grub, /usr/lib/pm-utils/sleep.d/99Zgrub) get confused by the "menuentry" added to the 00_header in grub.cfg.
So they set the wrong (off by one) entry to be booted.


Reproducible: Always

Steps to Reproduce:
1. set SUSE_BTRFS_SNAPSHOT_BOOTING=true (that's the default anyway)
2. boot a previous kernel in "Advanced Options"
3. hibernate, then resume
Actual Results:  
The wrong boot entry is booted (recovery mode), therefore no resume is actually taking place.
And now that boot entry is even set permanently because of bug#856391.

Expected Results:  
The system resumes successfully.

Here's the debug output (from the pm-utils script, systemd-sleep-grub says basically the same though):
INFO: running prepare-grub
  Skipping grub entry #3, because it has the noresume option
  Skipping grub entry #5, because it has the noresume option
  Skipping grub entry #6, because it has no root= option
  running kernel is grub menu entry 4 (vmlinuz-3.16.6-2-desktop)
  preparing boot-loader: selecting entry 4, kernel /boot/3.16.6-2-desktop
  grub-once:   saving original /boot/grub2/grubenv
  running '/usr/sbin/grub2-once 4'
while those are the menu entries:
# grub2-once --list
     0 openSUSE
     1 Advanced options for openSUSE>openSUSE, with Linux 3.16.7-7-desktop
     2 Advanced options for openSUSE>openSUSE, with Linux 3.16.7-7-desktop (recovery mode)
     3 Advanced options for openSUSE>openSUSE, with Linux 3.16.6-2-desktop
     4 Advanced options for openSUSE>openSUSE, with Linux 3.16.6-2-desktop (recovery mode)
     5 openSUSE Memtest
     6 Microsoft Windows XP Professional (on /dev/sda1)
(I booted #3 here)

Of course #3 and #5 do _not_ have the "noresume" option, but #2 and #4 have.

The problem is this: if "SUSE_BTRFS_SNAPSHOT_BOOTING" is true (in /etc/default/grub) the following is created in the menu header:
if [ -n "$extra_cmdline" ]; then
  submenu "Bootable snapshot #$snapshot_num" {
    menuentry "If OK, run 'snapper rollback $snapshot_num' and reboot." { true; }

The hibernate scripts look for the string "menuentry " to identify menu entries, so this gets counted as entry#0 and the following real menu entries are off by one.

If you are running the default kernel, there is not really a problem though, as entry#0 and entry#1 are actually the same (#1 is the default kernel entry inside the "Advanced Options" submenu).
I think this is the reason why this has gone through unnoticed until now... ;-)
Comment 2 Andrei Borzenkov 2014-12-24 17:40:44 UTC
The problem is mismatch between /usr/lib/pm-utils/sleep.d/99Zgrub and grub2-once. The former counts everything starting with "menuentry " and the latter counts more strict pattern "menuentry 'menu title' {...}". grub2-once should probably be extended to accept "..." and string without spaces as valid menu title.
Comment 3 Tomáš Chvátal 2018-04-12 13:57:24 UTC
This version of openSUSE changed to end-of-life (EOL [1]) status. As such
it is no longer maintained, which means that it will not receive any
further security or bug fix updates.
As a result we are closing this bug.

If you can reproduce this bug against a currently maintained version of 
openSUSE, or consider the bug still valid, please feel free to reopen this
bug against that version, or open a new ticket.

Thank you for reporting this bug and we are sorry it could not be fixed
during the lifetime of the release.

[1] https://en.opensuse.org/Lifetime
Comment 4 Wolfgang Bauer 2018-04-20 22:02:23 UTC
Actually this seems to work fine now in Leap 42.3.