1

I have 49 rpm packages that I need to install from a local directory. One of which is kernel-4.9.135 Therefore, I want to use yum so all dependencies are managed for me (instead of passing rpm a list of rpm files).

I also have a very customized grub.cfg file that I do not want touched during this process.

I examined the scripts that are run when the kernel package is installed:

# rpm -qp --scripts ./kernel-4.9.135-1.x86_64.rpm 
postinstall scriptlet (using /bin/sh):
if [ -x /sbin/installkernel -a -r /boot/vmlinuz-4.9.135 -a -r /boot/System.map-4.9.135 ]; then
cp /boot/vmlinuz-4.9.135 /boot/.vmlinuz-4.9.135-rpm
cp /boot/System.map-4.9.135 /boot/.System.map-4.9.135-rpm
rm -f /boot/vmlinuz-4.9.135 /boot/System.map-4.9.135
/sbin/installkernel 4.9.135 /boot/.vmlinuz-4.9.135-rpm /boot/.System.map-4.9.135-rpm
rm -f /boot/.vmlinuz-4.9.135-rpm /boot/.System.map-4.9.135-rpm
fi
...

installkernel contains the following:

if [ -n "$cfgLoader" ] && [ -x /sbin/new-kernel-pkg ]; then
if [ -n "$(which dracut 2>/dev/null)" ]; then
    new-kernel-pkg --mkinitrd --dracut --host-only --depmod --install --kernel-name $KERNEL_NAME $KERNEL_VERSION
else
    new-kernel-pkg --mkinitrd --depmod --install --kernel-name $KERNEL_NAME $KERNEL_VERSION
fi
new-kernel-pkg --rpmposttrans --kernel-name $KERNEL_NAME $KERNEL_VERSION
fi

And new-kernel-pkg uses grubby to update my grub.cfg file.

Is there some way to tell yum, and therefore the kernel rpm, to not do anything to alter grub.cfg, while using yum install to install all of my packages in one fell swoop?

The workaround is to copy my currentgrub.cfg to the side and copy it back after yum is finished but I thought I'd ask the question nonetheless.

2
  • 1
    Assuming that CentOS is close to Fedora, you may want to look at the packages that provide /usr/lib/kernel/install.d/ , /etc/kernel/install.d/ , and /etc/grub.d . You may be able to migrate your customizations out of grub.cfg so that kernel updates create a new grub.cfg that includes your customizations.
    – D McKeon
    Jun 25, 2019 at 23:31
  • You're right and I agree. The correct way to do this is to move my customizations out of grub.cfg. That activity is in progress and will happen eventually. The immediate goal here is to satisfy my curiosity about being able to alter the default "workflow" of a yum install in this particular instance. I do have a work-around that I'm okay using for now. Thanks for the feedback. FYI, in CentOS, most of the customization files are in /etc/grub.d/ and /etc/default/grub as @yurij mentions below. Jun 26, 2019 at 1:32

1 Answer 1

2

Your trick with grub.conf is working solution. Also you can apply one of the next approaches:

  1. Download kernel rpm package with yumdownloader and install kernel package with --noscripts parameter to ignore scripts which configure package by running prerun, postrun ... scripts during package are being configured. There is no way to tell --noscripts to yum directly.
  2. If you want persistent grub.conf after any new kernel installation via yum you should copy your current grub.conf menu entries that belong to your kernel to /etc/grub.d/40_custom and unset exec permissions (chmod a-x) from /etc/grub.d/30_probe_os (this script scans /boot directory for new kernels and initramfs files and generates menuentries for grub.conf). After this step all attempts of generate grub.conf bu running grub2-mkconfig will return only menu entries that contains in your custom configuration file /etc/grub.d/40_custom.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .