User:Immolo/OldKernelInstall
Any issues caused by following this are not Gentoo bugs. Gentoo dependencies exist for good reason and the project cannot support deviation. IRC support may be given in the form of helpful hints to solve your issue however, you must clearly state you are using an older kernel and why, while asking for help.
This system will be a security risk so direct access to the Internet should not be allowed.
This page makes use of
emerge --clean
to workaround some issues, this should not be copied on any other system and emerge --deselect
should be used instead.This guide is intended for those that need to use an older kernel as that's all the hardware supports. Throughout this guide we will be using a 2.6.39 kernel as it's the oldest recommended by Musl however, older ones can still work with it and feel free to add the needed fixes to this guide.
Gentoo on Older Kernels
Setup
Log into the system, create your partitions, mount them, change into that directory and then finally download the Musl stage3 tarball for your system (this guide will be using amd64 as the example.)
Due to these devices having a number of ways the above steps need to be completed this guide will start from unpacking the stage3:
root #
tar xvf stage3-amd64-musl-latest.tar.xz
Mount the required filesystems:
root #
mount --types proc /proc /mnt/gentoo/proc
root #
mount --rbind /sys /mnt/gentoo/sys
root #
mount --make-rslave /mnt/gentoo/sys
root #
mount --rbind /dev /mnt/gentoo/dev
root #
mount --make-rslave /mnt/gentoo/dev
root #
mount --bind /run /mnt/gentoo/run
root #
mount --make-slave /mnt/gentoo/run
root #
test -L /dev/shm && rm /dev/shm && mkdir /dev/shm
root #
mount --types tmpfs --options nosuid,nodev,noexec shm /dev/shm
root #
chmod 1777 /dev/shm /run/shm
/run isn't provided by all old host systems so you can ignore it if it's not there.
Next copy over /etc/resolv.conf
so Internet works in the chroot:
root #
cp --dereference /etc/resolv.conf /mnt/gentoo/etc/
Chroot into the system:
root #
chroot /mnt/gentoo /bin/bash
root #
source /etc/profile
Before moving on to the next step this is the time to setup make.conf
with the require common flags and use flags and finally run emerge-webrsync
.
root #
emerge-webrsync
Create Local Repository
Now, create a local repo for the kernel headers to match the device's kernel.
root #
emerge --ask eselect-repository
root #
eselect repository create local
root #
mkdir -p /var/db/repos/local/sys-kernel/linux-headers
root #
cp -r /var/db/repos/gentoo/sys-kernel/linux-headers/* /var/db/repos/local/sys-kernel/linux-headers/
root #
cd /var/db/repos/local/sys-kernel/linux-headers/
Next, create the required kernel headers version:
root #
nano linux-headers-2.6.39.ebuild
# Copyright 1999-2022 Gentoo Authors
# Distributed under the terms of the GNU General Public License v2
EAPI=7
ETYPE="headers"
H_SUPPORTEDARCH="alpha amd64 arc arm arm64 avr32 bfin cris frv hexagon hppa ia64 m32r m68k metag microblaze mips mn10300 openrisc ppc ppc64 s390 score sh sparc tile x86 xtensa"
inherit kernel-2 toolchain-funcs
detect_version
PATCH_VER="1"
SRC_URI="https://dev.gentoo.org/~vapier/dist/gentoo-headers-base-2.6.39.tar.xz
https://dev.gentoo.org/~vapier/dist/gentoo-headers-2.6.39-1.tar.xz"
S="${WORKDIR}/gentoo-headers-base-${PV}"
KEYWORDS="~alpha amd64 arm arm64 hppa ~ia64 ~m68k ~mips ppc ppc64 ~riscv ~s390 sparc x86 ~amd64-linux ~x86-linux"
BDEPEND="
app-arch/xz-utils
dev-lang/perl"
[ [ -n ${PATCH_VER} ] ] && PATCHES=( "${WORKDIR}"/${PV} )
src_unpack() {
# avoid kernel-2_src_unpack
default
}
src_prepare() {
# avoid kernel-2_src_prepare
default
}
src_test() {
einfo "Possible unescaped attribute/type usage"
grep -E -r \
-e '(^| [ [:space:](])(asm|volatile|inline)[ [:space:] (]' \
-e '\<([us](8|16|32|64))\>' \
.
emake ARCH="$(tc-arch-kernel)" headers_check
}
src_install() {
kernel-2_src_install
find "${ED}" \( -name '.install' -o -name '*.cmd' \) -delete || die
# delete empty directories
find "${ED}" -empty -type d -delete || die
# provided by libdrm (for now?)
rm -rf "${ED}"/$(kernel_header_destdir)/drm || die
}
Change the header sources to what you need and others can be obtained from here.
Create a manifest for the ebuild:
root #
ebuild linux-headers-2.6.39.ebuild manifest
Install Headers
First, remove sys-libs/libseccomp as it won't be supported by this kernel.
root #
emerge --clean sys-libs/libseccomp
Using --clean isn't recommended normally however, in this case it is required so we can emerge the 2.6.29 headers.
root #
emerge --ask =sys-kernel/linux-headers-2.6.39
This is the time to add USE="-seccomp"
to your make.conf
.
# These settings were set by the catalyst build script that automatically
# built this stage.
# Please consult /usr/share/portage/config/make.conf.example for a more
# detailed example.
COMMON_FLAGS="-march=native -O2 -pipe"
CFLAGS="${COMMON_FLAGS}"
CXXFLAGS="${COMMON_FLAGS}"
FCFLAGS="${COMMON_FLAGS}"
FFLAGS="${COMMON_FLAGS}"
CHOST="x86_64-gentoo-linux-musl"
# NOTE: This stage was built with the bindist Use flag enabled
PORTDIR="/var/db/repos/gentoo"
DISTDIR="/var/cache/distfiles"
PKGDIR="/var/cache/binpkgs"
# This sets the language of build output to English.
# Please keep this setting intact when reporting bugs.
LC_MESSAGES=C
#USEFLAGS
USE="-seccomp"
Now, create a package.mask so a newer kernel header isn't installed:
>sys-kernel/linux-headers-2.6.39
Ebuild fixes
Some ebuilds need to be edited to work.
sys-apps/shadow
This can be ignored on kernels newer than 4.13.
root #
mkdir -p /var/db/repos/local/sys-apps/shadow
root #
cp -r /var/db/repos/gentoo/sys-apps/shadow/* /var/db/repos/local/sys-apps/shadow
root #
cd /var/db/repos/local/sys-apps/shadow
The btrfs flag will case issues here so you will need to remove the --enable-btrfs
flag inside for for this to compile.
root #
ebuild shadow-4.12.13.ebuild manifest
net-misc/iputils
This section can be ignored on newer kernels (i.e 3.x)
net-misc/iputils cannot build due to the ipv6 headers so we need to disable this systemwide so only ipv4 can be used.
net-misc/iputils-20211215
USE="-seccomp -ipv6"
net-firewall/iptables
A header file is missing to allow net-forewall/iptables to successfully compile.
root #
mkdir -p /usr/include/linux/netfilter
/* SPDX-License-Identifier: GPL-2.0 WITH Linux-syscall-note */
#ifndef _NETFILTER_NF_LOG_H
#define _NETFILTER_NF_LOG_H
#define NF_LOG_TCPSEQ 0x01 /* Log TCP sequence numbers */
#define NF_LOG_TCPOPT 0x02 /* Log TCP options */
#define NF_LOG_IPOPT 0x04 /* Log IP options */
#define NF_LOG_UID 0x08 /* Log UID owning local socket */
#define NF_LOG_NFLOG 0x10 /* Unsupported, don't reuse */
#define NF_LOG_MACDECODE 0x20 /* Decode MAC header */
#define NF_LOG_MASK 0x2f
#define NF_LOG_PREFIXLEN 128
#endif /* _NETFILTER_NF_LOG_H */
sys-libs/libseccomp
Stop sys-libs/libseccomp from being pullied in the future
sys-libs/libseccomp-2.5.4
sys-libs/pam
sys-libs/pam won't build with earlier headers, so this will disable it.
USE="-seccomp -pam"
sys-apps/util-linux -su
This step doesn't appear to be needed anymore on older kernels and evdev is no longer supported in Gentoo
Replace sys-apps/systemd-utils with sys-fs/eudev
This can be ignored on kernels newer than 3.10.
sys-apps/systemd-utils won't work with the older headers so it needs to be replaced.
root #
emerge -C virtual/udev sys-fs/udev-init-scripts virtual/dev-manager sys apps/systemd-utils virtual/tmpfiles
Next. a patch is required to remove the V4L part being built:
root #
mkdir -p /etc/portage/patches/sys-fs/eudev
--- a/src/v4l_id/Makefile.am 2021-12-14 19:57:01.000000000 +0000
+++ b/src/v4l_id/Makefile.am 2022-10-26 01:52:38.581688184 +0000
@@ -1,14 +1 @@
-ACLOCAL_AMFLAGS = -I m4 ${ACLOCAL_FLAGS}
-AM_CPPFLAGS = \
- -I $(top_srcdir)/src/shared
-
-udevlibexec_PROGRAMS = \
- v4l_id
-
-v4l_id_SOURCES = \
- v4l_id.c
-
-v4l_id_LDADD = \
- $(top_builddir)/src/libudev/libudev-private.la \
- $(top_builddir)/src/udev/libudev-core.la
root #
emerge --ask sys-fs/eudev
Some fixes need to be applied:
root #
mkdir -p /var/db/repos/local/virtual/tmpfiles
root #
cp -r /var/db/repos/gentoo/virtual/tmpfiles/* /var/db/repos/local/virtual/tmpfiles/
Edit the ebuild to remove everything after the RDEPEND line in the local repo copy.
root #
ebuild /var/db/repos/local/virtual/tmpfiles/tmpfiles-0-r3.ebuild manifest
Finally, emerge sys-apps/opentmpfiles:
root #
mkdir -p /etc/portage/package.unmask
sys-apps/opentmpfiles
root #
emerge --ask sys-apps/opentmpfiles
Re-emerge the system
Emerge the system again to take advantage of your new flags and rebuild against the correct headers for your system.
root #
emerge --ask --emptytree @system
The base system is now installed, so now continue with original handbook for your system to make it bootable.
Known Packages to Fail under 2.6.39
net-misc/dhcpcd Can be replaced with net-dns/ddclient
See also
- /etc/portage/profile/package.provided
- /etc/portage/package.mask — a file, or a directory of files, controlled by the system administrator that can be used to prevent certain packages from being installed.