Gentoo Forums
Gentoo Forums
Gentoo Forums
Quick Search: in
Order of kernel rebuild steps
View unanswered posts
View posts from last 24 hours

 
Reply to topic    Gentoo Forums Forum Index Kernel & Hardware
View previous topic :: View next topic  
Author Message
g4s8
n00b
n00b


Joined: 15 Dec 2017
Posts: 15

PostPosted: Wed Jan 16, 2019 10:57 am    Post subject: Order of kernel rebuild steps Reply with quote

I have a script to rebuild the kernel after updating or config changes.
It includes: kernel building, modules building, installing initramfs with lvm and luks, rebuilding external modules (e.g. nvidia drivers) and updating grub config.

Here is the script:
Code:

#!/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?

Also asked same question here: https://unix.stackexchange.com/questions/494691/order-of-kernel-upgrade-commands-for-gentoo
Back to top
View user's profile Send private message
Atha
Apprentice
Apprentice


Joined: 22 Sep 2004
Posts: 169

PostPosted: Wed Jan 16, 2019 4:44 pm    Post subject: Reply with quote

Isn't genkernel supposed to build the kernel anyway? Maybe genkernel has some issues with generating just the initramfs for a kernel that has already been built and installed...

My routine is
Code:
genkernel --no-splash all && emerge @module-rebuild && grub-mkconfig -o /boot/grub/grub.cfg && umount /boot

I don't mount /boot because I have it set in /etc/genkernel.conf:
Code:
# Configuration file for genkernel
INSTALL="yes"
OLDCONFIG="no"
MENUCONFIG="no"
NCONFIG="no"
CLEAN="no"
MRPROPER="no"
MOUNTBOOT="yes"
SYMLINK="yes"
SAVE_CONFIG="no"
USECOLOR="yes"
CLEAR_CACHE_DIR="yes"
MAKEOPTS="-j16"
GK_SHARE="${GK_SHARE:-/usr/share/genkernel}"
CACHE_DIR="/var/cache/genkernel"
DISTDIR="/var/lib/genkernel/src"
LOGFILE="/var/log/genkernel.log"
LOGLEVEL=1
DEFAULT_KERNEL_SOURCE="/usr/src/linux"

All I have to do is copy the .config from the previous kernel, run "make listnewconfig" to get an overview, then "make oldconfig" to set the new options, and go with my genkernel command routine I wrote above.

I have no problems so far. I'm sorry I cannot be of more help, but my guess is really that genkernel doesn't correctly build the initramfs for you...
Back to top
View user's profile Send private message
Tony0945
Advocate
Advocate


Joined: 25 Jul 2006
Posts: 3293
Location: Illinois, USA

PostPosted: Wed Jan 16, 2019 5:26 pm    Post subject: Reply with quote

My build script, modify as required:
Code:
#!/bin/bash

#test if running on a bare VT
if [ "$TERM" = linux ]; then
    TERM=xterm     #so make munuconfig will display correctly
fi

cd /usr/src/linux
zcat /proc/config.gz >.config
#cp /boot/config-4.17.19-gentoo .config
#test for backporting nct6775.c
LONGVER=$(uname -r)
SHORTVER=$(echo -n $LONGVER | cut -f1,2 -d'.')
if [ $SHORTVER = 4.4 ] || [ $SHORTVER = 4.9 ]; then
 cp /usr/src/new_nct6775.c drivers/hwmon/nct6775.c
fi

# At this point we should compare kernel versions and make oldconfig if the base version has updated
make oldconfig
make menuconfig
make -j5 || {  echo "make -j5 failed"; exit 1; }
make -j5 modules_install || { echo "make modules_install failed";  exit 2; }
make -j5 install && echo "Don't forget to update boot loader menu"

# kver="$(eselect kernel list | awk '{gsub("linux-","") ; if ($3 ~ "*") print $2}')"
# i.e. kver contains 4.9.9-gentoo

#virtualbox modules
echo "Building Virtualbox modules"
emerge @module-rebuild
echo "Done"

This depends on having the kernel config built into the kernel which is a good idea anyway.
The nct6775.c stuff is because I have a newer motherboard that wasn't supported by the old nct6775.c but was in newer kernels. That may have been backported now. If you don't have an MSI Tomahawk B350, just erase it.
The commented out second line is for use in the case when the config is not in the kernel. Modify it as appropriate and then select "config in kernel" in make menuconfig.
Back to top
View user's profile Send private message
Display posts from previous:   
Reply to topic    Gentoo Forums Forum Index Kernel & Hardware All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum