Linux: Should I Increase Swap

Posted on 2011-10-17
Last Modified: 2012-05-12
Swap is 0.  Should it be increased?
-bash-3.2# free
             total       used       free     shared    buffers     cached
Mem:        524288       8672     515616          0          0          0
-/+ buffers/cache:       8672     515616
Swap:            0          0          0

Open in new window

Question by:hankknight
    LVL 21

    Accepted Solution

    You nearly always want at least some swap, especially if you only have 512MB of RAM.  I'm a bit thrown back however that you are only currently using 8.5MB, but anyways.

    A very non-technical explanation could be -- think of swap as the "oh crap" memory for your applications when the physical memory is used up.  It allows portions of the physical memory contents not currently being used to be swapped out to disk to free up physical space for other processes, and swapped back if/when possible.

    For servers, you don't want to rely on swap -- you want swap for the "oh crap" factor, then if more physical memory is truly needed, add some.

    In current Linux kernels, swap space is also used for tmpfs filesystems such as /tmp and /dev/shm.

    Basically with 0 swap and especially with only 512MB RAM, you are setting yourself up for system failures.
    LVL 21

    Assisted Solution

    Read through this link, it covers most of the basics without getting super-technical.
    LVL 13

    Expert Comment

    by:Hugh McCurdy
    Papertrip offers good advice.  I suggest you follow it.
    LVL 7

    Assisted Solution

    For the most part, I'd not have any less swap than the amount of RAM you have, and being a long time linux user, I'm still used to having my rule of thumb being that you have twice as much swap space as RAM.

    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone.

    Featured Post

    What Should I Do With This Threat Intelligence?

    Are you wondering if you actually need threat intelligence? The answer is yes. We explain the basics for creating useful threat intelligence.

    Using 'screen' for session sharing, The Simple Edition Step 1: user starts session with command: screen Step 2: other user (logged in with same user account) connects with command: screen -x Done. Both users are connected to the same CLI sessio…
    Linux users are sometimes dumbfounded by the severe lack of documentation on a topic. Sometimes, the documentation is copious, but other times, you end up with some obscure "it varies depending on your distribution" over and over when searching for …
    Learn several ways to interact with files and get file information from the bash shell. ls lists the contents of a directory: Using the -a flag displays hidden files: Using the -l flag formats the output in a long list: The file command gives us mor…
    Learn how to get help with Linux/Unix bash shell commands. Use help to read help documents for built in bash shell commands.: Use man to interface with the online reference manuals for shell commands.: Use man to search man pages for unknown command…

    760 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    9 Experts available now in Live!

    Get 1:1 Help Now