View previous topic :: View next topic |
Author |
Message |
librin.so.1 n00b
Joined: 16 Sep 2014 Posts: 5 Location: Kaunas, Lithuania
|
Posted: Thu Nov 21, 2024 2:06 pm Post subject: genkernel keeps overwriting .config |
|
|
How do I stop genkernel from trying to overwrite my .config?
All I want genkernel to do here is build the kernel with the .config file provided, exactly as-is, yet it keeps trying to change it as if it knows better (it doesn't).
I read through the man page, yet I cannot find an option to not do this.
I tried to chattr +i .config, but that only makes genkernel barf and quit as it tries to change it. _________________ "why do you wear glasses if you're deaf?" –Kenji |
|
Back to top |
|
|
grknight Retired Dev
Joined: 20 Feb 2015 Posts: 1932
|
Posted: Thu Nov 21, 2024 2:42 pm Post subject: |
|
|
--no-clean option, or, better, copy the config to /etc/kernels/ with a name like kernel-config-x86_64-6.6.52-gentoo which varies by kernel build arch and version
genkernel always prefers the config in /etc/kernels/ if it exists |
|
Back to top |
|
|
logrusx Advocate
Joined: 22 Feb 2018 Posts: 2453
|
Posted: Thu Nov 21, 2024 3:09 pm Post subject: |
|
|
I stopped using genkernel a long time ago exactly because of its strange behavior. It also was unable to produce initramf which would enable my touchpad, no matter what. I moved to dracut because it was used in gentoo-kernel who's pre-built counterpart did enable my touchpad. Later I abandoned those tools altogether and stopped using intramfs. If you don't need initramfs, that's a viable option. You just need a few things built into the kernel, including some firmware and microcode if your hardware needs any.
Best Regards,
Georgi |
|
Back to top |
|
|
librin.so.1 n00b
Joined: 16 Sep 2014 Posts: 5 Location: Kaunas, Lithuania
|
Posted: Thu Nov 21, 2024 5:08 pm Post subject: |
|
|
A big thank you for all the replies!
grknight wrote: | --no-clean option, or, better, copy the config to /etc/kernels/ with a name like kernel-config-x86_64-6.6.52-gentoo which varies by kernel build arch and version
genkernel always prefers the config in /etc/kernels/ if it exists |
I already run it with both --no-clean and --no-mrproper options.
To clarify, it doesn't clean away the .config file, it modifies it. It also modifies the config file if I put it under /etc/kernels/
to give a few examples of what it does (but this is not an exhaustive list, if I would list everything, the post would be uncomfortably long)
- it changes CONFIG_LOCALVERSION and there seems to be no option to avoid that. At the time of writing, the only options I managed to find are: either default behavior (overwrite it with dash-µarch e.g. -x86_64, set it with --kernel-localversion or append something to the default one with --kernel-append-localversion. But an option to simply not touch it and use CONFIG_LOCALVERSION as already set in the .config file? Nope.
- it sets options such as CONFIG_MD_RAID{0,1,10,456} and some other options, too, if --mdadm option is given. I need mdadm support, but I don't want it to change the kernel config.
again, the list is non-exhaustive; I don't want to barf a wall of text here listing every single such case.
some background: I used to run Gentoo some years ago, until I moved to Funtoo for reasons I don't remember.
When I used Gentoo back in the day, genkernel wouldn't attempt to modify the kernel config like this, neither would the Funtoo fork of genkernel would do it. Several months ago, as Funtoo has been EOL'd I moved back to Gentoo and now genkernel is doing very unexpected things – namely changing my kernel config no matter what and with no clear way to make it stop. Assuming it can stop. I fear it has been changed far too much and always tries to be """smart""" where, in my case, it ought not do so.
So far I have kept around a partition containing a Funtoo installation on one of my machines specifically so I could chroot into it and build me a kernel+initramfs, but that's just silly.
I need to find a solution from within Gentoo itself.
logrusx wrote: | I stopped using genkernel a long time ago exactly because of its strange behavior. It also was unable to produce initramf which would enable my touchpad, no matter what. I moved to dracut because it was used in gentoo-kernel who's pre-built counterpart did enable my touchpad. Later I abandoned those tools altogether and stopped using intramfs. If you don't need initramfs, that's a viable option. You just need a few things built into the kernel, including some firmware and microcode if your hardware needs any. |
in my case, I absolutely need an initramfs due to reasons including, but not limited to:
- the root partition on all my machines is encrypted
- /boot and / are not even on the same device
_________________ "why do you wear glasses if you're deaf?" –Kenji |
|
Back to top |
|
|
szatox Advocate
Joined: 27 Aug 2013 Posts: 3460
|
Posted: Thu Nov 21, 2024 5:15 pm Post subject: |
|
|
--oldconfig
Other than that, genkernel always updates stuff like local build version, and AFAIR there were some things it used to pull from genkernel's config and force onto linux/.config, though looking at my genkernel.conf I can't remember what it was. _________________ Make Computing Fun Again |
|
Back to top |
|
|
logrusx Advocate
Joined: 22 Feb 2018 Posts: 2453
|
Posted: Thu Nov 21, 2024 5:17 pm Post subject: |
|
|
librin.so.1 wrote: |
in my case, I absolutely need an initramfs |
You can have it as part of the kernel itself, though I can't give you details on that.
Best Regards,
Georgi |
|
Back to top |
|
|
pietinger Moderator
Joined: 17 Oct 2006 Posts: 5157 Location: Bavaria
|
Posted: Thu Nov 21, 2024 6:26 pm Post subject: |
|
|
librin.so.1,
since you have used Gentoo before, you probably know that with Gentoo you can install everything the way you want it. When it comes to the kernel, I recommend not using the genkernel and instead either using our Gentoo distribution kernel or configuring the kernel yourself manually. If you also need an initramfs for the latter, there are even three options: “dracut”, ugrd” or a self-built initramfs. If you write that you have your partitions on different hard disks, I don't see a problem yet, because that shouldn't be an obstacle for a standard initramfs.
Why I do not recommend genkernel: Because in my opinion you need the same information/knowledge as for a manual configuration and you don't gain any advantage (nowadays), because you can easily create an initramfs yourself with ugrd. You might be interested in the following articles:
* https://wiki.gentoo.org/wiki/UgRD
* https://wiki.gentoo.org/wiki/User:Pietinger/Tutorials/Initramfs_Overview
* https://wiki.gentoo.org/wiki/User:Pietinger/Tutorials/Manual_kernel_configuration _________________ https://wiki.gentoo.org/wiki/User:Pietinger |
|
Back to top |
|
|
librin.so.1 n00b
Joined: 16 Sep 2014 Posts: 5 Location: Kaunas, Lithuania
|
Posted: Thu Nov 21, 2024 6:43 pm Post subject: |
|
|
pietinger wrote: | librin.so.1,
since you have used Gentoo before, you probably know that with Gentoo you can install everything the way you want it. When it comes to the kernel, I recommend not using the genkernel and instead either using our Gentoo distribution kernel or configuring the kernel yourself manually. If you also need an initramfs for the latter, there are even three options: “dracut”, ugrd” or a self-built initramfs. If you write that you have your partitions on different hard disks, I don't see a problem yet, because that shouldn't be an obstacle for a standard initramfs. |
Thank you for your reply!
To clarify, I don't have any problems with initramfs.
I configure the kernel myself and my .config is tuned very specifically to what I need. The problem arises in specifically building the kernel – genkernel keeps undoing some of my configuration choices and introduces its own.
But with some fiddling I think I finally found a workaround for most of it:
- run genkernel with --no-mdadm and --no-luks and tell it to only build the kernel
- run genkernel again, this time with --mdadm and --luks, and tell it to only bulld the initramfs
This prevents all changes to my .config file by genkernel except for CONFIG_LOCALVERSION – it changes this one no matter what I do.
nevertheless, this is such a hacky way to do it. I wish there was a better way... _________________ "why do you wear glasses if you're deaf?" –Kenji |
|
Back to top |
|
|
pietinger Moderator
Joined: 17 Oct 2006 Posts: 5157 Location: Bavaria
|
|
Back to top |
|
|
szatox Advocate
Joined: 27 Aug 2013 Posts: 3460
|
Posted: Thu Nov 21, 2024 8:11 pm Post subject: |
|
|
librin.so.1 wrote: |
- run genkernel with --no-mdadm and --no-luks and tell it to only build the kernel
- run genkernel again, this time with --mdadm and --luks, and tell it to only bulld the initramfs
|
I wonder, where does this discrepancy come from?
First, I remember those options as only affecting initramfs, has it changed? Second, if you need userspace tools, you certainly need modules too.
In what way exactly does it mess up your kernel config?
Quote: |
This prevents all changes to my .config file by genkernel except for CONFIG_LOCALVERSION – it changes this one no matter what I do.
| It makes sense to make this one dynamic, don't you think? Making every build uniquely identifiable is good for testing things and has no downsides in prod.
Local version is pulled from genkernel.config, so you can set it to arbitrary value. An empty string should be a valid value too, in case you don't want it at all. _________________ Make Computing Fun Again |
|
Back to top |
|
|
logrusx Advocate
Joined: 22 Feb 2018 Posts: 2453
|
Posted: Thu Nov 21, 2024 8:25 pm Post subject: |
|
|
szatox wrote: | An empty string should be a valid value too, in case you don't want it at all. |
An empty string will set it to an empty string unless genkernel applies some logic to it to determine it as unset. To have it unset, this option should be commented in .config.
Best Regards,
Georgi |
|
Back to top |
|
|
pietinger Moderator
Joined: 17 Oct 2006 Posts: 5157 Location: Bavaria
|
Posted: Thu Nov 21, 2024 10:32 pm Post subject: |
|
|
logrusx wrote: | [...] To have it unset, this option should be commented in .config. [...] |
This is not possible because the option CONFIG_LOCALVERSION is type "string" (and not bool or tristate) ... okay, you CAN delete this line in .config with an editor ... BUT ... when you want then compile ("make") a kernel with this .config you will get immediately a question (like you will get when you do a "make oldconfig") where you MUST enter a value for this option (with <return> you will get an empty but SET CONFIG_LOCALVERSION):
Code: | Local version - append to kernel release (LOCALVERSION) [] (NEW) |
_________________ https://wiki.gentoo.org/wiki/User:Pietinger |
|
Back to top |
|
|
jburns Veteran
Joined: 18 Jan 2007 Posts: 1220 Location: Massachusetts USA
|
Posted: Fri Nov 22, 2024 2:17 am Post subject: |
|
|
/etc/genkernel.conf contains options for controlling genkernel. KERNEL_LOCALVERSION would be of interest to you.
The genkernel command line option --config=<file> can be used to specify the config file to use.
explains the available options. |
|
Back to top |
|
|
sublogic Apprentice
Joined: 21 Mar 2022 Posts: 276 Location: Pennsylvania, USA
|
Posted: Fri Nov 22, 2024 3:45 am Post subject: |
|
|
librin.so.1 wrote: | in my case, I absolutely need an initramfs due to reasons including, but not limited to:
- the root partition on all my machines is encrypted
- /boot and / are not even on the same device
|
What are the other reasons ? Because once you have a working .config, I don't think you need genkernel anymore. Code: | make localyesconfig
make menuconfig
make; make modules_install install | will give you a kernel with all the currently loaded modules changed to builtin. That kernel can boot without any of the modules in the initramfs. (The "menuconfig" is to tweak things, like setting network and video drivers back to modular so they can load their firmware in late boot. Alternatively, embed the required firmware, but that is more trouble.)
Your kernel is now decoupled from the initramfs. You can keep the same initramfs for future kernels. Copy it to something like /boot/initramfs-generic and (assuming you use grub) cheat a little with the grub config: Code: | $ head -n 3 /etc/default/grub
# use a kernel-independent initramfs
# (see /etc/grub.d/10_linux)
GRUB_EARLY_INITRD_LINUX_CUSTOM="initramfs-generic" |
When you upgrade a kernel, Code: | cd /usr/src/linux
zcat /proc/config.gz > .config
make helpnewconfig > ~/junk
make olddefconfig
make menuconfig # tweak as needed based on new options in ~/junk |
You may need a few cycles of menuconfig tweaks at first. Plug a USB thumb drive and nothing happens: oops, the usb-storage module wasn't loaded and didn't get yessed. Add it back as a module.
If your root is on a network drive it gets complicated... but who does that these days ? |
|
Back to top |
|
|
flexibeast Guru
Joined: 04 Apr 2022 Posts: 473 Location: Naarm/Melbourne, Australia
|
Posted: Fri Nov 22, 2024 7:32 am Post subject: |
|
|
logrusx wrote: | I stopped using genkernel a long time ago exactly because of its strange behavior. It also was unable to produce initramf which would enable my touchpad, no matter what. |
pietinger wrote: | When it comes to the kernel, I recommend not using the genkernel and instead either using our Gentoo distribution kernel or configuring the kernel yourself manually. |
i've been getting the impression that use of genkernel is somewhat deprecated, or at least discouraged .... Are either of these things, or something akin to them, true? Because if so, i'd like to note it on the genkernel page on the wiki. _________________ https://wiki.gentoo.org/wiki/User:Flexibeast |
|
Back to top |
|
|
logrusx Advocate
Joined: 22 Feb 2018 Posts: 2453
|
Posted: Fri Nov 22, 2024 9:10 am Post subject: |
|
|
flexibeast wrote: | i've been getting the impression that use of genkernel is somewhat deprecated, or at least discouraged .... |
I wouldn't say it's either. There was a discussion about it some time ago with statements from some of the devs but good luck finding it. What I got from it is the code is somewhat hard to maintain and not many devs like it or even use it so there's not much desire to work on it.
I will not say more because I'm afraid I may misrepresent the reality about it.
But it's far from deprecated. The discourage part is completely subjective. Also afair there are things genkernel can that dracut can't do.
Best Regards,
Georgi |
|
Back to top |
|
|
ali3nx l33t
Joined: 21 Sep 2003 Posts: 732 Location: Winnipeg, Canada
|
Posted: Fri Nov 22, 2024 10:03 am Post subject: Re: genkernel keeps overwriting .config |
|
|
librin.so.1 wrote: | How do I stop genkernel from trying to overwrite my .config?
All I want genkernel to do here is build the kernel with the .config file provided, exactly as-is, yet it keeps trying to change it as if it knows better (it doesn't). |
the newer than genkernel distro kernel package gentoo-kernel is designed for this by using savedconfig portage features.
https://wiki.gentoo.org/wiki/Savedconfig
Perhaps i should mention the kernel config included by default with gentoo-kernel is a functionally complete .config maintained by the developers you can optionally alter. Use this config that by default should be added to /boot to study a complete kernel config _________________ Compiling Gentoo since version 1.4
Thousands of Gentoo Installs Completed
Emerged on every continent but Antarctica
Compile long and Prosper! |
|
Back to top |
|
|
|
|
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
|
|