Skip to main content

Create/Edit Swap Partition

Tested Platform


Set-up Steps

1. Check the free space

free -m

2. Create a partition

dd if=/dev/zero of=SWAPFILE_DIRECTORY bs=COUNT count=SPACE
tip

COUNT could be 1K \ 1M \ 1G etc.

SPACE depends on your need, e.g. 1024

3. Formation

mkswap $SWAPFILE_DIRECTORY
chmod -R 600 $SWAPFILE_DIRECTORY

4. Turn it on

swapon $SWAPFILE_DIRECTORY

5. Enable it permanently

  1. Open /etc/fstab in the editor.

    vim /etc/fstab
  2. Add the line to it

    $SWAPFILE_DIRECTORY swap swap defaults 0 0