1

I have simple bash script to update the kernel. It includes building the kernel, rebuilding external modules, building initramfs with genkernel and updating grub config, here is the script:

#!/bin/bash

set -x
set -e

cd linux

# mount boot if not mounded
mount | grep "/boot type vfat" > /dev/null || mount /boot

# build the kernel
make -j16

# install modules
make modules_install

# prepare modules (for @module-rebuild)
make modules_prepare

# rebuild external modules (nvidia, etc)
emerge --ask=n @module-rebuild

# install kernel
make install

# build initramfs
genkernel --lvm --luks --install initramfs

# make grub config
grub-mkconfig > /boot/grub/grub.cfg

# umount boot
umount /boot

this script is working fine, but with one exception: I always need to call it twice, if I don't I'll get error on boot (failed to load initramfs), I think that some steps in script has wrong order, but I can't figure out what steps exactly. Oficial docs doesn't cover rebuilding with initramfs: https://wiki.gentoo.org/wiki/Kernel/Upgrade

What's wrong with my script? How to update it to fix?

1 Answer 1

0

I think you have to switch make modules_install and make modules_prepare.

First prepare the modules and then install them.

You must log in to answer this question.

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