Ajeet Raina Docker Captain, ARM Innovator & Docker Bangalore Community Leader.

How to increae Swap space under Linux

56 sec read

“Can Linux be installed without swap space?”.

This question was asked to me on one of Linux System admin interview. It might confuse anyone who is still fresher and have no hands-on experience with swap terminology.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):

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

c) Set up a Linux swap area:

  1. mkswap /swapf1

d) Activate /swapfile1 swap space immediately:

  1. 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:

  1. 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.

Have Queries? Join https://launchpass.com/collabnix

Ajeet Raina Docker Captain, ARM Innovator & Docker Bangalore Community Leader.

3 Replies to “How to increae Swap space under Linux”

  1. Thanks for sharing superb informations. Your site is very cool. I am impressed by the details that you’ve on this website. It reveals how nicely you understand this subject. Bookmarked this website page, will come back for extra articles. You, my friend, ROCK! I found just the info I already searched all over the place and simply could not come across. What a great website.

Leave a Reply

Your email address will not be published.