#!/bin/bash #Copyright 2002 William Stearns #Based on work by Jeff Dike SWAPMEGS=${SWAPMEGS:-126} if [ -f swap ] || [ -f swap.old ]; then echo Moving old swapspace out of the way... if [ -f swap.old ]; then rm -f swap.old ; fi if [ -f swap ]; then mv -f swap swap.old ; fi fi echo Creating an empty swapfile... dd if=/dev/zero of=swap bs=$((1024 * 1024)) count=0 seek=$SWAPMEGS || exit 1 #Make a completely sparse file to start with; use "count=$SWAPMEGS", no seek if you'd rather not. echo Making swap space in it... # $SUDO not necessary, it appears. mkswap swap || exit 1