Swap File

May 21 2011

To create swap space in a file:

First, create a file. I have 4GB of RAM, hence I create 4GB large file

$ sudo dd if=/dev/zero of=/media/4GB.swap bs=1G count=4

Set proper file attributes

$ sudo chmod 600 /media/4GB.swap

Set created file as a swap space

$ sudo mkswap /media/4GB.swap

Start swapping

$ sudo swapon /media/4GB.swap

Edit the fstab file

$ sudo vim  /etc/fstab

and set the swap file to mount automatically on next reboot

/media/4GB.swap	swap		swap		defaults	0	0
Tags: ,

Comments Off

Comments are closed at this time.

Performance Optimization WordPress Plugins by W3 EDGE