CentOS – Equivalent of ‘update-grub’ for RHEL, Fedora, and CentOS Systems

centosfedoragrubrhel

In Ubuntu (and I guess in Debian too) there is a system script named update-grub which automatically executes grub-mkconfig -o with the correct path for the grub configuration file.

Is there any similar command for Red Hat based distributions?

If not, how do the system knows where is the grub configuration file to update when a new kernel version is installed?

Best Answer

Specific actions that need to happen when a RPM package is installed or removed are included within the RPM package itself in pre-install, post-install, pre-uninstall and post-uninstall sections.

For every installed RPM package you can query the RPM database for the exact scripts that are included with the rpm command:

rpm -q --scripts <package-name>

Running that command on a kernel package for CentOS 6 returns among others:

postinstall scriptlet (using /bin/sh):
<snip>
/sbin/new-kernel-pkg --package kernel --install 2.6.32-431.17.1.el6.x86_64 || exit $?

From the manual:

new-kernel-package - tool to script kernel installation

Related Question