1.03.2011

Need to add extra swap space? Read this

"Can Linux be installed without swap space?". This question might sound confusing for those who listen it for the first time and never tried out. But the reality is "Yes". But if you did this, you should be ready to cope up with your Linux box next time you put extra load on your box.It will crash someday.
Its always recommended to provide extra space for swap partition.Swap is only used when you have maximum load.

This article discuss how to increase the swap space through adding swap file on Linux machine.

Lets proceed with the requisite steps to add swap file as shown below:

Lets use dd command to create swapfile. Then you need to use mkswap command to set up a Linux swap area on a device or in a file.

a) Log in as root user.

b) Run this command to create 512MB swap file (1024 * 512MB = 524288 block size):

# dd if=/dev/zero of=/swapf1 bs=1024 count=524288

c) Set up a Linux swap area:

# mkswap /swapf1

d) Activate /swapfile1 swap space immediately:

# swapon /swapf1

e) To activate /swapf1 after Linux system reboot, add entry to /etc/fstab file. Open this file using text editor such as vi:

# vi /etc/fstab

Then,append following line:

/swapf1 swap swap defaults 0 0

So next time Linux comes up after reboot, it enables the new swap file for you automatically.

Verifying if the swap is activated or not?

$ free -m

Hope the article proves useful for everyone who wants an extra swap space therein.

No comments:

Post a Comment