diff --git a/mint/make_swapvol.sh b/mint/make_swapvol.sh index ce81659..7b11002 100644 --- a/mint/make_swapvol.sh +++ b/mint/make_swapvol.sh @@ -1,5 +1,14 @@ #!/bin/bash +get_total_ram_in_mb() { + # Verwenden von /proc/meminfo, um die Gesamtgröße des RAM zu ermitteln + total_ram_kb=$(grep MemTotal /proc/meminfo | awk '{print $2}') + + # Umrechnung von KB in MB + total_ram_mb=$((total_ram_kb / 1024)) +} + + # skript baut ein subvol /@swap unten drunter und mountet das # ganze als /swap um darin /swap/swapfile als swapspace # zu aktivieren - größe 8G oder was man sich ausdenkt @@ -49,8 +58,17 @@ sudo chmod 600 /swap/swapfile # Disable COW for this file. sudo chattr +C /swap/swapfile +# Determine Size of Swapfile +# if RAM is below 8GB we default to 8GB SWAP +# if we have above 8GB we assume RAM Size for SWAP Size 1to1 + +if [total_ram_mb < 8192]; then +swapsize=8192 +else +swapsize=$total_ram_mb + # Set size of the swap file to 8G as an example. -sudo dd if=/dev/zero of=/swap/swapfile bs=1M count=8192 +sudo dd if=/dev/zero of=/swap/swapfile bs=1M count=$swapsize # Format the swapfile. sudo mkswap /swap/swapfile