From 7e3e24780d0237982af1cf0539ae8491892723ca Mon Sep 17 00:00:00 2001 From: Kroese Date: Sun, 9 Aug 2026 22:16:20 +0200 Subject: [PATCH] feat: Enforce a minimal disk size per Windows version (#2122) --- src/define.sh | 66 +++++++++++++++++++++++++++++++++++++++++--------- src/install.sh | 14 +++++++++++ 2 files changed, 69 insertions(+), 11 deletions(-) diff --git a/src/define.sh b/src/define.sh index be4d97a9..5e439391 100644 --- a/src/define.sh +++ b/src/define.sh @@ -963,27 +963,71 @@ getRequiredMemory() { case "$id" in "win11"* ) - echo 2147483648 ;; + echo "2G" ;; "tiny11"* | "core11"* ) - echo 2147483648 ;; + echo "2G" ;; "win10"* | "tiny10"* ) - echo 2147483648 ;; + echo "2G" ;; "win2025"* | "win2022"* | "win2019"* | "win2016"* ) - echo 2147483648 ;; + echo "2G" ;; "win81"* | "win7x64"* ) - echo 2147483648 ;; + echo "2G" ;; "win7x86"* | "winvista"* | "win2012"* ) - echo 1073741824 ;; + echo "1G" ;; "win2008"* | "win2003"* ) - echo 536870912 ;; + echo "512M" ;; "winxpx64"* ) - echo 268435456 ;; + echo "256M" ;; "win9"* | "winnt4"* | "winxpx86"* | "win2k"* ) - echo 136314880 ;; + echo "130M" ;; "reactos"* ) - echo 136314880 ;; + echo "130M" ;; * ) - echo 136314880 ;; + echo "130M" ;; + esac + + return 0 +} + +getRequiredDisk() { + + local id="${1,,}" + + case "$id" in + "win11"* ) + echo "32G" ;; + "tiny11"* ) + echo "8G" ;; + "core11"* ) + echo "4G" ;; + "win10"* ) + echo "16G" ;; + "tiny10"* ) + echo "10G" ;; + "win2025"* | "win2022"* | "win2019"* | "win2016"* | "win2012"* ) + echo "32G" ;; + "win81"* | "win7"* | "winvista"* ) + echo "16G" ;; + "win2008"* ) + echo "10G" ;; + "win2003"* ) + echo "4G" ;; + "winxp"* ) + echo "2G" ;; + "win2k"* ) + echo "1G" ;; + "win9x"* ) + echo "512M" ;; + "win98"* ) + echo "256M" ;; + "win95"* ) + echo "100M" ;; + "winnt4"* ) + echo "128M" ;; + "reactos"* ) + echo "512M" ;; + * ) + echo "100M" ;; esac return 0 diff --git a/src/install.sh b/src/install.sh index 51db6f4b..f0d1761e 100644 --- a/src/install.sh +++ b/src/install.sh @@ -160,6 +160,8 @@ configureMachine() { return 79 fi + setDiskMinimum "$DETECTED" || return 79 + if ! setMachine "$DETECTED" "$iso" "$dir" "$desc"; then error "Failed to configure the virtual machine for $desc!" return 80 @@ -401,6 +403,7 @@ startInstall() { if [ -z "$CUSTOM" ] && [[ "${VERSION,,}" != "http"* ]]; then checkMemory "$VERSION" || return 67 + setDiskMinimum "$VERSION" || return 67 fi # Work from the temporary directory so the persistent source path can @@ -1454,6 +1457,17 @@ checkMemory() { return 0 } +setDiskMinimum() { + + local id="$1" + local required + + required=$(getRequiredDisk "$id") || return + DISK_MINIMUM="$required" + + return 0 +} + restoreBootMode() { local current="${BOOT_MODE:-}"