Gentoo Forums
Gentoo Forums
Gentoo Forums
Quick Search: in
[solved] kernel update with genkernel
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
mschraff
Tux's lil' helper
Tux's lil' helper


Joined: 08 Jun 2008
Posts: 84

PostPosted: Sun Nov 10, 2019 5:56 pm    Post subject: [solved] kernel update with genkernel Reply with quote

Hello,

a few weeks ago I set up a new gentoo system. The last time I was using gentoo / linux is about 10 years ago and that time I was manually compiling my kernel so it will fit my system. But now my aim was to get gentoo installed and editing the kernel without proper "know-how" would cost me a lot of time so I used genkernel and the 4.19-72-gentoo sources. Now an update installed the 4.19-82 sources and an "emerge --depclean" would like to delete the old kernel sources. That implies that I have to compile the new sources and boot them with grub2 (with EFI). That leads to several problems:

1) I don´t know how the "/etc/genkernel" should look like
2) how to edit grub? Where is the grub config file where I can add the entry for the new kernel?
3) how do I tell my system to keep the old kernel at least as a fallback option

So let´s start step by step. My laptop starts with UEFI and the /etc/genkernel (in short) looks like that
Code:

# Run 'make oldconfig' before compiling this kernel?
OLDCONFIG="yes"
# Run 'make menuconfig' before compiling this kernel?
MENUCONFIG="no"
# Run 'make gconfig' before compiling this kernel?
GCONFIG="no"
# Run 'make nconfig' (ncurses 'menuconfig') before compiling this kernel?
NCONFIG="no"
# Run 'make xconfig' before compiling this kernel?
XCONFIG="no"

# Run 'make clean' before compilation?
# If set to NO, implies MRPROPER WILL NOT be run
# Also, if clean is NO, it won't copy over any configuration
# file, it will use what's there.
CLEAN="yes"

# Run 'make mrproper' before configuration/compilation?
MRPROPER="yes"

# Override the arch detection?
#ARCH_OVERRIDE="x86"

# Mount BOOTDIR automatically if it isn't mounted?
MOUNTBOOT="yes"

# Make symlinks in BOOTDIR automatically?
#SYMLINK="no"

# Save the new configuration in /etc/kernels upon
# successfull compilation
SAVE_CONFIG="yes"

# =========COMPILED UTILS CONFIGURATION============
#
# Default location of kernel source
DEFAULT_KERNEL_SOURCE="/usr/src/linux"
# Default kernel config (only use to override using
# arch/%%ARCH%%/kernel-config-${VER}.${PAT} !)
#DEFAULT_KERNEL_CONFIG="${GK_SHARE}/arch/%%ARCH%%/kernel-config"


I already compiled the new kernel with "genkernel all" after setting the right symlink to the new sources. How do I have to proceed. The grub as well as the genkernel wiki are at least confusing for a newbie like me.
_________________
DELL Latitude 5550 intel Core i5-5300 CPU @ 2.30GHz
gentoo genkernel-4.19.97 gcc 9.2.0-r2 portage 2.3.89-r1


Last edited by mschraff on Mon Nov 11, 2019 9:01 pm; edited 1 time in total
Back to top
View user's profile Send private message
NeddySeagoon
Administrator
Administrator


Joined: 05 Jul 2003
Posts: 44921
Location: 56N 3W

PostPosted: Sun Nov 10, 2019 8:34 pm    Post subject: Reply with quote

mschraff,

1) /etc/genkernel is not changed between kernel updates. If it works now, its fine.
2) You don't edit grub.cfg
Once the new kernel and initrd are installed into /boot
Code:
grub-mkconfig -o /boot/grub/grub.cfg
will rewrite grub.cfg for you, including all the kernels that it can find.

3) That needs some background.
--depclean will only remove the kernel sources from /usr/src/. All the generated files will remain. That includes the .config file.
The kernel binary will be in /boot as will the initrd and the modules will stay in /lib/modules, so it all still works.
However with the sources removed, you cannot rebuild that kernel, nor build external kernel modules against it.

Use the --exclude option to emerge to keep your kernel sources.
_________________
Regards,

NeddySeagoon

Computer users fall into two groups:-
those that do backups
those that have never had a hard drive fail.
Back to top
View user's profile Send private message
r7l
n00b
n00b


Joined: 16 Feb 2019
Posts: 46

PostPosted: Sun Nov 10, 2019 11:39 pm    Post subject: Reply with quote

1) As said before, you don't need to edit it if it worked once and you don't need anything different for a new kernel

2) In most situations it's sufficient enough to edit /etc/default/grub instead of the files in /etc/grub.d/. You can add kernel parameters to the first file already using the GRUB_CMDLINE_LINUX parameter. That's the only parameter you might actually need to edit if you just wanna start up without any other fancy additions.

