diff --git a/scripts/firstrun b/scripts/firstrun index 812245b879..b997cfb844 100644 --- a/scripts/firstrun +++ b/scripts/firstrun @@ -37,16 +37,16 @@ echo -e "### [firstrun] Recreated SSH keys" >>${Log} MEMTOTAL=$(( $(awk -F" " '/^MemTotal/ {print $2}' /dev/null 2>&1 -if [ $? -eq 1 ]; then dd if=/dev/zero of=$SWAPFILE bs=1M count=128 status=noxfer >/dev/null 2>&1; fi -chown root:root $SWAPFILE -chmod 0600 $SWAPFILE -mkswap $SWAPFILE >/dev/null 2>&1 -swapon $SWAPFILE >/dev/null 2>&1 -if ! grep -q swap /etc/fstab; then echo "$SWAPFILE none swap sw 0 0" >> /etc/fstab; fi +if [[ ! -f "\$SWAPFILE" && "\$FREESIZE" -gt "132" ]]; then +fallocate -l 128M \$SWAPFILE >/dev/null 2>&1 +if [ $? -eq 1 ]; then dd if=/dev/zero of=\$SWAPFILE bs=1M count=128 status=noxfer >/dev/null 2>&1; fi +chown root:root \$SWAPFILE +chmod 0600 \$SWAPFILE +mkswap \$SWAPFILE >/dev/null 2>&1 +swapon \$SWAPFILE >/dev/null 2>&1 +if ! grep -q swap /etc/fstab; then echo "\$SWAPFILE none swap sw 0 0" >> /etc/fstab; fi if ! grep -q swap /etc/sysctl.conf; then echo "vm.swappiness=0" >> /etc/sysctl.conf; fi -echo -e "\n### [firstrun] Created 128MB emergency swap as $SWAPFILE" >>${Log} +echo -e "\n### [firstrun] Created 128MB emergency swap as \$SWAPFILE" >>${Log} fi # RAMLOG if [[ "$(apt-cache policy ramlog | grep Installed)" != "" ]]; then