Gentoo Forums
Gentoo Forums
Gentoo Forums
Quick Search: in
Three or more different kernel versions?
View unanswered posts
View posts from last 24 hours

 
Reply to topic    Gentoo Forums Forum Index Portage & Programming
View previous topic :: View next topic  
Author Message
eeckwrk99
Apprentice
Apprentice


Joined: 14 Mar 2021
Posts: 163
Location: Gentoo forums

PostPosted: Mon Jul 04, 2022 8:02 pm    Post subject: Three or more different kernel versions? Reply with quote

I'm using
Code:

ACCEPT_KEYWORDS="~amd64"

in /etc/portage.make.conf. Therefore, I'm using gentoo-sources-5.18.9, which is the latest unstable version in the Gentoo portage tree.

I decided I also wanted to install the 5.15 LTS kernel so I added:
Code:

sys-kernel/gentoo-sources -~amd64 amd64
<sys-kernel/gentoo-sources-5.16

in /etc/portage/package.accept_keywords.

It works just fine, I now have gentoo-sources-5.15.52 installed, which is the latest for 5.15.

Now, how can I add the unstable 5.10 version so that portage also pulls future updates for this branch?

Thanks.
Back to top
View user's profile Send private message
alamahant
Advocate
Advocate


Joined: 23 Mar 2019
Posts: 3879

PostPosted: Mon Jul 04, 2022 9:09 pm    Post subject: Reply with quote

You cant.
Although gentoo-sources is slotted it is slotted with the full version of the kernel.
See
https://packages.gentoo.org/packages/sys-kernel/gentoo-sources
Quote:

It works just fine, I now have gentoo-sources-5.15.52 installed, which is the latest for 5.15.

Does the latest kernel survive a --depclean?
_________________
:)
Back to top
View user's profile Send private message
eeckwrk99
Apprentice
Apprentice


Joined: 14 Mar 2021
Posts: 163
Location: Gentoo forums

PostPosted: Mon Jul 04, 2022 9:26 pm    Post subject: Reply with quote

alamahant wrote:
You cant.
Although gentoo-sources is slotted it is slotted with the full version of the kernel.
See
https://packages.gentoo.org/packages/sys-kernel/gentoo-sources

I see. Thank you!

alamahant wrote:

Quote:

It works just fine, I now have gentoo-sources-5.15.52 installed, which is the latest for 5.15.

Quote:
Does the latest kernel survive a --depclean?


Good catch, it does not. Any way to avoid this?
Back to top
View user's profile Send private message
alamahant
Advocate
Advocate


Joined: 23 Mar 2019
Posts: 3879

PostPosted: Mon Jul 04, 2022 9:37 pm    Post subject: Reply with quote

I suppose by
Code:

emerge -av gentoo-sources:5.18.9
emerge -av gentoo-sources:5.17.15


ie emerge explicitly the versions you want as opposed generically gentoo-sources.
I am not certain you need an entry in package.provided to do that.
Plz test and see for yourself.
_________________
:)
Back to top
View user's profile Send private message
Goverp
Advocate
Advocate


Joined: 07 Mar 2007
Posts: 2006

PostPosted: Tue Jul 05, 2022 9:08 am    Post subject: Reply with quote

alamahant wrote:
You cant.
Although gentoo-sources is slotted it is slotted with the full version of the kernel.
...

That seems pointless. Fixes to kernel-V.R.M will be kernel-V.R.M+1, and surely the purpose of a slotted package is to be able to maintain (as in use and keep patched) of said package.
_________________
Greybeard
Back to top
View user's profile Send private message
eeckwrk99
Apprentice
Apprentice


Joined: 14 Mar 2021
Posts: 163
Location: Gentoo forums

PostPosted: Sat Aug 13, 2022 2:17 pm    Post subject: Reply with quote

alamahant wrote:
I suppose by
Code:

emerge -av gentoo-sources:5.18.9
emerge -av gentoo-sources:5.17.15


