Files
unkernel/guest/base/rootfs/usr/lib/kw/data-stop
Pooya Parsa 97f8d9e5f1 guest: distroless base initramfs and separate Alpine and Debian erofs images
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.
2026-11-19 14:46:13 +00:00

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