anatol / booster

Fast and secure initramfs generator
MIT License
504 stars 45 forks source link

add gentoo kernel config path search #270

Open alexminder opened 1 month ago

alexminder commented 1 month ago

Hello, On Gentoo kernel config placed in /lib/modules/KVER/config. Can you add it for booster in to search path?

anatol commented 1 month ago

Are you talking about kernel config file?

If yes the code is located here https://github.com/anatol/booster/blob/276a3efc4336e866e3944359ecd86658d6354eb9/generator/kmod.go#L732

note that booster also falls back to /proc/config and /proc/config.gz files. Do you have it available at your machine?

alexminder commented 1 month ago

Are you talking about kernel config file? If yes the code is located here https://github.com/anatol/booster/blob/276a3efc4336e866e3944359ecd86658d6354eb9/generator/kmod.go#L732

Yes.

I added block wich works for me:

      } else if f, err := os.Open("/lib/modules/" + kernelVersion + "/config"); err == nil {
              // Gentoo specific config path.
              debug("reading %s", f.Name())
              defer f.Close()
              r = f

note that booster also falls back to /proc/config and /proc/config.gz files. Do you have it available at your machine?

Config in /proc shows current (booted) kernel version. But if we build initramfs for new kernel version with changed kernel config, a new kernel may fail to boot. For example, root device driver was built-in , but in new config it changed to module.

anatol commented 1 month ago

@alexminder your change looks good to me. Could you please send a PR with it?

A related item is to add Gentoo into set of tested platforms. To make that happen I need a script that creates an image with Gentoo system. Something like this one https://github.com/anatol/booster/blob/master/tests/generators/alpinelinux.sh AUR has portage package which is a good sight that creating a Gentoo image is possible.

anatol commented 4 weeks ago

@alexminder the question with Gentoo testing is still open.

If you can provide me the simplest set of commands that creates a Gentoo image (similar to this script https://github.com/anatol/booster/blob/master/tests/generators/alpinelinux.sh) then I can add an integration test for Gentoo and it will help to catch problems with the disto early.

desultory commented 4 weeks ago

@alexminder your change looks good to me. Could you please send a PR with it?

A related item is to add Gentoo into set of tested platforms. To make that happen I need a script that creates an image with Gentoo system. Something like this one https://github.com/anatol/booster/blob/master/tests/generators/alpinelinux.sh AUR has portage package which is a good sight that creating a Gentoo image is possible.

If you'd like to support gentoo, installkernel hooks would be very nice. https://github.com/desultory/ugrd/blob/main/hooks/installkernel/52-ugrd.install

The hook should pretty much just check that the relevant initrd_generator is set, then take the supplied kernel version and whatnot to make an image.