Added kernel-extra.config for customization

This commit is contained in:
2026-03-21 02:26:13 +08:00
parent 9c97871f97
commit a7236ed3b0
9 changed files with 177 additions and 20 deletions

View File

@@ -1,20 +1,19 @@
#!/bin/sh
mount -t proc none /proc
mount -t sysfs none /sys
mount -t devtmpfs devtmpfs /dev
mount -t proc proc /proc
mount -t sysfs sysfs /sys
cat <<!
# Optional but nice
mkdir -p /dev/pts
mount -t devpts devpts /dev/pts
_ _ _ __ __ _
| | | (_) | \/ | | |
| |__| |_ | \ / | ___ _ __ ___ | |
| __ | | | |\/| |/ _ \| '_ \ / _ \| |
| | | | |_ | | | | (_) | | | | (_) |_|
|_| |_|_( ) |_| |_|\___/|_| |_|\___/(_)
|/
echo "Booting kernel took $(cut -d' ' -f1 /proc/uptime) seconds."
echo "Dropping to shell on ttyS0..."
Booting kernel took $(cut -d' ' -f1 /proc/uptime) seconds.
while true; do
setsid cttyhack /bin/sh
echo "Shell exited. Starting another one..."
done
!
exec /bin/sh
EOF
exec poweroff -f

107
initramfs/selective-mods.sh Executable file
View File

@@ -0,0 +1,107 @@
#!/usr/bin/env bash
set -euo pipefail
# Stage a subset of kernel modules into a target rootfs/initramfs tree.
#
# Example:
# ./stage-initramfs-modules.sh \
# /out/rootfs/lib/modules/6.18.2 \
# /out/initramfs
#
# Result:
# /out/initramfs/lib/modules/6.18.2/...
#
# Notes:
# - This copies selected directories and modules.* metadata.
# - It does NOT run depmod for you unless you uncomment that section.
# - Best run after kernel modules have already been installed into the source tree.
if [[ $# -ne 2 ]]; then
echo "Usage: $0 <source-lib-modules-version-dir> <dest-root>"
echo "Example: $0 /out/rootfs/lib/modules/6.18.2 /out/initramfs"
exit 1
fi
SRC_MODDIR="$1" # e.g. /out/rootfs/lib/modules/6.18.2
DEST_ROOT="$2" # e.g. /out/initramfs
if [[ ! -d "$SRC_MODDIR" ]]; then
echo "Source module dir does not exist: $SRC_MODDIR" >&2
exit 1
fi
KVER="$(basename "$SRC_MODDIR")"
DEST_MODDIR="$DEST_ROOT/lib/modules/$KVER"
mkdir -p "$DEST_MODDIR"
echo "==> Source: $SRC_MODDIR"
echo "==> Dest: $DEST_MODDIR"
echo
# Relative paths under /lib/modules/<version>
PATHS=(
# Metadata files used by modprobe/depmod.
"modules.builtin"
"modules.builtin.modinfo"
"modules.order"
"modules.dep"
"modules.dep.bin"
"modules.alias"
"modules.alias.bin"
"modules.symbols"
"modules.symbols.bin"
"modules.softdep"
# Core module dirs we may need.
"kernel/drivers/pwm"
"kernel/drivers/hwmon"
"kernel/drivers/thermal"
# Optional
# "kernel/drivers/i2c"
# "kernel/drivers/gpio"
# "kernel/drivers/base"
# "kernel/drivers/power"
# "kernel/drivers/platform"
)
copy_one() {
local rel="$1"
local src="$SRC_MODDIR/$rel"
local dst="$DEST_MODDIR/$rel"
if [[ -d "$src" ]]; then
echo "[DIR ] $rel"
mkdir -p "$(dirname "$dst")"
cp -a "$src" "$dst"
elif [[ -f "$src" ]]; then
echo "[FILE] $rel"
mkdir -p "$(dirname "$dst")"
cp -a "$src" "$dst"
else
echo "[MISS] $rel"
fi
}
for rel in "${PATHS[@]}"; do
copy_one "$rel"
done
echo
echo "==> Done staging selected modules."
# Optional: show what got copied
echo
echo "==> Staged files summary:"
find "$DEST_MODDIR" -type f | sed "s#^$DEST_ROOT/##" | sort
# Optional: if depmod exists INSIDE the build environment and you want to
# regenerate metadata for the destination tree, uncomment this block.
#
# if command -v depmod >/dev/null 2>&1; then
# echo
# echo "==> Running depmod for destination tree..."
# depmod -b "$DEST_ROOT" "$KVER"
# fi