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