Discussion:
How to customize the kernel
(too old to reply)
Chris Marusich
2017-12-16 02:37:17 UTC
Permalink
Hi,

Suppose you want to compile a custom kernel. Suppose you want to use a
custom kernel configuration. Currently, none of the logic that builds
linux-libre kernels in Guix is public,, so the implication is that
nobody should be using that to customize their kernel builds.

Is anyone building custom kernels? How are you doing it? Are you just
using the "make-linux-libre" procedure anyway, despite the fact that it
supposedly isn't public? Did you copy it and just modify it to suit
your needs? Or did you do something totally different?

I am new to compiling the Linux kernel, so it is doubly difficult to
learn how I should do it using Guix. Any tips would be greatly
appreciated. I'm guessing one tip might be, "Try building a few Linux
kernels on a more normal distribution, not using Guix, a few times to
get the hang of doing it the 'traditional' way first." I have not
really done that yet.
--
Chris
Andy Wingo
2017-12-18 09:26:56 UTC
Permalink
Post by Chris Marusich
Is anyone building custom kernels? How are you doing it? Are you just
using the "make-linux-libre" procedure anyway, despite the fact that it
supposedly isn't public? Did you copy it and just modify it to suit
your needs? Or did you do something totally different?
To build upstream kernels I just do a (package (inherit linux-libre)
...) and include a customized (source) pointing to the upstream kernel.
I don't change the config though. For what it's worth :)

Andy
Marius Bakke
2017-12-18 12:21:25 UTC
Permalink
Post by Chris Marusich
Is anyone building custom kernels? How are you doing it? Are you just
using the "make-linux-libre" procedure anyway, despite the fact that it
supposedly isn't public? Did you copy it and just modify it to suit
your needs? Or did you do something totally different?
Here is my approach:

--8<---------------cut here---------------end--------------->8---
(define-module (my packages)
#:use-module (gnu packages linux))

(define kernel-config
(string-append (dirname (current-filename)) "/kernel.config"))

(define-public my-kernel
(package
(inherit linux-libre)
(native-inputs
`(("kconfig" ,kernel-config)
,@(alist-delete "kconfig"
(package-native-inputs linux-libre))))))

(use-modules (my packages))
(operating-system
[...]
(kernel my-kernel)
--8<---------------cut here---------------end--------------->8---

This lets me keep the kernel .config in version control along with the
system configuration.
Post by Chris Marusich
I am new to compiling the Linux kernel, so it is doubly difficult to
learn how I should do it using Guix. Any tips would be greatly
appreciated. I'm guessing one tip might be, "Try building a few Linux
kernels on a more normal distribution, not using Guix, a few times to
get the hang of doing it the 'traditional' way first." I have not
really done that yet.
Working with custom kernels in Guix is simpler than in many other
distros IMO. Suppose you have a patched Linux-Libre tree, then you
could add e.g.:

(source "/path/to/custom/kernel")

to the package declaration above. Be aware that rolling back to the
previous generation might not work if your computer implodes ;-)

For starting out, I would recommend copying the GuixSD default config[*]
to /your/kernel/tree/.config and run:

guix environment linux-libre --ad-hoc ncurses -- make nconfig

This will present a nice ncurses-based interface for configuring the
kernel. Note that if the kernel major+minor is higher than the .config
(see top of file), you should run `make oldconfig` first which gives an
interactive "wizard" that walks you through all the new options.

Good luck! :-)

[*] You can also start from `make defconfig` if you feel adventurous.
Vincent Legoll
2017-12-18 13:45:47 UTC
Permalink
Hello,
Post by Marius Bakke
--8<---------------cut here---------------end--------------->8---
(define-module (my packages)
#:use-module (gnu packages linux))
(define kernel-config
(string-append (dirname (current-filename)) "/kernel.config"))
(define-public my-kernel
(package
(inherit linux-libre)
(native-inputs
`(("kconfig" ,kernel-config)
(package-native-inputs linux-libre))))))
(use-modules (my packages))
(operating-system
[...]
(kernel my-kernel)
--8<---------------cut here---------------end--------------->8---
The above should be put somewhere in the doc, faq, maybe
in a sample system config, or whatever.

Early adopters will probably want to do just that (at least I did,
when I tried GuixSD for the first time).
--
Vincent Legoll
Loading...