Bug 1524554

Summary: grub2-set-default command can't change a default start kernel when grub2-efi rpms are installed
Product: Red Hat Enterprise Linux 7 Reporter: Dmitry Zhukovski <dzhukous>
Component: grub2Assignee: Peter Jones <pjones>
Status: CLOSED DUPLICATE QA Contact: Release Test Team <release-test-team-automation>
Severity: medium Docs Contact:
Priority: medium    
Version: 7.7CC: bgollahe, cww, mkolbas, pjones, release-test-team-automation, yferszt
Target Milestone: rc   
Target Release: 7.7   
Hardware: x86_64   
OS: Linux   
Whiteboard:
Fixed In Version: Doc Type: If docs needed, set a value
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2018-11-26 07:40:34 UTC Type: Bug
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Embargoed:
Bug Depends On:    
Bug Blocks: 1477664    

Description Dmitry Zhukovski 2017-12-11 16:45:00 UTC
Description of problem:
grub2-set-default command can't change a default start kernel when grub2-efi rpms are installed

Version-Release number of selected component (if applicable):
grub2-tools-minimal-2.02-0.65.el7_4.2.x86_64
grub2-pc-modules-2.02-0.65.el7_4.2.noarch
grub2-tools-2.02-0.65.el7_4.2.x86_64
grub2-pc-2.02-0.65.el7_4.2.x86_64
grub2-common-2.02-0.65.el7_4.2.noarch
grubby-8.28-23.el7.x86_64
grub2-tools-extra-2.02-0.65.el7_4.2.x86_64
grub2-2.02-0.65.el7_4.2.x86_64


How reproducible:
Everytime

Steps to Reproduce:
1. Install several kernels
2. Check we are booted into recent kernel
[root@desktop ~]# cat /etc/sysconfig/kernel
# UPDATEDEFAULT specifies if new-kernel-pkg should make
# new kernels the default
UPDATEDEFAULT=yes

# DEFAULTKERNEL specifies the default kernel package type
DEFAULTKERNEL=kernel
[root@desktop ~]# awk -F\' '$1=="menuentry " {print $2}' /etc/grub2.cfg
Red Hat Enterprise Linux Client (3.10.0-693.11.1.el7.x86_64) 7.4 (Maipo)
Red Hat Enterprise Linux Client (3.10.0-693.2.2.el7.x86_64) 7.4 (Maipo)
Red Hat Enterprise Linux Client (3.10.0-514.el7.x86_64) 7.4 (Maipo)
Red Hat Enterprise Linux Client (0-rescue-66bc7c210909401584fe486451278072) 7.4 (Maipo)
[root@desktop ~]# cat /boot/grub2/grubenv |grep saved
saved_entry=0
[root@desktop ~]# uname -a
Linux desktop 3.10.0-693.11.1.el7.x86_64 #1 SMP Fri Oct 27 05:39:05 EDT 2017 x86_64 x86_64 x86_64 GNU/Linux

3. Set default entry to #2 => third in the list (3.10.0-514.el7.x86_64)
[root@desktop ~]# grub2-set-default 2
[root@desktop ~]# grub2-mkconfig -o /boot/grub2/grub.cfg
Generating grub configuration file ...
Found linux image: /boot/vmlinuz-3.10.0-693.11.1.el7.x86_64
Found initrd image: /boot/initramfs-3.10.0-693.11.1.el7.x86_64.img
Found linux image: /boot/vmlinuz-3.10.0-693.2.2.el7.x86_64
Found initrd image: /boot/initramfs-3.10.0-693.2.2.el7.x86_64.img
Found linux image: /boot/vmlinuz-3.10.0-514.el7.x86_64
Found initrd image: /boot/initramfs-3.10.0-514.el7.x86_64.img
Found linux image: /boot/vmlinuz-0-rescue-66bc7c210909401584fe486451278072
Found initrd image: /boot/initramfs-0-rescue-66bc7c210909401584fe486451278072.img
done

4. Reboot
5. Check it's booted into correct kernel. 
[root@desktop ~]# uname -a
Linux desktop 3.10.0-514.el7.x86_64 #1 SMP Wed Oct 19 11:24:13 EDT 2016 x86_64 x86_64 x86_64 GNU/Linux

6. NB!!! grub2-efi* are NOT installed
7. Install grub2-efi*

[root@desktop ~]# yum install grub2-efi*
Loaded plugins: langpacks, product-id, search-disabled-repos, subscription-manager
Package grub2-efi-modules is obsoleted by grub2-efi-x64-modules, trying to install 1:grub2-efi-x64-modules-2.02-0.65.el7_4.2.noarch instead
Package grub2-efi is obsoleted by grub2-efi-x64, trying to install 1:grub2-efi-x64-2.02-0.65.el7_4.2.x86_64 instead
Resolving Dependencies
--> Running transaction check
---> Package grub2-efi-ia32.x86_64 1:2.02-0.65.el7_4.2 will be installed
---> Package grub2-efi-ia32-modules.noarch 1:2.02-0.65.el7_4.2 will be installed
---> Package grub2-efi-x64.x86_64 1:2.02-0.65.el7_4.2 will be installed
---> Package grub2-efi-x64-modules.noarch 1:2.02-0.65.el7_4.2 will be installed
--> Finished Dependency Resolution

