diff --git a/libs/qemu-docker/linux/src/entry.sh b/libs/qemu-docker/linux/src/entry.sh index 938a831bc..734aa6f90 100644 --- a/libs/qemu-docker/linux/src/entry.sh +++ b/libs/qemu-docker/linux/src/entry.sh @@ -12,6 +12,21 @@ cleanup() { # Install trap for signals trap cleanup SIGTERM SIGINT SIGHUP SIGQUIT +# Overlay mode: /golden mounted read-only, /storage starts empty +if [ -d "/golden" ] && [ -z "$(ls -A /storage 2>/dev/null)" ]; then + echo "Overlay mode detected, setting up copy-on-write..." + if cp -al /golden/. /storage/ 2>/dev/null; then + echo "Overlay setup complete (hard links)." + else + echo "Hard links not supported, falling back to full copy..." + if ! cp -a /golden/. /storage/; then + echo "ERROR: overlay copy failed, cannot proceed." + exit 1 + fi + echo "Overlay setup complete (full copy)." + fi +fi + # Start the VM in the background echo "Starting Ubuntu VM..." /usr/bin/tini -s /run/entry.sh & diff --git a/libs/qemu-docker/windows/src/entry.sh b/libs/qemu-docker/windows/src/entry.sh index 81130b245..8ea7cb445 100644 --- a/libs/qemu-docker/windows/src/entry.sh +++ b/libs/qemu-docker/windows/src/entry.sh @@ -12,6 +12,21 @@ cleanup() { # Install trap for signals trap cleanup SIGTERM SIGINT SIGHUP SIGQUIT +# Overlay mode: /golden mounted read-only, /storage starts empty +if [ -d "/golden" ] && [ -z "$(ls -A /storage 2>/dev/null)" ]; then + echo "Overlay mode detected, setting up copy-on-write..." + if cp -al /golden/. /storage/ 2>/dev/null; then + echo "Overlay setup complete (hard links)." + else + echo "Hard links not supported, falling back to full copy..." + if ! cp -a /golden/. /storage/; then + echo "ERROR: overlay copy failed, cannot proceed." + exit 1 + fi + echo "Overlay setup complete (full copy)." + fi +fi + # Create windows.boot file if it doesn't exist (required for proper boot) if [ -d "/storage" -a ! -f "/storage/windows.boot" ]; then echo "Creating windows.boot file in /storage..."