preload preload preload preload

Creating a swap file

Using the command dd you can create swap file.

dd – convert and copy a file

First of all check the current swap size using the command ‘free’

$ free
Output
total       used       free     shared    buffers     cached
Mem:       1025620    1009140      16480          0       2252     465116
-/+ buffers/cache:     541772     483848
Swap:      2096440      18924    2077516

Create a directory called ’swap’ under slash ‘/’

$ sudo mkdir /swap

First creat a file using dd command

Creates a file of size 1GB

$ sudo dd if=/dev/zero of=/swap/swap.file bs=2048 count=524288

Format this file ‘/swap/swap.file’ using the command ‘mkswap’

$ mkswap /swap/swap.file

Activate the ’swap.file’ to the current swap space using the command ’swapon’

$ swapon /swap/swap.file

After the above command 1GB will be added to you are swap area.

You can check by the command ‘free’

$ free
             total       used       free     shared    buffers     cached
Mem:       1025620    1010660      14960          0       2620     465292
-/+ buffers/cache:     542748     482872
Swap:      3145008      18924    3126084

You can remove the swap area by using the command ’swapoff’

$ swapoff /swap/swap.file
  • Share/Bookmark
  • Leave a Reply

    * Required
    ** Your Email is never shared