diff --git a/crates/openshell-driver-vm/scripts/openshell-vm-sandbox-init.sh b/crates/openshell-driver-vm/scripts/openshell-vm-sandbox-init.sh index 2166e06177..906d27bb1d 100644 --- a/crates/openshell-driver-vm/scripts/openshell-vm-sandbox-init.sh +++ b/crates/openshell-driver-vm/scripts/openshell-vm-sandbox-init.sh @@ -243,6 +243,12 @@ setup_overlay_root() { if [ "${OPENSHELL_VM_INIT_MODE:-sandbox}" = "image-prep" ]; then prepare_guest_image_rootfs sync + if mount -o remount,ro /overlay 2>/dev/null; then + : + else + umount /overlay + fi + sync ts "image-prep complete" exit 0 fi @@ -252,7 +258,7 @@ setup_overlay_root() { local lower_root="/lower" if [ -b /dev/vdc ]; then - mount -t ext4 -o ro /dev/vdc /image-cache + mount -t ext4 -o ro,noload /dev/vdc /image-cache if [ -d /image-cache/image-rootfs ]; then lower_root="/image-cache/image-rootfs" ts "using prepared image rootfs lowerdir" diff --git a/crates/openshell-driver-vm/src/runtime.rs b/crates/openshell-driver-vm/src/runtime.rs index a6ddfe011d..65b2753ce4 100644 --- a/crates/openshell-driver-vm/src/runtime.rs +++ b/crates/openshell-driver-vm/src/runtime.rs @@ -1057,7 +1057,12 @@ impl VmContext { self.ctx_id, image_block_id_c.as_ptr(), image_disk_c.as_ptr(), - true, + // Attach as writable at the hypervisor level so the + // kernel can replay the ext4 journal if the image-prep + // VM did not unmount cleanly. The guest still mounts + // the filesystem with -o ro, so guest processes cannot + // write to it. See: openshell-vm-sandbox-init.sh + false, ) }, "krun_add_disk",