Article View: linux.gentoo.user
Article #106Re: [gentoo-user] Building a custom kernel
From: Michael
Date: Sat, 07 Nov 2026 09:40
Date: Sat, 07 Nov 2026 09:40
182 lines
9766 bytes
9766 bytes
--nextPartQm0sF4zQQweCj7ucuFJ4QA
Content-Transfer-Encoding: 7Bit
Content-Type: text/plain; charset="utf-8"; protected-headers="v1"
From: Michael <confabulate@kintzios.com>
To: gentoo-user@lists.gentoo.org
Reply-To: confabulate@kintzios.com
Subject: Re: [gentoo-user] Building a custom kernel
Date: Sat, 07 Nov 2026 09:25:29 +0000
Message-ID: <-S0VXcOcTBWNNRHMUe7B8A@kintzios.com>
In-Reply-To: <06ed66b8-a78e-4a5d-9d68-3f935d397d2b@oldfart.online>
MIME-Version: 1.0
On Friday, 6 November 2026 18:16:13 Greenwich Mean Time Pocket wrote:
> On 11/6/26 10:40, Michael wrote:
> > On Friday, 6 November 2026 15:10:33 Greenwich Mean Time Pocket
wrote:
> >> I have my gentoo project going very well and I would like to
> >> rebuild
> >> the rpi kernel to have btrfs built into the kernel instead of a
> >> module.
> >>
> >> I want to use btrfs as the filesystem for the root partition as I
> >> do
> >> on my archlinux systems.
> >>
> >> I have looked at the ebuilds for kernels and I can not figure them
> >> out. I have looking into portage as a later project after I finish
> >> this desktop project.
> >>
> >> I have three options at this point.
> >>
> >> 1. Use my custom kernel build from archlinuxarm using my PKGBUILD
> >> and
> >> remove the ebuild and extract the package archive to system.
> >>
> >> 2. Modify a kernel ebuild.
> >>
> >> 3. Create a initramfs
> >>
> >>
> >> Any one have any hints or direction on how to accomplish this?
> >
> > In the first instance you can read these pages a couple of times to
> > get a grounding on what options Gentoo offers, both in its
> > distribution kernels and DIY from source:
> >
> > https://wiki.gentoo.org/wiki/Handbook:AMD64/Installation/Kernel
> > https://wiki.gentoo.org/wiki/Kernel
> >
> > If you know your archlinuxarm is exactly, or mostly, what you want
> > from a kernel configuration, you can use the archlinuxarm
> > configuration to get you ready to compile your own kernel from
> > source. The general idea is to follow the basic steps below:
> >
> > 1. First emerge sys-kernel/gentoo-sources.
> > 2. Check what modules are loaded when you boot with your
> > archlinuxarm
> > kernel. You may wish to build some of these in-kernel, as opposed
> > to
> > have them as loadable modules and exclude any modules which do not
> > need if you want to keep the kernel image small(er) in size.
> > 3. Copy the archlinuxarm running .config into the gentoo-sources
> > installed in /usr/src/linux/.
> > 4. Run 'make oldconfig', followed by 'make menuconfig' to adjust the
> > configuration as you want.
> > 5. Compile and install as described at the bottom of the Handbook
> > page above.
> >
> > The above should get you mostly there. You can use dracut or a UKI
> > if you need an initramfs.
> >
> > HTH.
>
> I have a archlinux PKGBUILD that I wrote to build a custom kernel.
>
> The upstream source is from raspberrypi kernel sources and I modiify
> .config to add btrfs as built in not a module.
>
> I thought I could convert the PKGBUILD to ebuild then add it to a
> custom repository, then emerge that.
>
> Looking at the gentoo kernel ebuilds didn't give me a way forward.
> I am still looking at that. My PKGBUILD file is nothing like the
> gentoo ebuild.
>
> Goes something like this......
>
>
> https://github.com/raspberrypi/linux/archive/refs/tags/stable_20260911
> .tar.gz
>
> prepare() {
> cd "$srcdir"/"$_pkgname"_"$_pkgver"
> make mrproper
> make bcm2711_defconfig
> sed -e '/^CONFIG_BTRFS_FS/s|m|y|' -i .config
> make oldconfig
> }
>
> build() {
> cd "$srcdir"/"$_pkgname"_"$_pkgver"
> make Image.gz modules dtbs
> }
>
> then package that into a tar archive'
> package() {
> # variables
> make -s kernelrelease > version
> version="$(< version)"
>
> # Install kernel modules
> mkdir -vp "$pkgdir/usr"
> make INSTALL_MOD_PATH="$pkgdir/usr" INSTALL_MOD_STRIP=1 \
> DEPMOD=/doesnt/exist modules_install # Suppress
depmod
>
> # Install kernel and firmware
> mkdir -vp "${pkgdir}"/boot/overlays
> cp -v arch/arm64/boot/Image.gz "${pkgdir}"/boot/$KERNEL.img
> cp -v arch/arm64/boot/dts/broadcom/*.dtb "${pkgdir}"/boot/
> cp -v arch/arm64/boot/dts/overlays/*.dtb* "${pkgdir}"/boot/
overlays
> cp -v arch/arm64/boot/dts/overlays/README "${pkgdir}"/boot/
overlays
>
> # Versioning, system map and configuration
> cp -v version "${pkgdir}"/boot/
> cp -v System.map "${pkgdir}"/boot/System.map-"$version"
> cp -v .config "${pkgdir}"/boot/config-"$version"
>
> # Boot and Configuration
> cp -v "$srcdir"/cmdline.txt "${pkgdir}"/boot/
> cp -v "$srcdir"/config.txt "${pkgdir}"/boot/
>
> # Remove symlink that points to file in the building
directory
> unlink "${pkgdir}"/usr/lib/modules/6.18.50-v8/build
> }
>
> I guess I could make a shell script to install directly to /boot and
> /usr but I was really looking to make an ebuild for this.
> A PKGBUILD is nothing more than a shell script that makepkg calls.
>
>
> I don't really need or want an initramfs
If you first configure, compile and build the kernel manually as you
want it to be, you'll be able to modify your script to do the same for
you.
For ebuilds which perform similar, check the distribution kernel
ebuilds, e.g.:
/var/db/repos/gentoo/sys-kernel/gentoo-kernel/gentoo-kernel-7.3.1.ebuild
/var/db/repos/gentoo/sys-kernel/gentoo-kernel-bin/gentoo-kernel-
bin-7.3.1.ebuild
--nextPartQm0sF4zQQweCj7ucuFJ4QA
Content-Type: application/pgp-signature; name="signature.asc"
Content-Description: This is a digitally signed message part.
Content-Transfer-Encoding: 7Bit
-----BEGIN PGP SIGNATURE-----
iQJPBAABCAA5FiEEXqhvaVh2ERicA8Ceseqq9sKVZxkFAmru7okbFIAAAAAABAAO
bWFudTIsMi41KzEuMTIsMiwyAAoJELHqqvbClWcZMxgQAKBzCfDxvM08Ttn8xGhm
Imi75QAMsAnsC55gZXD3BOraWSv1Wkl3omdXJJeNayHff7qZsfldaJt1/hzxTPPF
C0n2t7xDELTt7xeUXwfmcaySYMo5MyeRHEp2hRC/emocoptiCwyl/Mr5zvjAc2DI
yDgWDAmU4h+ZKUOon098LpLaqefr3OCxac+0Ztnh1RGBJoGh60hfx1k9dsfSxr7o
oo3SKWMBKZJPdUJOTfkeECNnfWHQWl5mP9rL+6KgZubN2Z3WEOLBQXDJv3SYkLSj
PAdrBjplNc/cft2z9YGmsOM6/GTE2JcimrLM4c4duql5iBZ2iIiBDlQEFXxRofX5
d24rrQtRFVzlHcIPrQ8mbWeCD8nelH4Oi6VqxrTBhIW+WO3fT1Qx0F+qZIfIPVQ2
4tNJSLPZ1Itn6WfJHRTK/VXevdUMGH1Ab3Y+kvxRBuymSsxKIeUKaQcT11EeG41g
xNRGGSyaOpIbdlRdA9HizhFu7nLG+4265Doacf83HsPuEGpvlQqHqhXiHJUr0tKc
Dixe0jyBM/YUp1020uImNPt4SxRSH+yFmXSlTCqgqi4RUWlyK0vOmK5+povsZs83
5SSaq8h2iwxZlLVJt258XlR96Eez6BqXwuhKUHhgAQPh/CU4Pm77b8GurgN5onpx
w4nrgqYtABJmdt7WWwbOMYhe
=TCP5
-----END PGP SIGNATURE-----
--nextPartQm0sF4zQQweCj7ucuFJ4QA--
Technical Details
Message-ID:
<NWL3X-amLC-3@gated-at.bofh.it>Path:
mbox-mo1.pugleaf.net!archive.usenet.blueworldhosting.com!usenet.blueworldhosting.com!diablo1.usenet.blueworldhosting.com!news.nntp4.net!news.samoylyk.net!gothmog.csi.it!bofh.it!news.nic.it!robomodReferences:
<NWL3X-amLC-5@gated-at.bofh.it> <NWtTs-adpa-21@gated-at.bofh.it> <NWumt-adAe-13@gated-at.bofh.it> <NWwHD-aeXC-15@gated-at.bofh.it>Show Full Headers
Complete Article Headers
Path: mbox-mo1.pugleaf.net!archive.usenet.blueworldhosting.com!usenet.blueworldhosting.com!diablo1.usenet.blueworldhosting.com!news.nntp4.net!news.samoylyk.net!gothmog.csi.it!bofh.it!news.nic.it!robomod
From: Michael <confabulate@kintzios.com>
Newsgroups: linux.gentoo.user
Subject: Re: [gentoo-user] Building a custom kernel
Date: Sat, 07 Nov 2026 10:40:01 +0100
Message-ID: <NWL3X-amLC-3@gated-at.bofh.it>
References: <NWL3X-amLC-5@gated-at.bofh.it> <NWtTs-adpa-21@gated-at.bofh.it> <NWumt-adAe-13@gated-at.bofh.it> <NWwHD-aeXC-15@gated-at.bofh.it>
X-Sender-ID: thundermail|x-authsender|confabulate@kintzios.com
X-Sender-ID: thundermail|x-authsender|confabulate@kintzios.com
X-Mc-Relay: Neutral
X-Mc-Copy: stored-urls
X-Mailchannels-Senderid: thundermail|x-authsender|confabulate@kintzios.com
X-Mailchannels-Auth-ID: thundermail
X-Rock-Share: 7ba0037e08aaa0cb_1794043560698_2159009459
X-Mc-Loop-Signature: 1794043560698:1808770659
X-Mc-Ingress-Time: 1794043560698
Authentication-Results: cloud238.thundercloud.uk;
spf=pass (sender IP is 217.169.3.230) smtp.mailfrom=confabulate@kintzios.com smtp.helo=rogueboard.localnet
Received-Spf: pass (cloud238.thundercloud.uk: connection is authenticated)
List-ID: Gentoo Linux mail <gentoo-user.gentoo.org>
Reply-To: gentoo-user@lists.gentoo.org
X-Auto-Response-Suppress: DR, RN, NRN, OOF, AutoReply
MIME-Version: 1.0
Content-Type: multipart/signed; boundary="nextPartQm0sF4zQQweCj7ucuFJ4QA";
micalg="pgp-sha256"; protocol="application/pgp-signature"
X-Ppp-Message-ID:
<179404355755.141723.4810064850915229230@cloud238.thundercloud.uk>
X-Ppp-Vhost: kintzios.com
X-Rspamd-Queue-ID: 4jM9df2N5XzGnsd
X-Rspamd-Server: mailclean11
X-Rspamd-Action: no action
X-Spamd-Result: default: False [-2.10 / 999.00];
SIGNED_PGP(-2.00)[];
ONCE_RECEIVED(0.20)[];
MIME_GOOD(-0.20)[multipart/signed,text/plain];
MX_GOOD(-0.10)[mail.kintzios.com];
RCVD_TLS_ALL(0.00)[];
RCVD_VIA_SMTP_AUTH(0.00)[];
R_SPF_ALLOW(0.00)[+mx];
RCPT_COUNT_ONE(0.00)[1];
RCVD_COUNT_ONE(0.00)[1];
ARC_NA(0.00)[];
ASN(0.00)[asn:34931, ipnet:149.255.60.0/22, country:GB];
MISSING_XM_UA(0.00)[];
MIME_TRACE(0.00)[0:+,1:+,2:~];
DMARC_POLICY_ALLOW(0.00)[kintzios.com,none];
MID_RHS_MATCH_FROM(0.00)[];
R_DKIM_NA(0.00)[];
REPLYTO_ADDR_EQ_FROM(0.00)[];
FROM_EQ_ENVFROM(0.00)[];
FROM_HAS_DN(0.00)[];
HAS_REPLYTO(0.00)[confabulate@kintzios.com];
UWH_IDENTITY(0.00)[1|770476ccaef69fa3|t=258|r=0|m=postfix|n=15|h=pppm:1:13/1+pppv:1:14/0|f=nv];
TO_MATCH_ENVRCPT_ALL(0.00)[];
TO_DN_NONE(0.00)[];
PREVIOUSLY_DELIVERED(0.00)[gentoo-user@lists.gentoo.org];
REPLYTO_DOM_NEQ_TO_DOM(0.00)[]
Approved: robomod@news.nic.it
Lines: 182
Organization: linux.* mail to news gateway
Sender: robomod@news.nic.it
X-Original-Date: Sat, 07 Nov 2026 09:25:29 +0000
X-Original-Message-ID: <-S0VXcOcTBWNNRHMUe7B8A@kintzios.com>
X-Original-References:
<96dbc5af-dc8c-450e-9b4e-1e6a40be4cdd@oldfart.online>
<hokyXLvHR06uCKzIA5XC-g@kintzios.com>
<06ed66b8-a78e-4a5d-9d68-3f935d397d2b@oldfart.online>