Here are a couple bash script’s I use on a regular basis.

Create Swap:

Remove Swap: