]> git.proxmox.com Git - pve-installer.git/commitdiff
fine tune swap selection for low memory/space setups
authorThomas Lamprecht <t.lamprecht@proxmox.com>
Fri, 18 Nov 2022 09:23:56 +0000 (10:23 +0100)
committerThomas Lamprecht <t.lamprecht@proxmox.com>
Fri, 18 Nov 2022 09:23:57 +0000 (10:23 +0100)
Switch also from tracking the calculation in GB to MB for higher
accuracy and more flexibility.

Note also that the hd_gb / 8 -> GB is the same as hd_gb * 128 -> MB,
so the auto-calculation did not change semantically.

Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
proxinstall

index c93941821112af52d7003f878469467f36e42cbc..a69fd5d42d9946b137b2f9affdef0ff9e044f58c 100755 (executable)
@@ -1202,11 +1202,14 @@ sub compute_swapsize {
     if (defined($config_options->{swapsize})) {
        $swapsize = $config_options->{swapsize} * 1024 * 1024;
     } else {
-       my $ss = int ($total_memory / 1024);
-       $ss = 4 if $ss < 4;
-       $ss = ($hdgb/8) if $ss > ($hdgb/8);
-       $ss = 8 if $ss > 8;
-       $swapsize = $ss*1024*1024;
+       my $ss = int($total_memory);
+       $ss = 4096 if $ss < 4096 && $hdgb >= 64;
+       $ss = 2048 if $ss < 2048 && $hdgb >= 32;
+       $ss = 1024 if $ss >= 2048 && $hdgb <= 16;
+       $ss = 512 if $ss < 512;
+       $ss = int($hdgb * 128) if $ss > $hdgb * 128;
+       $ss = 8192 if $ss > 8192;
+       $swapsize = $ss * 1024;
     }
 
     return $swapsize;