Linux Swap File

This article is intended for systems administrators that are comfortable with Linux.  If after reading this article you are scratching your head, please contact Viakoo support and we can assist you with the process.

 

 

To determine if a swap file already exists, issue the command:

      cat /proc/swaps

 

 

------------------------------------------------------------------------------------------------

In the following example, we’ll extend the swap space available in the /swapfile to 2GB.

You can do "df" command, and see if you have enough free space first under / (root) directory.

 

To change the size of the swap partition (file):

  1. Turn off all swap processes

 

sudo swapoff -a

  1. Resize the swap  

 

sudo dd if=/dev/zero of=/swapfile bs=1M count=2000

if = input file
of = output file
bs = block size
count = multiplier of blocks

  1. Make the file usable as swap

 

sudo mkswap /swapfile

  1. Activate the swap file

 

sudo swapon /swapfile

  1. Check the amount of swap available

 

grep SwapTotal /proc/meminfo

Have more questions? Submit a request

Comments

Powered by Zendesk