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

Read 369 articles by

3 Comments

  1. wilmor24 says:

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

    • Dhaval Thakar says:

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

  • How to Modify Swap Size – Ubuntu 10.04 « It Could Always Be Worse says:

    [...] to use at least 2GB of memory in order to create a database, let alone run it. With help from this excellent post from LinuxReaders, I expanded my swap size to 2GB (again, Oracle’s recommended size for 11g) [...]

Leave a Reply

Your email address will not be published. Required fields are marked *

*

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong> <pre lang="" line="" escaped="" highlight="">

Archives

Categories

Page optimized by WP Minify WordPress Plugin