grubenv not updated when new kernel installed

Latest response

I have a bunch of machines running RHEL7. Normally when yum installs a new kernel, the /boot/grub2/grubenv file is updated to point to the latest kernel. However, on one particular machine, the grubenv file is not updated. Is there a log of what yum does when it installs a new kernel that I could look at? What is the process (script? program?) to update grubenv when the kernel RPM is installed?
Thanks,
Allen

Responses

Same issue, had to run grub2-mkconfig to get it to boot new kernel. grubenv still references old kernel.

That is odd. My grubenv doesn't have any configuration values in it. All of my grub2 configuration resides in /boot/grub2/grub.cfg and custom parameters in /etc/default/grub, which is how it is documented in the RHEL7 SAM. Give this page a read if you have not already:

https://access.redhat.com/documentation/en-us/red_hat_enterprise_linux/7/html/system_administrators_guide/ch-working_with_the_grub_2_boot_loader

Hi Charles: Thanks; the manual explained some of what happening. But where is the actual script which is run when a new kernel is installed? Is that in the kernel RPM or does yum itself know something about installing kernels? Somewhere there must be a "grubby" or "grub-set-default" command which is not completing. (I guess...)

Allen,

I'm not entirely sure what yum does with the grub configuration on a kernel upgrade, aside from it calling grubby by some means. The output of "rpm -ql kernel" shows no shell scripts bundled with the kernel on my system.

You can examine what files yum opens with the strace command, but that can be a lot of output. Maybe try running your yum upgrade with strace, redirect its stderr to stdout, and grep for grub?

I also found this page with an answer that suggests you may want to check to make sure your /etc/grub2.cfg is a symlink which points to /boot/grub2/grub.cfg:

https://ask.fedoraproject.org/en/question/8269/why-isnt-my-grubconf-updated-after-kernel-updates/

Hope this helps.

Regards,

Charles

" I'm not entirely sure what yum does with the grub configuration on a kernel upgrade, aside from it calling grubby by some means. The output of "rpm -ql kernel" shows no shell scripts bundled with the kernel on my system."

You need to run the rpm command with --scripts like so:

$ rpm -q --scripts kernel-3.10.0-693.5.2.el7
postinstall scriptlet (using /bin/sh):

/usr/sbin/new-kernel-pkg --package kernel --install 3.10.0-693.5.2.el7.x86_64 || exit $?
preuninstall scriptlet (using /bin/sh):
/usr/sbin/new-kernel-pkg --rminitrd --rmmoddep --remove 3.10.0-693.5.2.el7.x86_64 || exit $?
if [ -x /usr/sbin/weak-modules ]
then
    /usr/sbin/weak-modules --remove-kernel 3.10.0-693.5.2.el7.x86_64 || exit $?
fi
posttrans scriptlet (using /bin/sh):
if [ -x /usr/sbin/weak-modules ]
then
    /usr/sbin/weak-modules --add-kernel 3.10.0-693.5.2.el7.x86_64 || exit $?
fi
/usr/sbin/new-kernel-pkg --package kernel --mkinitrd --dracut --depmod --update 3.10.0-693.5.2.el7.x86_64 || exit $?
/usr/sbin/new-kernel-pkg --package kernel --rpmposttrans 3.10.0-693.5.2.el7.x86_64 || exit $?

The new-kernel-pkg script does a lot of things. :)

"The new-kernel-pkg script does a lot of things. :)" Indeed it does! Thanks, Akemi. I think this is what I'm looking for. At least I can edit the script to add -x to the #! line next time I install a kernel.

Hi Charles: OK, more grist for the mill of understanding. Thanks! (My /etc/grub2.cfg is symlinked to /boot/grub2/grub.cfg.)

I agree with Charles that installing new kernel would not make any changes to /boot/grub2/grubenv file, this is used in case if there is a need to change boot kernel from default one. So, installing new kernel would become default boot kernel unless 'UPDATEDEFAULT' parameter in /etc/sysconfig/kernel is set to 'no', which by default set to 'yes'.

You may change the default logging level from 'info' to 'debug' in /etc/rsyslog.conf file (as shown below), and restart the rsyslog service after which you would get to see additional logs in /var/log/messages file whenever kernel is installed. Keep in mind that this would fill up file system space allotted for /var, so you may change it back to default mode after your debug activities.

*.debug;mail.none;authpriv.none;cron.none                /var/log/messages

That's it! The machine which won't update grubenv is missing /etc/sysconfig/kernel.

Now on to the next mystery: "rpm -qf /etc/sysconfig/kernel" says it comes from the grubby rpm. But, "yum reinstall grubby" doesn't create the file. There must be more to it.

Thanks!

You could create that file as root user with required details as given:

[root@managed1 ~]# 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@managed1 ~]# ls -al /etc/sysconfig/kernel
-rw-r--r--. 1 root root 180 May 30 13:56 /etc/sysconfig/kernel

After this you could run the "grub2-set-default" command to set the required kernel as the default boot kernel. You would need to reboot the system and test. The system should boot up to the kernel entry as specified in /boot/grub2/grubenv file.

Close

Welcome! Check out the Getting Started with Red Hat page for quick tours and guides for common tasks.