Add extra comment about blocksizes. Inline if, to check if swap was mounted

This commit is contained in:
Michael Kroes 2016-03-16 12:54:19 +01:00
parent dfe1374901
commit 85e6118ae3
1 changed files with 3 additions and 2 deletions

View File

@ -41,7 +41,8 @@ if
then
echo "Adding swap to the system..."
# Allocate and activate the swap file
# Allocate and activate the swap file. Allocate in 1KB chuncks
# doing it in one go, could fail on low memory systems
dd if=/dev/zero of=/swapfile bs=1024 count=$[1024*1024] status=none
if [ -e /swapfile ]; then
chmod 600 /swapfile
@ -50,7 +51,7 @@ then
fi
# Check if swap is mounted then activate on boot
if [ -n "$(swapon -s | grep "\/swapfile")" ]; then
if swapon -s | grep -q "\/swapfile"; then
echo "/swapfile none swap sw 0 0" >> /etc/fstab
else
echo "ERROR: Swap allocation failed"