Complete from-scratch Linux distribution targeting AMD Ryzen 9 9950X3D + NVIDIA RTX 5090 on ASUS ROG CROSSHAIR X870E HERO. Deliverables: - dpack: custom package manager in Rust (3,800 lines) - TOML package parser, dependency resolver, build sandbox - CRUX Pkgfile and Gentoo ebuild converters - Shared library conflict detection - 124 package definitions across 4 repos (core/extra/desktop/gaming) - 34 toolchain bootstrap scripts (LFS 13.0 adapted for Zen 5) - Linux 6.19.8 kernel config (hardware-specific, fully commented) - SysVinit init system with rc.d service scripts - Live ISO builder (UEFI-only, squashfs+xorriso) - Interactive installer (GPT partitioning, EFISTUB boot) - Integration test checklist (docs/TESTING.md) No systemd. No bootloader. No display manager. Kernel boots via EFISTUB → auto-login → dwl Wayland compositor. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
105 lines
3.8 KiB
Bash
Executable File
105 lines
3.8 KiB
Bash
Executable File
#!/bin/bash
|
|
# ============================================================================
|
|
# DarkForge Linux — System Initialization
|
|
# ============================================================================
|
|
# /etc/rc.d/rc.sysinit — runs once at boot before daemons start.
|
|
# Sets up: hostname, clock, filesystems, kernel modules, swap, sysctl.
|
|
# ============================================================================
|
|
|
|
. /etc/rc.conf
|
|
|
|
echo "DarkForge Linux — booting..."
|
|
|
|
# --- Mount virtual filesystems (if not already by kernel) -------------------
|
|
mountpoint -q /proc || mount -t proc proc /proc
|
|
mountpoint -q /sys || mount -t sysfs sysfs /sys
|
|
mountpoint -q /run || mount -t tmpfs tmpfs /run
|
|
mountpoint -q /dev || mount -t devtmpfs devtmpfs /dev
|
|
mkdir -p /dev/pts /dev/shm /run/lock
|
|
mountpoint -q /dev/pts || mount -t devpts devpts /dev/pts
|
|
mountpoint -q /dev/shm || mount -t tmpfs tmpfs /dev/shm
|
|
|
|
# --- Set hostname -----------------------------------------------------------
|
|
echo "${HOSTNAME}" > /proc/sys/kernel/hostname
|
|
echo ":: Hostname set to ${HOSTNAME}"
|
|
|
|
# --- Set hardware clock -----------------------------------------------------
|
|
if [ "${HARDWARECLOCK}" = "UTC" ]; then
|
|
hwclock --systohc --utc 2>/dev/null
|
|
else
|
|
hwclock --systohc --localtime 2>/dev/null
|
|
fi
|
|
|
|
# --- Set timezone -----------------------------------------------------------
|
|
if [ -f "/usr/share/zoneinfo/${TIMEZONE}" ]; then
|
|
ln -sf "/usr/share/zoneinfo/${TIMEZONE}" /etc/localtime
|
|
echo ":: Timezone set to ${TIMEZONE}"
|
|
fi
|
|
|
|
# --- Set console keymap -----------------------------------------------------
|
|
if [ -n "${KEYMAP}" ]; then
|
|
loadkeys "${KEYMAP}" 2>/dev/null && echo ":: Keymap set to ${KEYMAP}"
|
|
fi
|
|
|
|
# --- Set console font -------------------------------------------------------
|
|
if [ -n "${FONT}" ]; then
|
|
setfont "${FONT}" 2>/dev/null && echo ":: Console font set to ${FONT}"
|
|
fi
|
|
|
|
# --- Filesystem check -------------------------------------------------------
|
|
echo ":: Checking filesystems..."
|
|
fsck -A -T -C -a
|
|
if [ $? -gt 1 ]; then
|
|
echo "!! Filesystem errors detected. Dropping to emergency shell."
|
|
echo "!! Run 'fsck' manually, then 'exit' to continue boot."
|
|
/bin/bash
|
|
fi
|
|
|
|
# --- Mount all filesystems from fstab ---------------------------------------
|
|
echo ":: Mounting filesystems..."
|
|
mount -a
|
|
mount -o remount,rw /
|
|
|
|
# --- Activate swap ----------------------------------------------------------
|
|
echo ":: Activating swap..."
|
|
swapon -a
|
|
|
|
# --- Load kernel modules from rc.conf --------------------------------------
|
|
echo ":: Loading kernel modules..."
|
|
for mod in "${MODULES[@]}"; do
|
|
modprobe "${mod}" && echo " Loaded: ${mod}"
|
|
done
|
|
|
|
# --- Apply module parameters ------------------------------------------------
|
|
for param in "${MODULE_PARAMS[@]}"; do
|
|
mod=$(echo "${param}" | awk '{print $1}')
|
|
args=$(echo "${param}" | cut -d' ' -f2-)
|
|
# Module params are passed at load time, but if already loaded,
|
|
# try writing to sysfs
|
|
if [ -d "/sys/module/${mod}/parameters" ]; then
|
|
key=$(echo "${args}" | cut -d'=' -f1)
|
|
val=$(echo "${args}" | cut -d'=' -f2)
|
|
echo "${val}" > "/sys/module/${mod}/parameters/${key}" 2>/dev/null
|
|
fi
|
|
done
|
|
|
|
# --- Apply sysctl settings --------------------------------------------------
|
|
if [ -f /etc/sysctl.conf ]; then
|
|
sysctl -p /etc/sysctl.conf >/dev/null 2>&1
|
|
echo ":: Applied sysctl settings"
|
|
fi
|
|
|
|
# --- Set up /tmp ------------------------------------------------------------
|
|
chmod 1777 /tmp
|
|
|
|
# --- Seed random number generator ------------------------------------------
|
|
if [ -f /var/lib/random-seed ]; then
|
|
cat /var/lib/random-seed > /dev/urandom
|
|
fi
|
|
dd if=/dev/urandom of=/var/lib/random-seed count=1 bs=512 2>/dev/null
|
|
|
|
# --- Clear old PID files and locks ------------------------------------------
|
|
rm -f /run/*.pid /var/lock/* 2>/dev/null
|
|
|
|
echo ":: System initialization complete"
|