Skip to content

Instantly share code, notes, and snippets.

@oparrish2
oparrish2 / create-swap.sh
Created November 11, 2011 18:08
Script for creating a filesystem swap file on Linux
#!/bin/bash
SWAP_SIZE_MEGABYTES=$1
if [ $SWAP_SIZE_MEGABYTES -eq 0 ];then
echo No swap size given, skipping.
else
if [ -e /swapfile ];then
echo /swapfile already exists, skiping.
else
echo Creating /swapfile of $SWAP_SIZE_MEGABYTES Megabytes
dd if=/dev/zero of=/swapfile bs=1024 count=$(($SWAP_SIZE_MEGABYTES*1024))