commit ac05d3e5dc0c50d172272058d4c8c158cadac94f42642d068cb1a90f90f2ab02
| author | 斟酌 鵬兄 <tgckpg@gmail.com> |
| date | 2026-03-23T12:18:10Z |
| subject | CRI-O runs but not tested yet |
commit ac05d3e5dc0c50d172272058d4c8c158cadac94f42642d068cb1a90f90f2ab02
Author: 斟酌 鵬兄 <tgckpg@gmail.com>
Date: 2026-03-23T12:18:10Z
CRI-O runs but not tested yet
---
alpine/build-rootfs.sh | 26 ++++++++++++++++----------
alpine/etc/fancontrol | 9 +++++++++
alpine/install-packages.sh | 16 +++++++++++++++-
docker/alpine.Dockerfile | 5 +++++
docker/initramfs.Dockerfile | 2 +-
docker/kernel-build.Dockerfile | 1 +
initramfs/init | 3 +++
kernel-extra.config | 24 ++++++++++++------------
makefile | 7 ++++---
9 files changed, 66 insertions(+), 27 deletions(-)
diff --git a/alpine/build-rootfs.sh b/alpine/build-rootfs.sh
index c4ed860..be3074f 100755
--- a/alpine/build-rootfs.sh
+++ b/alpine/build-rootfs.sh
@@ -11,12 +11,14 @@ mount --bind /run "$ROOTFS/run"
cp /usr/bin/qemu-aarch64-static "$ROOTFS/usr/bin/"
cp /etc/resolv.conf "$ROOTFS/etc/resolv.conf"
cp /build/crio.tar.gz "$ROOTFS/build/"
+cp -r /build/rootfs/* "$ROOTFS/"
chroot "$ROOTFS" /bin/sh -c "ln -s /var/cache/apk /etc/apk/cache"
# chroot "$ROOTFS" /bin/sh -c "apk update"
chroot "$ROOTFS" /bin/sh -c "apk add bash curl"
cp "/install-packages.sh" "$ROOTFS/install-packages.sh"
chroot "$ROOTFS" /bin/bash /install-packages.sh || exit 1
+rm "$ROOTFS/install-packages.sh"
umount "$ROOTFS/var/cache/apk"
umount "$ROOTFS/dev"
@@ -30,13 +32,12 @@ rm -r "$ROOTFS/build"
echo "=========================== RootFS "$( du -sh "$ROOTFS/" )
IMG=output.img
-SIZE=512MB
+SIZE=1024MB
dd if=/dev/zero of="$IMG" bs=1 count=0 seek=$SIZE
sgdisk -o "$IMG" \
- -n 1:2048:+64M -t 1:0700 \
- -n 2:0:-1M -t 2:8300
+ -n 1:65536:-1M -t 1:8300
losetup -D
LOOP=$(losetup --find --show -P "$IMG")
@@ -44,18 +45,23 @@ LOOP=$(losetup --find --show -P "$IMG")
/sync-loop.sh "$LOOP"
TMP_LOOP="/tmp$LOOP"
-mkfs.vfat "${TMP_LOOP}p1"
-mkfs.ext4 "${TMP_LOOP}p2"
+mkfs.ext4 -F "${TMP_LOOP}p1"
-mkdir -p /mnt/img-root /mnt/img-boot
+mkdir -p /mnt/img-root
-mount ${TMP_LOOP}p1 /mnt/img-boot
-mount ${TMP_LOOP}p2 /mnt/img-root
+mount "${TMP_LOOP}p1" /mnt/img-root
cp -a "$ROOTFS"/. /mnt/img-root/
-cp /build/board.itb /mnt/img-boot
+mkdir -p /mnt/img-root/boot
+cp /build/Image.gz /mnt/img-root/boot/Image.gz
+cp /build/board.itb /mnt/img-root/boot/kernel.itb
+cp /build/${DEVICE_TREE_TARGET}.dtb /mnt/img-root/boot/${DEVICE_TREE_TARGET}.dtb
+
+sync
umount /mnt/img-root
-umount /mnt/img-boot
losetup -d "$LOOP"
+
+echo "GZipping the image"
+gzip "/build/$IMG"
diff --git a/alpine/etc/fancontrol b/alpine/etc/fancontrol
new file mode 100644
index 0000000..b378156
--- /dev/null
+++ b/alpine/etc/fancontrol
@@ -0,0 +1,9 @@
+INTERVAL=10
+DEVPATH=hwmon0=devices/platform/soc/2180000.i2c/i2c-0/i2c-7/7-002e hwmon1=devices/virtual/thermal/thermal_zone0
+DEVNAME=hwmon0=emc2305 hwmon1=ddr_thermal
+FCTEMPS=hwmon0/pwm2=hwmon1/temp1_input
+FCFANS= hwmon0/pwm2=hwmon0/fan1_input
+MINTEMP=hwmon0/pwm2=40
+MAXTEMP=hwmon0/pwm2=60
+MINSTART=hwmon0/pwm2=60
+MINSTOP=hwmon0/pwm2=45
diff --git a/alpine/install-packages.sh b/alpine/install-packages.sh
index 30f4c55..9d6f248 100755
--- a/alpine/install-packages.sh
+++ b/alpine/install-packages.sh
@@ -2,7 +2,21 @@
cd /build
-### CRI-O
+echo "##################################################### Installing basic packages"
+apk add alpine-base \
+ openrc busybox-openrc bash nftables \
+ lm-sensors lm-sensors-fancontrol lm-sensors-fancontrol-openrc
+rc-update add devfs sysinit
+rc-update add procfs sysinit
+rc-update add sysfs sysinit
+rc-update add loopback boot
+rc-update add fancontrol default
+echo "ttyS0::respawn:/sbin/getty -L ttyS0 115200 vt100 -n -l /bin/sh" >> "/etc/inittab"
+echo '[ -x /bin/bash ] && exec /bin/bash -l' >> "/root/.profile"
+echo "export PATH=\"/usr/local/bin:$PATH\"" >> "/etc/profile.d/settings.sh"
+
+
+echo "##################################################### Installing CRI-O"
tar zxf crio.tar.gz
cd cri-o
diff --git a/docker/alpine.Dockerfile b/docker/alpine.Dockerfile
index 42c326a..0d86c9f 100644
--- a/docker/alpine.Dockerfile
+++ b/docker/alpine.Dockerfile
@@ -6,13 +6,18 @@ FROM --platform=$BUILDPLATFORM ${DOCKER_IMAGE_ROOT}/build-base:${TAG} AS build-b
ARG ALPINE_ARCH
ARG ALPINE_VER
ARG CRIO_VERSION
+ARG DEVICE_TREE_TARGET
RUN mkdir -p "/out/rootfs"
COPY packages/alpine-minirootfs-${ALPINE_VER}-${ALPINE_ARCH}.tar.gz ./alpine.tar.gz
COPY packages/${CRIO_VERSION}.tar.gz ./crio.tar.gz
COPY out/board.itb ./
+COPY out/rootfs ./rootfs
+COPY out/${DEVICE_TREE_TARGET}.dtb ./
+COPY out/Image.gz ./
RUN tar -xf alpine.tar.gz -C "/out/rootfs"
+COPY alpine/etc ./rootfs/etc
COPY alpine/*.sh /
diff --git a/docker/initramfs.Dockerfile b/docker/initramfs.Dockerfile
index 81bcbcf..c23a89e 100644
--- a/docker/initramfs.Dockerfile
+++ b/docker/initramfs.Dockerfile
@@ -27,7 +27,7 @@ WORKDIR /out/initramfs
COPY initramfs/init init
RUN chmod +x init
-RUN mkdir -p bin sbin etc proc sys dev lib usr/bin usr/sbin
+RUN mkdir -p bin sbin etc proc sys dev lib mnt usr/bin usr/sbin
# Selective mods
RUN mkdir -p /out/selected-mods /out/kernel
diff --git a/docker/kernel-build.Dockerfile b/docker/kernel-build.Dockerfile
index b3e0a39..39d4d86 100644
--- a/docker/kernel-build.Dockerfile
+++ b/docker/kernel-build.Dockerfile
@@ -33,6 +33,7 @@ RUN grep -q "^dtb-\\\$(CONFIG_ARCH_LAYERSCAPE) += ${DEVICE_TREE_TARGET}.dtb$" \
RUN make ARCH="${ARCH}" CROSS_COMPILE="${CROSS_COMPILE}" defconfig lsdk.config \
&& ./scripts/kconfig/merge_config.sh -m .config /tmp/kernel-extra.config \
&& make ARCH="${ARCH}" CROSS_COMPILE="${CROSS_COMPILE}" olddefconfig \
+ && grep '^CONFIG_NF_TABLES=' .config \
&& make ARCH="${ARCH}" CROSS_COMPILE="${CROSS_COMPILE}" -j"$(nproc)"
# artifact collection
diff --git a/initramfs/init b/initramfs/init
index 0a2924d..1b674e3 100755
--- a/initramfs/init
+++ b/initramfs/init
@@ -4,6 +4,9 @@ mount -t devtmpfs devtmpfs /dev
mount -t proc proc /proc
mount -t sysfs sysfs /sys
+# Spin the fan
+echo 100 > /sys/class/hwmon/hwmon0/pwm1
+
# Optional but nice
mkdir -p /dev/pts
mount -t devpts devpts /dev/pts
diff --git a/kernel-extra.config b/kernel-extra.config
index 1c12671..989bc0c 100644
--- a/kernel-extra.config
+++ b/kernel-extra.config
@@ -96,7 +96,7 @@ CONFIG_TMPFS_XATTR=y
CONFIG_TMPFS_POSIX_ACL=y
# POSIX ACLs on tmpfs. Good compatibility feature for userland.
-CONFIG_OVERLAY_FS=m
+CONFIG_OVERLAY_FS=y
# Overlay filesystem. This is the big one for container image/layer storage.
# Module is fine; CRI-O can load/use it after boot. No need to bloat FIT image.
@@ -131,34 +131,34 @@ CONFIG_DUMMY=m
# This is where container networking gets messy. Better to enable a sane baseline.
###############################################################################
-CONFIG_NETFILTER=m
+CONFIG_NETFILTER=y
# Netfilter core framework. Module is okay if your setup loads it before use.
CONFIG_NETFILTER_ADVANCED=y
# Exposes more advanced netfilter options and modules.
-CONFIG_NF_CONNTRACK=m
+CONFIG_NF_CONNTRACK=y
# Connection tracking. Critical for NAT, Kubernetes service traffic, and many CNIs.
-CONFIG_NF_NAT=m
+CONFIG_NF_NAT=y
# NAT framework. Required for masquerading and pod egress in many setups.
-CONFIG_NF_TABLES=m
+CONFIG_NF_TABLES=y
# nftables framework. Modern Linux packet filtering backend.
CONFIG_NFT_CT=m
# nftables conntrack expressions.
-CONFIG_NFT_CHAIN_NAT=m
+CONFIG_NFT_CHAIN_NAT=y
# nftables NAT chain support.
-CONFIG_NFT_MASQ=m
+CONFIG_NFT_MASQ=y
# nftables masquerade support. Often needed for pod egress NAT.
-CONFIG_NFT_REDIR=m
+CONFIG_NFT_REDIR=y
# nftables redirect target.
-CONFIG_NFT_NAT=m
+CONFIG_NFT_NAT=y
# nftables NAT support.
CONFIG_NF_NAT_IPV4=m
@@ -216,14 +216,14 @@ CONFIG_NETFILTER_XT_TARGET_CT=m
# Bridge / container interface plumbing
###############################################################################
-CONFIG_VETH=m
+CONFIG_VETH=y
# Virtual Ethernet pairs. This is how container interfaces are commonly connected
# to the host/network namespace.
-CONFIG_BRIDGE=m
+CONFIG_BRIDGE=y
# Ethernet bridge support. Needed by bridge-based CNIs.
-CONFIG_BRIDGE_NETFILTER=m
+CONFIG_BRIDGE_NETFILTER=y
# Allows bridged traffic to pass through netfilter/iptables/nftables hooks.
# Important for Kubernetes networking behavior.
diff --git a/makefile b/makefile
index 22002ed..7c08b8a 100644
--- a/makefile
+++ b/makefile
@@ -13,7 +13,7 @@ CRIO_TAR := $(PACKAGES_DIR)/$(CRIO_VERSION).tar.gz
BOARD_ITB := $(OUT_DIR)/board.itb
INITRAMFS := $(OUT_DIR)/initramfs.cpio.gz
-RELEASE_IMAGE := $(OUT_DIR)/monok8s-$(TAG).img
+RELEASE_IMAGE := $(OUT_DIR)/monok8s-$(TAG).img.gz
KERNEL_IMAGE := $(OUT_DIR)/Image.gz
@@ -139,6 +139,7 @@ $(RELEASE_IMAGE): $(RELEASE_DEPS) | $(OUT_DIR)
--build-arg ALPINE_ARCH=$(ALPINE_ARCH) \
--build-arg ALPINE_VER=$(ALPINE_VER) \
--build-arg CRIO_VERSION=$(CRIO_VERSION) \
+ --build-arg DEVICE_TREE_TARGET=$(DEVICE_TREE_TARGET) \
-t $(DOCKER_IMAGE_ROOT)/buildenv-alpine:$(TAG) .
@cid=$$(docker create \
@@ -146,12 +147,12 @@ $(RELEASE_IMAGE): $(RELEASE_DEPS) | $(OUT_DIR)
-v /cache/apk:/var/cache/apk \
--device=/dev/loop0:/dev/loop0 \
-e ROOTFS=/out/rootfs \
- -e ARTIFACT_DIR=/artifacts \
-e RELEASE_IMAGE=$(RELEASE_IMAGE) \
+ -e DEVICE_TREE_TARGET=$(DEVICE_TREE_TARGET) \
$(DOCKER_IMAGE_ROOT)/buildenv-alpine:$(TAG) \
bash -lc '/build-rootfs.sh'); \
docker start -a $$cid; \
- docker cp $$cid:/build/output.img $@; \
+ docker cp $$cid:/build/output.img.gz $@; \
docker rm $$cid
test -f $@