From 885e123bf4f20eb2f0a8203e092ab419b382ee89 Mon Sep 17 00:00:00 2001 From: "bscriver123 (aider)" Date: Wed, 11 Dec 2024 18:51:14 +0000 Subject: [PATCH] fix: Replace fallocate with dd to create swap file safely --- aws/aws_ec2_ebs_docker_host/provision-swap.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/aws/aws_ec2_ebs_docker_host/provision-swap.sh b/aws/aws_ec2_ebs_docker_host/provision-swap.sh index 96cd743..8435a8f 100644 --- a/aws/aws_ec2_ebs_docker_host/provision-swap.sh +++ b/aws/aws_ec2_ebs_docker_host/provision-swap.sh @@ -12,8 +12,8 @@ SWAPPINESS=$2 echo "Setting up a swap file (size: $SWAP_FILE_SIZE, swappiness: $SWAPPINESS)..." -# Create the swap file -sudo fallocate -l ${SWAP_FILE_SIZE} /swapfile +# Create the swap file using dd +sudo dd if=/dev/zero of=/swapfile bs=1M count=${SWAP_FILE_SIZE} # Only root should be able to access to this file sudo chmod 600 /swapfile