ie emerge explicitly the versions you want as opposed generically gentoo-sources.
I am not certain you need an entry in package.provided to do that.
Plz test and see for yourself.


The following seems to work for me after a couple of kernels update cycles:

I don't specify anything gentoo-sources related in /etc/portage/package.accept_keywords. Since I'm using ~arch globally, the latest unstable gentoo-sources version is pulled when doing a system upgrade.

Then, I manually emerge new 5.10 and 5.15 and compile the three new kernels:

Code:
# emerge -1 =gentoo-sources{5.10.xxx,5.15.xx}


I wrote this hacky script to clean old kernels and unmerge old gentoo-sources:

Code:

#! /usr/bin/env bash

if [[ ! "$(sudo eclean-kernel -A -n "3" -p -s "mtime")" == "No outdated kernels found." ]] ; then
    sudo eclean-kernel -A -n "3" -s "mtime"
    PREVIOUS_5_10="$(eix --format '<installedversions:NAMEVERSION>' -* gentoo-sources | awk -F "-" '{ print $4 }' | rg -m "1" "^5.10")"
    PREVIOUS_5_15="$(eix --format '<installedversions:NAMEVERSION>' -* gentoo-sources | awk -F "-" '{ print $4 }' | rg -m "1" "^5.15")"
    PREVIOUS_5_19="$(eix --format '<installedversions:NAMEVERSION>' -* gentoo-sources | awk -F "-" '{ print $4 }' | rg -m "1" "^5.19")"
    sudo emerge -C =gentoo-sources-{"$PREVIOUS_5_10","$PREVIOUS_5_15","$PREVIOUS_5_19"}
else
    printf "No outdated kernel(s) to remove.\n"
fi


I use eclean-kernel to keep only the last three merged kernel with -s "mtime" option. As a result, previous 5.10, 5.15 and 5.19 kernels are cleaned and only the last one from each branch is kept.

Then, I use eix to find the previous installed kernel for 5.10 and 5.15 and 5.19 branches and --depclean them.

When I want to use --depclean globally,I just use "# emerge --depclean --exclude gentoo-sources" since it's now taken cared of by the script.

I thought it could be interesting to some other users.

Feel free to suggest any improvement.
Back to top
View user's profile Send private message
Hu
Moderator
Moderator


Joined: 06 Mar 2007
Posts: 21631

PostPosted: Sat Aug 13, 2022 3:06 pm    Post subject: Reply with quote

What is the point of keeping multiple major kernel series like this? I can see keeping a backup kernel version around until you are sure the new one is good, but usually that is only one backup kernel, and usually within the same series. If you explain your goal, we might be able to suggest a better way to achieve that goal.
Back to top
View user's profile Send private message
eeckwrk99
Apprentice
Apprentice


Joined: 14 Mar 2021
Posts: 163
Location: Gentoo forums

PostPosted: Sat Aug 13, 2022 4:34 pm    Post subject: Reply with quote

Hu wrote:
What is the point of keeping multiple major kernel series like this? I can see keeping a backup kernel version around until you are sure the new one is good, but usually that is only one backup kernel, and usually within the same series. If you explain your goal, we might be able to suggest a better way to achieve that goal.


I recently had major issues with VirtualBox 6.1.34. I also have an Arch Linux install on the same machine with latest stable + LTS kernels. My virtual machines suddenly became completely unusable on both Arch (5.15 kernel) and Gentoo (5.18 / 5.15 / 5.10). They would only work fine on Arch with 5.18 kernel for some reasons, maybe because Arch maintainers included some fixes, I don't know.

See these threads: 1 - 2

In the Manjaro forums thread, a user went back to 5.4 and finally got usable VMs. 5.18 and 5.4 were apparently the two branches with less or even no issues at all.

It's been fixed with 6.1.36 but that was frustrating because I spent quite a lot of time finding the culprit. I switched to QEMU/KVM + virt-manager since then but you never know what can happen with kernel updates. So I eventually decided I would keep three branches on Gentoo. Let's say something breaks for me on 5.19 and the issue is somehow back-ported to 5.15, then I can still try 5.10. Or even older branches because Gentoo allows to do so.

