Revision 93142965901e4392ed2e225a6bb2a5f9d2281bcc authored by Shivaram Venkataraman on 11 January 2017, 00:06:05 UTC, committed by GitHub on 11 January 2017, 00:06:05 UTC
2 parent s 5188c78 + fcbe85f
Raw File
create-swap.sh
#!/bin/bash

if [ $# -lt 1 ]; then
  echo "Usage: create-swap.sh <amount of MB>"
  exit 1
fi

if [ -e /mnt/swap ]; then
  echo "/mnt/swap already exists" >&2
  exit 1
fi

SWAP_MB=$1
if [[ "$SWAP_MB" != "0" ]]; then
  dd if=/dev/zero of=/mnt/swap bs=1M count=$SWAP_MB
  mkswap /mnt/swap
  swapon /mnt/swap
  echo "Added $SWAP_MB MB swap file /mnt/swap"
fi
back to top