diff --git a/scripts/bootstrap-aio.sh b/scripts/bootstrap-aio.sh index 173496c71e..fff548b25a 100755 --- a/scripts/bootstrap-aio.sh +++ b/scripts/bootstrap-aio.sh @@ -167,7 +167,13 @@ mount -a || true # Build the loopback drive for swap to use if [ ! "$(swapon -s | grep -v Filename)" ]; then - loopback_create "/opt/swap.img" 1024M thick swap + memory_kb=$(awk '/MemTotal/ {print $2}' /proc/meminfo) + if [ "${memory_kb}" -lt "8388608" ]; then + swap_size="4G" + else + swap_size="8G" + fi + loopback_create "/opt/swap.img" ${swap_size} thick swap # Ensure swap will be used on the host if [ ! $(sysctl vm.swappiness | awk '{print $3}') == "10" ];then sysctl -w vm.swappiness=10 | tee -a /etc/sysctl.conf diff --git a/scripts/scripts-library.sh b/scripts/scripts-library.sh index 9bfb7e2827..2b1c142d9b 100755 --- a/scripts/scripts-library.sh +++ b/scripts/scripts-library.sh @@ -142,7 +142,7 @@ function loopback_create() { if [ "${LOOP_FILE_TYPE}" = "thin" ]; then truncate -s ${LOOP_FILESIZE} ${LOOP_FILENAME} elif [ "${LOOP_FILE_TYPE}" = "thick" ]; then - dd if=/dev/zero of=${LOOP_FILENAME} bs=${LOOP_FILESIZE} count=1 + fallocate -l ${LOOP_FILESIZE} ${LOOP_FILENAME} else exit_fail 'No valid option ${LOOP_FILE_TYPE} found.' fi