3) If you don't want to update the kernel but still want to update the rest of the system, you could use the update command like this:
Code:
emerge -uND world --exclude=sys-kernel/gentoo-sources

This prevents the kernel from being updated.
Back to top
View user's profile Send private message
mschraff
Tux's lil' helper
Tux's lil' helper


Joined: 08 Jun 2008
Posts: 84

PostPosted: Mon Nov 11, 2019 7:32 pm    Post subject: Reply with quote

Thanks to both of you!! That was nearly too easy. So the thread can be "closed". But before I´ll do that one last question:

When this laptop is set up properly (the last thing missing is the screen resolution) I may switch to a manually compiled kernel. Can this kernel be used parallel with the one compiled with genkernel?
_________________
DELL Latitude 5550 intel Core i5-5300 CPU @ 2.30GHz
gentoo genkernel-4.19.97 gcc 9.2.0-r2 portage 2.3.89-r1
Back to top
View user's profile Send private message
NeddySeagoon
Administrator
Administrator


Joined: 05 Jul 2003
Posts: 44921
Location: 56N 3W

PostPosted: Mon Nov 11, 2019 8:18 pm    Post subject: Reply with quote

mschraff,

Yes but ...

If the kernel are different versions, just yes.
The kernel identifies bits of itself by
Code:
uname -r
Modules for any kernel go into /lib/modules/`uname -r` whatever the uname -r is for that kernel.
Thus
Code:
ls /lib/modules/`uname -r`
shows the top level of the kernel modules directory for the running kernel.
This means that you must not try to install two kernel with the same uname -r at the same time.
Keeping the kernel binaries separate in /boot is not a problem but the last one installed will overwrite the modules for any earlier ones, which means that they will no longer work.

There are two or three options.
1. Set CONFIG_LOCALVERSION in the kernel config. That changes uname -r
The down side is that not all out of kernel modules respect it. If you don't use out of kernel kernel modules, thats not an issue.

2. Edit the kernel Makefile. At the top it contains something like
Code:
VERSION = 5
PATCHLEVEL = 3
SUBLEVEL = 8
EXTRAVERSION = -gentoo
Change EXTRAVERSION = to whatever you like as long as it does not end in a space.

3. Make a copy of the kernel tree and apply 1 or 2 above. That way you keep both kernel trees in a state where they can be modified.

4. Learn to use the kernel environment variables to build outside of the tree.
Building as root is a verybadthing. Once upon a time the kernel build system shipped with a bug where it tried to recursively remove the root filesystem.
As root, that did a lot more damage than building as a normal user. Either would ruin you day though.
_________________
Regards,

NeddySeagoon

Computer users fall into two groups:-
those that do backups
those that have never had a hard drive fail.
Back to top
View user's profile Send private message
mschraff
Tux's lil' helper
Tux's lil' helper


Joined: 08 Jun 2008
Posts: 84

PostPosted: Mon Nov 11, 2019 9:00 pm    Post subject: Reply with quote

Thanks for your detailled information. For now this thread is closed as the question is answered. If I will really start again compiling a kernel manually I´ll do this step by step.

Best
_________________
DELL Latitude 5550 intel Core i5-5300 CPU @ 2.30GHz
gentoo genkernel-4.19.97 gcc 9.2.0-r2 portage 2.3.89-r1
Back to top
View user's profile Send private message
Whissi
Developer
Developer


Joined: 12 Jan 2011
Posts: 78

PostPosted: Sun Nov 24, 2019 10:57 pm    Post subject: Reply with quote

With new genkernel-4 this is now very easy: Use new "--kernel-append-localversion" command-line argument to genkernel to create a new revision. I.e. you run

Code:
genkernel all


for gentoo-sources-5.3.12 for the first time. This created

Code:

/boot/vmlinuz-5.3.12-gentoo-x86_64
/boot/initramfs-5.3.12-gentoo-x86_64.img
/lib/modules/5.3.12-gentoo-x86_64


If you are going to change something and want a new "revision" which doesn't interfere with previous build of the same kernel version, just re-run genkernel but this time add new "--kernel-append-localversion" command-line argument like

Code:
genkernel --kernel-append-localversion=-r1 all


This will create

Code:

/boot/vmlinuz-5.3.12-gentoo-x86_64-r1
/boot/initramfs-5.3.12-gentoo-x86_64-r1.img
/lib/modules/5.3.12-gentoo-x86_64-r1


Pay attention to used kernel config: Genkernel tries to find config based on kernel version extracted from kernel sources (--kernel-dir). So once updated $KERNEL_DIR/include/config/kernel.release was written, genkernel will probably use a different config taking updated CONFIG_LOCALVERSION into account.

PS: --kernel-config can read from /proc/config.gz!
_________________
Regards,
Whissi
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