forked from tfgrid/zosbuilder
feat: Implement complete Zero OS Alpine Initramfs Builder
- Complete bash framework with strict error handling - Modular library system (docker, alpine, components, initramfs, kernel, testing) - Rust component integration (zinit, rfs, mycelium) with musl targeting - Rootless Docker/Podman support for GitHub Actions - Centralized configuration in config/build.conf - 2-stage module loading system - Strip + UPX optimization for minimal size - Complete zinit integration replacing OpenRC - GitHub Actions CI/CD pipeline - Comprehensive documentation and usage guides Components: - Latest stable kernel 6.12.44 - Alpine Linux 3.22 base - ThreeFold components: zinit, mycelium, rfs, corex - Target: ~8-12MB final initramfs.cpio.xz
This commit is contained in:
103
configs/init
Executable file
103
configs/init
Executable file
@@ -0,0 +1,103 @@
|
||||
#!/bin/sh
|
||||
# Alpine-based Zero-OS Init Script
|
||||
# Maintains identical flow to original busybox version
|
||||
|
||||
echo ""
|
||||
echo "============================================"
|
||||
echo "== ZERO-OS ALPINE INITRAMFS =="
|
||||
echo "============================================"
|
||||
|
||||
echo "[+] creating ram filesystem"
|
||||
mount -t proc proc /proc
|
||||
mount -t sysfs sysfs /sys
|
||||
mount -t tmpfs tmpfs /mnt/root -o size=1536M
|
||||
mount -t devtmpfs devtmpfs /dev
|
||||
|
||||
echo "[+] building ram filesystem"
|
||||
target="/mnt/root"
|
||||
|
||||
# Copy Alpine filesystem to tmpfs (same as original)
|
||||
echo " copying /bin..."
|
||||
cp -ar /bin $target
|
||||
echo " copying /etc..."
|
||||
cp -ar /etc $target
|
||||
echo " copying /lib..."
|
||||
cp -ar /lib* $target
|
||||
echo " copying /usr..."
|
||||
cp -ar /usr $target
|
||||
echo " copying /root..."
|
||||
cp -ar /root $target
|
||||
echo " copying /sbin..."
|
||||
cp -ar /sbin $target
|
||||
echo " copying /tmp..."
|
||||
cp -ar /tmp $target
|
||||
echo " copying /var..."
|
||||
cp -ar /var $target
|
||||
echo " copying /run..."
|
||||
cp -ar /run $target
|
||||
|
||||
# Create essential directories
|
||||
mkdir -p $target/dev
|
||||
mkdir -p $target/sys
|
||||
mkdir -p $target/proc
|
||||
mkdir -p $target/mnt
|
||||
|
||||
# Mount filesystems in tmpfs
|
||||
mount -t proc proc $target/proc
|
||||
mount -t sysfs sysfs $target/sys
|
||||
mount -t devtmpfs devtmpfs $target/dev
|
||||
|
||||
# Mount devpts for terminals
|
||||
mkdir -p $target/dev/pts
|
||||
mount -t devpts devpts $target/dev/pts
|
||||
|
||||
echo "[+] setting environment"
|
||||
export PATH
|
||||
|
||||
echo "[+] probing drivers"
|
||||
# Use Alpine's udev instead of busybox udevadm
|
||||
if [ -x /sbin/udevd ]; then
|
||||
echo " starting udevd..."
|
||||
udevd --daemon
|
||||
|
||||
echo " triggering device discovery..."
|
||||
udevadm trigger --action=add --type=subsystems
|
||||
udevadm trigger --action=add --type=devices
|
||||
udevadm settle
|
||||
|
||||
echo " stopping udevd..."
|
||||
kill $(pidof udevd) || true
|
||||
else
|
||||
echo " warning: udevd not found, skipping hardware detection"
|
||||
fi
|
||||
|
||||
echo "[+] loading essential drivers"
|
||||
# Load core drivers for storage and network
|
||||
modprobe btrfs 2>/dev/null || true
|
||||
modprobe fuse 2>/dev/null || true
|
||||
modprobe overlay 2>/dev/null || true
|
||||
|
||||
# Load storage drivers
|
||||
modprobe ahci 2>/dev/null || true
|
||||
modprobe nvme 2>/dev/null || true
|
||||
modprobe virtio_blk 2>/dev/null || true
|
||||
modprobe virtio_scsi 2>/dev/null || true
|
||||
|
||||
# Load network drivers
|
||||
modprobe virtio_net 2>/dev/null || true
|
||||
modprobe e1000 2>/dev/null || true
|
||||
modprobe e1000e 2>/dev/null || true
|
||||
|
||||
# Unmount init filesystems
|
||||
umount /proc 2>/dev/null || true
|
||||
umount /sys 2>/dev/null || true
|
||||
|
||||
echo "[+] checking for debug files"
|
||||
if [ -e /init-debug ]; then
|
||||
echo " executing debug script..."
|
||||
sh /init-debug
|
||||
fi
|
||||
|
||||
echo "[+] switching root"
|
||||
echo " exec switch_root /mnt/root /sbin/zinit init"
|
||||
exec switch_root /mnt/root /sbin/zinit init
|
||||
Reference in New Issue
Block a user