From f2e7864a00d814ddc9f69df09b67033b189a1067 Mon Sep 17 00:00:00 2001 From: markmental Date: Thu, 10 Sep 2026 21:51:07 -0400 Subject: [PATCH] Add build tagging and rtl8139 network card kernel drivers --- .config | 9 ++++++--- board/mentalnet/INSTALL-GUIDE.md | 19 ++++++++++++++++-- board/mentalnet/linux-slim.config | 3 +++ board/mentalnet/post-build.sh | 32 +++++++++++++++++++++++++++++++ board/mentalnet/post-image.sh | 28 +++++++++++++++++++++++++++ 5 files changed, 86 insertions(+), 5 deletions(-) create mode 100755 board/mentalnet/post-build.sh create mode 100755 board/mentalnet/post-image.sh diff --git a/.config b/.config index 23b3116..4292289 100644 --- a/.config +++ b/.config @@ -1,6 +1,6 @@ # # Automatically generated file; DO NOT EDIT. -# Buildroot -g0d30096-dirty Configuration +# Buildroot -g1d86d4f-dirty Configuration # BR2_HAVE_DOT_CONFIG=y BR2_HOST_GCC_AT_LEAST_4_9=y @@ -474,9 +474,12 @@ BR2_GENERATE_LOCALE="" BR2_ROOTFS_USERS_TABLES="" BR2_ROOTFS_OVERLAY="board/mentalnet/overlay" BR2_ROOTFS_PRE_BUILD_SCRIPT="" -BR2_ROOTFS_POST_BUILD_SCRIPT="" +BR2_ROOTFS_POST_BUILD_SCRIPT="board/mentalnet/post-build.sh" BR2_ROOTFS_POST_FAKEROOT_SCRIPT="" -BR2_ROOTFS_POST_IMAGE_SCRIPT="" +BR2_ROOTFS_POST_IMAGE_SCRIPT="board/mentalnet/post-image.sh" +BR2_ROOTFS_POST_SCRIPT_ARGS="" +BR2_ROOTFS_POST_BUILD_SCRIPT_ARGS="" +BR2_ROOTFS_POST_IMAGE_SCRIPT_ARGS="" # # Kernel diff --git a/board/mentalnet/INSTALL-GUIDE.md b/board/mentalnet/INSTALL-GUIDE.md index b254557..97771c6 100644 --- a/board/mentalnet/INSTALL-GUIDE.md +++ b/board/mentalnet/INSTALL-GUIDE.md @@ -24,7 +24,7 @@ same CD carries a built-in hard disk installer (`mentalnet-install`). | Display | VGA text console, PS/2 keyboard/mouse | | USB | USB keyboards, mice and mass storage (UHCI/OHCI/EHCI) | | Serial | 8250 UART (kernel log is mirrored to COM1) | -| NICs (opt.) | NE2000-PCI clones (RTL8029 etc.), Intel e100/e1000/e1000e, Realtek 8139, 3Com 3c59x | +| NICs (opt.) | NE2000-PCI clones (RTL8029 etc.), Intel e100/e1000/e1000e, Realtek 8139 / 8139C+ (rtl8139, incl. QEMU/Proxmox emulation), 3Com 3c59x, virtio-net (virtualized environments) | ### Installing to a hard disk @@ -83,6 +83,17 @@ A full build takes a while; rebuilds after config changes are much faster. After editing kernel fragments or the overlay, plain `make` picks the changes up. +Every build also publishes the ISO under a unique name and prints its +SHA256 at the end of the build log: + +``` +Published: .../output/images/mentalnet-gnulinux-intel32-20260910-212811.iso +0dcfbcb0...c308c69 output/images/mentalnet-gnulinux-intel32-20260910-212811.iso +``` + +Upload **that** file to hypervisors — see the Proxmox pitfall in the +troubleshooting section before attaching it to an existing VM. + --- ## 4. Testing in QEMU @@ -238,13 +249,15 @@ The installed GRUB menu has a 5s timeout and boots automatically. | Symptom | Likely cause / fix | |---------|--------------------| +| **How to tell which build a VM is actually running** | At the login prompt the build stamp is printed (`Mentalnet GNU/Linux build YYYYMMDD-HHMMSS`); inside the guest check `cat /etc/os-release` (`BUILD_ID=`) or `cat /proc/version`. Useful kernel build markers: `#3 ... 18:45:02` predates the rtl8139 fix, `#4 ... 20:24:17` is the first build with 8139cp. | +| **Proxmox: VM boots an older build despite uploading a new ISO** | Proxmox keeps every upload as a separate storage volume, and a VM's CD/DVD drive points at a specific **volume** — renaming or re-uploading a file never updates an existing drive (checksums of the new file do not help either). Delete the stale volume, upload the unique-named ISO from the build log, attach it in Hardware, and check Boot Order (an installed disk can also shadow the CD). | | GRUB menu does not appear, or the machine reboots before booting, in QEMU | Try more RAM (`-m 256`). Memory pressure during development was the culprit more than once. | | Kernel panic: `Unable to mount root fs` | The CD drive is on an unsupported controller. The kernel targets PIIX-era IDE/ATA; modern SATA-only setups are out of scope. | | `Remounting root filesystem read-write ... failed` on live boot | Cosmetic. The CD root is read-only by design; all writes go to tmpfs. | | Installer: `/dev/sdX1 did not appear after partitioning` | The kernel was still re-reading the partition table. Simply run the installer again. | | Installer: `disk is too small` | At least 400 MB is needed. | | Forgot the password | It is `mnlinux` (set at build time in the Buildroot config). | -| No network | Check the NIC against the supported list in section 1. QEMU: use `-nic model=ne2k_pci` or the default e1000. | +| No network | Check the NIC against the supported list in section 1. QEMU/Proxmox: `rtl8139`, `virtio-net-pci`, `ne2k_pci` or the default e1000 all work. | --- @@ -261,5 +274,7 @@ Everything Mentalnet-specific lives here: | `board/mentalnet/overlay/etc/resolv.conf` | symlink so DHCP DNS works on the read-only CD | | `board/mentalnet/overlay/etc/lighttpd/` | web server configuration | | `fs/iso9660/grub.cfg` | live CD boot menu (`root=/dev/sr0 ro`) | +| `board/mentalnet/post-build.sh` | stamps `BUILD_ID` into os-release and the login banner (wired via `BR2_ROOTFS_POST_BUILD_SCRIPT`) | +| `board/mentalnet/post-image.sh` | publishes the ISO under a unique dated name + SHA256 (wired via `BR2_ROOTFS_POST_IMAGE_SCRIPT`) | | `localversion.config` | kernel version suffix (`-mentalnet-intel32`) | | `.config` | Buildroot configuration: GRUB2 embedded config path and module list, kernel fragment list, e2fsprogs/grub install tools | diff --git a/board/mentalnet/linux-slim.config b/board/mentalnet/linux-slim.config index 04bd9be..fe5799e 100644 --- a/board/mentalnet/linux-slim.config +++ b/board/mentalnet/linux-slim.config @@ -13,6 +13,9 @@ CONFIG_E1000=y CONFIG_E1000E=y CONFIG_NET_VENDOR_REALTEK=y CONFIG_8139TOO=y +# QEMU/Proxmox present their rtl8139 emulation as an enhanced 8139C+ +# chip (rev 0x20); 8139too defers those to the 8139cp driver. +CONFIG_8139CP=y CONFIG_NET_VENDOR_3COM=y CONFIG_NET_VENDOR_DEC=y # NB: in kernels >= 6.x the whole 8390/NE2000 family (incl. NE2K_PCI) diff --git a/board/mentalnet/post-build.sh b/board/mentalnet/post-build.sh new file mode 100755 index 0000000..a02fe2a --- /dev/null +++ b/board/mentalnet/post-build.sh @@ -0,0 +1,32 @@ +#!/bin/sh +# +# post-build.sh - stamp the Mentalnet root filesystem with a build id +# +# Invoked by Buildroot (BR2_ROOTFS_POST_BUILD_SCRIPT) with the target +# directory as first argument. The same stamp is recorded in +# output/images/.mn-build-stamp so post-image.sh can name the ISO +# after the exact build that is inside it. +# +# The stamp is visible inside the guest: +# - /etc/os-release -> BUILD_ID="YYYYMMDD-HHMMSS" +# - /etc/issue -> shown above the login prompt + +set -e + +TARGET_DIR="${1}" +STAMP="$(date +%Y%m%d-%H%M%S)" +IMAGES_DIR="$(dirname "${TARGET_DIR}")/images" + +# record the stamp for post-image.sh +mkdir -p "${IMAGES_DIR}" +echo "${STAMP}" > "${IMAGES_DIR}/.mn-build-stamp" + +# /etc/os-release (regular file lives at /usr/lib/os-release) +OS_RELEASE="${TARGET_DIR}/usr/lib/os-release" +sed -i '/^BUILD_ID=/d' "${OS_RELEASE}" +echo "BUILD_ID=\"${STAMP}\"" >> "${OS_RELEASE}" + +# login banner +ISSUE="${TARGET_DIR}/etc/issue" +sed -i '/^Mentalnet GNU\/Linux build /d' "${ISSUE}" +printf 'Mentalnet GNU/Linux build %s\n' "${STAMP}" >> "${ISSUE}" diff --git a/board/mentalnet/post-image.sh b/board/mentalnet/post-image.sh new file mode 100755 index 0000000..bafa918 --- /dev/null +++ b/board/mentalnet/post-image.sh @@ -0,0 +1,28 @@ +#!/bin/sh +# +# post-image.sh - publish the Mentalnet ISO under a unique build name +# +# Invoked by Buildroot (BR2_ROOTFS_POST_IMAGE_SCRIPT) with the +# binaries directory as first argument. +# +# The ISO is copied to mentalnet-gnulinux-intel32-.iso so that +# uploads to hypervisors (Proxmox in particular) can never be confused +# with a previous build's storage volume, and its SHA256 is printed +# for the build log. + +set -e + +BINARIES_DIR="${1}" +ISO="${BINARIES_DIR}/rootfs.iso9660" + +[ -f "${ISO}" ] || exit 0 + +# reuse the stamp recorded by post-build.sh so the ISO name matches +# the build id visible inside the guest; fall back to a fresh stamp +STAMP="$(cat "${BINARIES_DIR}/.mn-build-stamp" 2>/dev/null || date +%Y%m%d-%H%M%S)" + +OUT="${BINARIES_DIR}/mentalnet-gnulinux-intel32-${STAMP}.iso" +cp "${ISO}" "${OUT}" + +echo "Published: ${OUT}" +sha256sum "${OUT}"