How to Modify Swap Size

I am one of those Linux users who either skips SWAP during installation or assigns minimum space possible.
Reason being, now a days RAM is affordable, 2Gb RAM is common. Thus there is no logic assigning one & half OR double size of your RAM to SWAP. With routine work I hardly consume 400Mb.

So basically we do not require higher SWAP unless we use memory hogging application, e.g I want to try new Linux distro on virtual machine (although VM works on physical memory, just for example).

Create 1Gb swapfile
dd if=/dev/zero of=/tmp/swapfile bs=1MB count=1024

Create swap area
mkswap /tmp/swapfile

Enable Swapfile

swapon /tmp/swapfile

Check total size of SWAP memory.
free -m

If you wish to make it permanent enter following line in /etc/fstab
/tmp/swapfile swap swap defaults 0 0

In case you wish to remove additional swap
swapoff /tmp/swapfile
rm -rf /tmp/swapfile

Refer


if you find any missing point in here, please let us know in comment section or tweet us at @linuxreaders. To get more articles like this, subscribe to our RSS feeds / Mails.

Article by Dhaval Thakar

Hi, I am Linux Admin. You'll find my articles small & without much descriptions.
Read 218 articles by
  • Pingback: How to Modify Swap Size – Ubuntu 10.04 « It Could Always Be Worse

  • http://wilmor24.blogspot.com wilmor24

    Verified on 2010-05-13 for Ubuntu 10.04 LTS and it works perfect. Thanks!

    • http://www.linuxreaders.com/ Dhaval Thakar

      Thanks for the verification. Being part time blogger I can’t test my post on diff distros.
      Such comments makes my work easy.

Archives

Categories

Page optimized by WP Minify WordPress Plugin