I know it might sound a bit overkill but 5.10 EOL is December 2026 and compilation for one kernel takes betwen 10 and 15 minutes with my current hardware so why not?
Back to top
View user's profile Send private message
Hu
Moderator
Moderator


Joined: 06 Mar 2007
Posts: 21631

PostPosted: Sat Aug 13, 2022 5:09 pm    Post subject: Reply with quote

That is an exceedingly slow kernel build. Mine complete in under 3 minutes. ;)

I see the value in being able to go back to older branches, but I don't see the point in proactively keeping all those older branches installed just in case you might need them. If you hit a regression, install an older kernel as needed to deal with it. Gentoo's ability to offer multiple kernel versions also means it's easy enough to bring in old kernel sources later. You ought to always keep at least one older known-good kernel when upgrading, so you also have the option of falling back to that while getting the latest of an old line.
Back to top
View user's profile Send private message
eeckwrk99
Apprentice
Apprentice


Joined: 14 Mar 2021
Posts: 163
Location: Gentoo forums

PostPosted: Sat Aug 13, 2022 5:50 pm    Post subject: Reply with quote

Hu wrote:
That is an exceedingly slow kernel build. Mine complete in under 3 minutes. ;)


Threadripper? :)

It takes 10~15 minutes for me (i7-5820k) because I also have to run
Code:
# emerge @module-rebuild
for x11-drivers/nvidia-drivers and I'm using LVM on LUKS so I also have to build an initramfs with genkernel.

Hu wrote:
I see the value in being able to go back to older branches, but I don't see the point in proactively keeping all those older branches installed just in case you might need them. If you hit a regression, install an older kernel as needed to deal with it. Gentoo's ability to offer multiple kernel versions also means it's easy enough to bring in old kernel sources later. You ought to always keep at least one older known-good kernel when upgrading, so you also have the option of falling back to that while getting the latest of an old line.


I prefer dealing with new kernel options gradually, although LTS kernels don't receive many changes of course. But I see your point, I could stop right after
Code:
# make oldconfig
without compiling.
Back to top
View user's profile Send private message
Genone
Retired Dev
Retired Dev


Joined: 14 Mar 2003
Posts: 9527
Location: beyond the rim

PostPosted: Sun Aug 14, 2022 9:44 pm    Post subject: Reply with quote

Goverp wrote:
alamahant wrote:
You cant.
Although gentoo-sources is slotted it is slotted with the full version of the kernel.
...

That seems pointless. Fixes to kernel-V.R.M will be kernel-V.R.M+1, and surely the purpose of a slotted package is to be able to maintain (as in use and keep patched) of said package.

The point of kernel slots is to support external kernel modules. And as any version bump can include kernel-space ABI breaks you need to include the full version in the slot.
Or why else would you want to keep multiple kernels around in the first place?
Back to top
View user's profile Send private message
Goverp
Advocate
Advocate


Joined: 07 Mar 2007
Posts: 2006

PostPosted: Mon Aug 15, 2022 9:17 am    Post subject: Reply with quote

Genone wrote:
The point of kernel slots is to support external kernel modules. And as any version bump can include kernel-space ABI breaks you need to include the full version in the slot.
Or why else would you want to keep multiple kernels around in the first place?

I thought (a) Linus was really rather upset about ABI breaks, and (b) I'm talking about that third level, which is fixes between kernel version bumps.
_________________
Greybeard
Back to top
View user's profile Send private message
Genone
Retired Dev
Retired Dev


Joined: 14 Mar 2003
Posts: 9527
Location: beyond the rim

PostPosted: Mon Aug 15, 2022 12:37 pm    Post subject: Reply with quote

Goverp wrote:
Genone wrote:
The point of kernel slots is to support external kernel modules. And as any version bump can include kernel-space ABI breaks you need to include the full version in the slot.
Or why else would you want to keep multiple kernels around in the first place?

I thought (a) Linus was really rather upset about ABI breaks, and (b) I'm talking about that third level, which is fixes between kernel version bumps.

