mirror of
https://github.com/pithings/unkernel.git
synced 2026-12-05 22:39:34 +08:00
The bundle (unkernel.wasm) carries a small busybox initramfs that mounts a distro image labelled kwroot under an overlay root, or starts the base shell without one. guest/ replaces kernel/guest/: base/, distro/NAME/, shared lib/ and tools/. Images are laid out for their boot by a patched mkfs.erofs and a recorded boot file list, with a prefetch hint in the image header. Debian bakes its apt lists and cache, a set of everyday packages and a command-not-found installer.
29 lines
1.0 KiB
Plaintext
Executable File
29 lines
1.0 KiB
Plaintext
Executable File
#!/run/kw-lower/bin/busybox sh
|
|
# SPDX-License-Identifier: GPL-2.0-or-later
|
|
# Copyright (C) 2026 Pooya Parsa <pooya@pi0.io>
|
|
# /usr/lib/kw/data-stop (the kw layer): leave /data clean at shutdown.
|
|
# /usr/lib/kw/shutdown calls it after it has stopped every process and
|
|
# before reboot(2). On a data upper (/run/kw-base: upper=data) /data is busy
|
|
# under the root overlay, so / and /data are remounted read-only, which
|
|
# commits the journal and marks the file system clean. Otherwise /data is
|
|
# unmounted.
|
|
|
|
PATH=/run/kw-lower/bin
|
|
mountpoint -q /data || exit 0
|
|
sync
|
|
if [ "$(sed -n 's/^upper=//p' /run/kw-base 2>/dev/null)" = data ]; then
|
|
mount -o remount,ro / 2>/dev/null
|
|
if mount -o remount,ro /data; then
|
|
echo "kw-shutdown: /data is clean (read-only under the overlay root)"
|
|
else
|
|
echo "kw-shutdown: /data is busy"
|
|
fi
|
|
elif umount /data; then
|
|
echo "kw-shutdown: /data is clean"
|
|
elif mount -o remount,ro /data; then
|
|
echo "kw-shutdown: /data is busy, remounted read-only"
|
|
else
|
|
echo "kw-shutdown: /data is busy"
|
|
fi
|
|
exit 0
|