Dependencies Resolved

========================================================================================================================
 Package                          Arch             Version                          Repository                     Size
========================================================================================================================
Installing:
 grub2-efi-ia32                   x86_64           1:2.02-0.65.el7_4.2              rhel-7-desktop-rpms           1.1 M
 grub2-efi-ia32-modules           noarch           1:2.02-0.65.el7_4.2              rhel-7-desktop-rpms           1.0 M
 grub2-efi-x64                    x86_64           1:2.02-0.65.el7_4.2              rhel-7-desktop-rpms           1.1 M
 grub2-efi-x64-modules            noarch           1:2.02-0.65.el7_4.2              rhel-7-desktop-rpms           1.1 M

Transaction Summary
========================================================================================================================
Install  4 Packages

Total download size: 4.2 M
Installed size: 16 M
Is this ok [y/d/N]: y
Downloading packages:
(1/4): grub2-efi-ia32-modules-2.02-0.65.el7_4.2.noarch.rpm                                       | 1.0 MB  00:00:01     
(2/4): grub2-efi-ia32-2.02-0.65.el7_4.2.x86_64.rpm                                               | 1.1 MB  00:00:01     
(3/4): grub2-efi-x64-2.02-0.65.el7_4.2.x86_64.rpm                                                | 1.1 MB  00:00:00     
(4/4): grub2-efi-x64-modules-2.02-0.65.el7_4.2.noarch.rpm                                        | 1.1 MB  00:00:00     
------------------------------------------------------------------------------------------------------------------------
Total                                                                                   1.7 MB/s | 4.2 MB  00:00:02     
Running transaction check
Running transaction test
Transaction test succeeded
Running transaction
  Installing : 1:grub2-efi-ia32-modules-2.02-0.65.el7_4.2.noarch                                                    1/4 
  Installing : 1:grub2-efi-ia32-2.02-0.65.el7_4.2.x86_64                                                            2/4 
  Installing : 1:grub2-efi-x64-2.02-0.65.el7_4.2.x86_64                                                             3/4 
  Installing : 1:grub2-efi-x64-modules-2.02-0.65.el7_4.2.noarch                                                     4/4 
  Verifying  : 1:grub2-efi-x64-modules-2.02-0.65.el7_4.2.noarch                                                     1/4 
  Verifying  : 1:grub2-efi-x64-2.02-0.65.el7_4.2.x86_64                                                             2/4 
  Verifying  : 1:grub2-efi-ia32-2.02-0.65.el7_4.2.x86_64                                                            3/4 
  Verifying  : 1:grub2-efi-ia32-modules-2.02-0.65.el7_4.2.noarch                                                    4/4 

Installed:
  grub2-efi-ia32.x86_64 1:2.02-0.65.el7_4.2              grub2-efi-ia32-modules.noarch 1:2.02-0.65.el7_4.2             
  grub2-efi-x64.x86_64 1:2.02-0.65.el7_4.2               grub2-efi-x64-modules.noarch 1:2.02-0.65.el7_4.2              

Complete!

8. Set again default entry to #2 => third in the list (3.10.0-514.el7.x86_64)
[root@desktop ~]# grub2-set-default 2
[root@desktop ~]# grub2-mkconfig -o /boot/grub2/grub.cfg
Generating grub configuration file ...
Found linux image: /boot/vmlinuz-3.10.0-693.11.1.el7.x86_64
Found initrd image: /boot/initramfs-3.10.0-693.11.1.el7.x86_64.img
Found linux image: /boot/vmlinuz-3.10.0-693.2.2.el7.x86_64
Found initrd image: /boot/initramfs-3.10.0-693.2.2.el7.x86_64.img
Found linux image: /boot/vmlinuz-3.10.0-514.el7.x86_64
Found initrd image: /boot/initramfs-3.10.0-514.el7.x86_64.img
Found linux image: /boot/vmlinuz-0-rescue-66bc7c210909401584fe486451278072
Found initrd image: /boot/initramfs-0-rescue-66bc7c210909401584fe486451278072.img
done
[root@desktop ~]# reboot 


Actual results:
Server boots into recent kernel version
[root@desktop ~]# uname -a
Linux desktop 3.10.0-693.11.1.el7.x86_64 #1 SMP Fri Oct 27 05:39:05 EDT 2017 x86_64 x86_64 x86_64 GNU/Linux

Expected results:
Server boots into correct kernel entry


Additional info:
Might be related to https://bugzilla.redhat.com/show_bug.cgi?id=1157397
Workaround - remove efi packages and redo  grub2-set-default & grub2-mkconfig