fix: auto-shrink to 10% of virtual size, min 20 GB

Replaces flat 30 GB default with proportional sizing:
- 500 GB → 50 GB, 200 GB → 20 GB, 80 GB → 20 GB
- Less aggressive for large disks, safer for GRUB boot
- Update UI hint and README to reflect new rule
This commit is contained in:
Claus Lohmar 2026-07-23 12:45:32 +00:00
parent 778e929985
commit cd8d86a98c
3 changed files with 14 additions and 8 deletions

View file

@ -251,10 +251,12 @@ Virtual disk images (VMDK, QCOW2) have two sizes:
| **Actual size** | Real data in the image (sparse file) | ~7 GB | | **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 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. 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 | | You enter | Result |
|-----------|--------| |-----------|--------|

View file

@ -283,11 +283,15 @@ def _process_job(job_id: str, req: JobSubmissionRequest):
current_gb = current_bytes / (1024 ** 3) current_gb = current_bytes / (1024 ** 3)
target_gb = req.target_disk_size_gb target_gb = req.target_disk_size_gb
if target_gb is None and current_gb > 30: if target_gb is None:
target_gb = 30 # Auto-shrink: 10% of virtual size, minimum 20 GB
logger.info("Auto-shrink: %.1f GiB → %d GiB", current_gb, target_gb) auto_target = max(int(current_gb * 0.1), 20)
elif target_gb is None: 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 target_gb = int(round(current_gb)) + 1
logger.info("Disk already <= target, no shrink needed")
if target_gb < current_gb: if target_gb < current_gb:
_update_job(job_id, progress=60, _update_job(job_id, progress=60,

View file

@ -43,7 +43,7 @@
<input type="number" name="target_disk_size_gb" class="pve-input" <input type="number" name="target_disk_size_gb" class="pve-input"
value="{{ analysis.disk_size_gb }}" value="{{ analysis.disk_size_gb }}"
placeholder="Leave blank for auto-shrink"> placeholder="Leave blank for auto-shrink">
<span class="pve-hint">{{ analysis.disk_size_gb }} GB detected. Omit to auto-shrink to 30 GB.</span> <span class="pve-hint">{{ analysis.disk_size_gb }} GB detected. Omit to auto-shrink (10% of size, min 20 GB).</span>
</div> </div>
</div> </div>
<div class="pve-row"> <div class="pve-row">