Kernel devs don't like breaking the ABI for userspace. They don't care about the kernelspace ABI though in any way: https://www.kernel.org/doc/Documentation/process/stable-api-nonsense.rst

And keep in mind the SLOT policy has been in place since kernel version 2.6.x when the meaning of 'z' was quite different.
Back to top
View user's profile Send private message
logrusx
Veteran
Veteran


Joined: 22 Feb 2018
Posts: 1532

PostPosted: Mon Aug 15, 2022 1:48 pm    Post subject: Reply with quote

alamahant wrote:
You cant.


That's not correct.

Goverp wrote:
alamahant wrote:
You cant.
Although gentoo-sources is slotted it is slotted with the full version of the kernel.
...

That seems pointless. Fixes to kernel-V.R.M will be kernel-V.R.M+1, and surely the purpose of a slotted package is to be able to maintain (as in use and keep patched) of said package.


Seems pointless because the above is not correct.

emerge =sys-kernel/gentoo-sources-<version here if still in tree>
or
emerge gentoo-sources:<version here if still in tree>

Emerged this way the kernels will survive depclean and version bumps.

Regarding why someone might need multiple kernel versions, that's not a subject of the original question.

Regards,
Georgi
Back to top
View user's profile Send private message
Hu
Moderator
Moderator


Joined: 06 Mar 2007
Posts: 21631

PostPosted: Mon Aug 15, 2022 3:34 pm    Post subject: Reply with quote

logrusx wrote:
Regarding why someone might need multiple kernel versions, that's not a subject of the original question.
We rather frequently get X-Y problems, so asking a user to justify their need is good practice. Often, we find that the user's real goal is more easily satisfied not by answering their initial question, but by understanding their goal and addressing the problem that they actually want to solve.
Back to top
View user's profile Send private message
madmin
n00b
n00b


Joined: 04 Nov 2018
Posts: 26

PostPosted: Mon Aug 15, 2022 3:43 pm    Post subject: Reply with quote

- Avoiding a kernel to be removed by "emerge --depclean -va" once a newer version is deploy:

A trash trick is to remove that version from the database.

The installed packages database is in /var/db/pkg/. Simply remove the whole directory of the version[s] you want to e ignored by emerge once installed.
Note: move that or these directories in some other place, outside of /var/db/pkg, at first, to not trash your system by trusting me blindly ; )

I used that to avoid to have to rebuild my kernel after each and every world update when I was happy with that version. This because I configure my kernels manually and "make oldconfig" is time consuming.

It can be done with any kind of package but I strongly recommend NOT to do that for standard software as emerge is there to keep systems clean.

- Avoiding kernel rebuild:

Kernels are sources, once compiled and pushed in /boot (and /lib/modules) or wherever you want, there is no need to rebuild them all after each emerge process. Here, my systems are requesting kernel rebuild when emerge tries to install drivers relying on present kernel AND gcc version has been changed since I compiled the mentioned kernel. This happens (to me) mainly when nvidia-drivers are about to be merged.

- rebuilding a already deployed kernel using multiple threads:

make clean
make -j12 bzImage modules
make modules_install

The point is to separate "make modules" and "make modules_install". On a clean kernel sources tree, asking "make" command to do all three tasks (kernel/bzImage, modules and modules installation/modules_install) will hang. Some issues with install order if I remember correctly.

Note that there are other options than bzImage. These are those I use for years, since I found a tutorial on how to compile my own kernel.

Cheers
Back to top
View user's profile Send private message
Hu
Moderator
Moderator


Joined: 06 Mar 2007
Posts: 21631

PostPosted: Mon Aug 15, 2022 4:48 pm    Post subject: Reply with quote

Deliberately breaking the package database is a terrible way to solve this, particularly since adding that kernel version to @world ought to protect it from a broad depclean, and is easier to undo.
Back to top
View user's profile Send private message
Display posts from previous:   
Reply to topic    Gentoo Forums Forum Index Portage & Programming 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