#!/bin/sh # /init of the live image (rdinit=/init), packed by `container.sh # initramfs` as a second cpio after T's: it belongs to no package. # # The kernel unpacks the initramfs into rootfs, and pivot_root(2) # refuses to move rootfs, so builds (gsandbox) could never enter their # build root. This copies the system into a tmpfs and switch_roots into # it; switch_root empties rootfs, so the copy costs no RAM after boot. PATH=/usr/bin:/bin mkdir -p /.live if ! mount -t tmpfs -o size=90%,mode=755 live /.live; then echo "[x] Cannot mount the live tmpfs; booting from the initramfs." >&2 exec /sbin/init fi for e in /* /.[!.]*; do case "$e" in /.live|/init|'/.[!.]*') ;; *) cp -a "$e" /.live/ || { echo "[x] Cannot copy $e to the live tmpfs; booting from the initramfs." >&2 umount /.live; exec /sbin/init } ;; esac done exec switch_root /.live /sbin/init