#!/bin/sh # /init — PID 1 entry point for the everything-in-initramfs live image. # # The kernel unpacks our cpio.zst into a ramfs, sees no root= parameter, # and execs /init. Classic initramfs-tools has an elaborate /init that # mounts a real rootfs and pivot_roots into it; we don't do that — # there IS no other rootfs, the initramfs IS the rootfs. All we need # to do is set up the api-vfs mounts systemd expects before PID 1 and # hand off. # # Running systemd directly as PID 1 from kernel /init works (systemd # detects it's PID 1 and boots normally), but only if /proc, /sys, /dev # are pre-mounted. Systemd has fallback mount code for these, but it's # fragile in the ramfs-rootfs case — doing it here explicitly makes # first-boot failures easier to see and harder to hit. set -e echo "vetting-init: bootstrapping api-vfs" mount -t proc -o nosuid,noexec,nodev proc /proc mount -t sysfs -o nosuid,noexec,nodev sysfs /sys mount -t devtmpfs -o mode=0755,nosuid devtmpfs /dev mkdir -p /dev/pts /dev/shm /run mount -t devpts -o gid=5,mode=620,nosuid,noexec devpts /dev/pts mount -t tmpfs -o mode=1777,nosuid,nodev tmpfs /dev/shm mount -t tmpfs -o mode=0755,nosuid,nodev tmpfs /run echo "vetting-init: handing off to systemd" exec /lib/systemd/systemd