+# if the swap instance variable is already set, then we'll use it.
+# this allows multiple different swap partitions to be added.
+if [ -z "$SWAP_INSTANCE" ]; then
+ SWAP_INSTANCE=1
+fi
+
+# allow the amount of swap space to be determined from outside the script.
+# this is measured in megabytes.
+if [ -z "$SWAP_SIZE" ]; then
+ SWAP_SIZE=2048
+fi
+
+/bin/dd if=/dev/zero of=/var/swap.${SWAP_INSTANCE} bs=1M count=${SWAP_SIZE}
+exit_on_error "creating swap file"
+
+/bin/chmod 600 /var/swap.${SWAP_INSTANCE}
+exit_on_error "setting swap file permissions"
+
+/sbin/mkswap /var/swap.${SWAP_INSTANCE}
+exit_on_error "formatting swap file as swap partition"
+
+/sbin/swapon /var/swap.${SWAP_INSTANCE}
+exit_on_error "enabling new swap partition"