diff --git a/README.md b/README.md index 1bf2948..812d272 100644 --- a/README.md +++ b/README.md @@ -251,10 +251,12 @@ Virtual disk images (VMDK, QCOW2) have two sizes: | **Actual size** | Real data in the image (sparse file) | ~7 GB | During analysis, the UI shows the virtual size (e.g. *"500.0 GB detected. Omit to -auto-shrink to 30 GB"*). This is because the source image was created with a +auto-shrink"*). This is because the source image was created with a large virtual disk, but only a fraction is used. -**Target Disk Size field — what happens:** +**Auto-shrink**: if you leave Target Disk Size blank, the disk shrinks to +**10% of its virtual size, minimum 20 GB**. A 500 GB disk becomes 50 GB, +an 80 GB disk becomes 20 GB. You can override this by entering a value. | You enter | Result | |-----------|--------| diff --git a/backend/provisioner.py b/backend/provisioner.py index 6504616..80cb50f 100644 --- a/backend/provisioner.py +++ b/backend/provisioner.py @@ -283,11 +283,15 @@ def _process_job(job_id: str, req: JobSubmissionRequest): current_gb = current_bytes / (1024 ** 3) target_gb = req.target_disk_size_gb - if target_gb is None and current_gb > 30: - target_gb = 30 - logger.info("Auto-shrink: %.1f GiB → %d GiB", current_gb, target_gb) - elif target_gb is None: - target_gb = int(round(current_gb)) + 1 + if target_gb is None: + # Auto-shrink: 10% of virtual size, minimum 20 GB + auto_target = max(int(current_gb * 0.1), 20) + if current_gb > auto_target: + target_gb = auto_target + logger.info("Auto-shrink: %.1f GiB → %d GiB (10%% rule)", current_gb, target_gb) + else: + target_gb = int(round(current_gb)) + 1 + logger.info("Disk already <= target, no shrink needed") if target_gb < current_gb: _update_job(job_id, progress=60, diff --git a/frontend/templates/_analysis.html b/frontend/templates/_analysis.html index 10012e1..7b15b41 100644 --- a/frontend/templates/_analysis.html +++ b/frontend/templates/_analysis.html @@ -43,7 +43,7 @@ - {{ analysis.disk_size_gb }} GB detected. Omit to auto-shrink to 30 GB. + {{ analysis.disk_size_gb }} GB detected. Omit to auto-shrink (10% of size, min 20 GB).