From 95c88f77151f61c85dadd3c0384b20e3557ed2eb Mon Sep 17 00:00:00 2001 From: colin Date: Fri, 13 Sep 2024 16:46:03 -0400 Subject: [PATCH] Update swap.sh --- swap.sh | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/swap.sh b/swap.sh index 117ff33..68d81f7 100644 --- a/swap.sh +++ b/swap.sh @@ -5,11 +5,11 @@ create_swapfile() { # Detect the main disk by finding the partition mounted on root ('/') mount_point=$(df / | tail -1 | awk '{print $6}') - # Get available space on the partition in GB - available_space=$(df -BG $mount_point | tail -1 | awk '{print $4}' | sed 's/G//') + # Get available space on the partition in MB + available_space=$(df -BM $mount_point | tail -1 | awk '{print $4}' | sed 's/M//') # Calculate 5% of the available space, and ensure it's within the limits (max 30GB) - swap_size=$((available_space * 5 / 100)) + swap_size=$((available_space * 5 / 100 / 1024)) # Convert MB to GB if [ $swap_size -gt 30 ]; then swap_size=30 elif [ $swap_size -lt 1 ]; then