What is swap partition

6

1

I read that the swap partition must have the double size of your RAM, that is optional to install, that is for hibernation mode only, several technical information that tells me what to do. I am using linux (Ubuntu at the moment).

Could anyone explain better swap partition?

Like:

  • What is
  • What is for
  • When should I use
  • Why should I use
  • How to partition correctly
  • Pros/ Cons to add this to system

lcsvcn

Posted 2014-10-19T15:22:20.353

Reputation: 215

Parts of your question are difficult to answer without knowing what is your operating system... – DavidPostill – 2014-10-19T15:24:16.680

& other parts seem to be confusing the swap file with the hibernation file – Tetsujin – 2014-10-19T15:26:38.407

2

You should read paging and All about Linux swap space

– DavidPostill – 2014-10-19T15:27:26.447

I edited adding the OS at the question... – lcsvcn – 2014-10-19T15:28:50.773

It should be noted that "swap partition" is a general term whose specific meaning depends on the OS in use. Original UNIX had a swap partition (or, more likely, an entire disk or two) where entire process images were swapped in and out, in order to multitask in a box with no memory mapping capability. Other systems use a "paging store" which is similar to the Windows "swap partition" and is used to swap in and out individual storage pages. – Daniel R Hicks – 2014-10-20T02:08:43.363

Answers

8

The main ideas before you dive into some guides if you feel like it to learn more details:

What is

It's a special type of partition (sometimes OSes simply use one giant swap file).

What is for

The swap partition is used by an OS to artificially increase the size of the memory.

When should I use

When you think that the size of your physical memory (a.k.a. RAM) won't to be enough to run all the programs you plan to use.

Why should I use

Because you don't want programs to crash because they are out of memory.

Pros/ Cons to add this to system

  • Pro: artificially increase the size of the memory, meaning that you could run more programs that you have done without it.
  • Con: disks much slower than RAM

Franck Dernoncourt

Posted 2014-10-19T15:22:20.353

Reputation: 13 518

The 'double your RAM' guideline is for Windows; Linux folk generally recommend only the same disk space as your RAM size. I run without a real swap partition, for I have an SSD instead of a spinning drive, aka HDD. – K7AAY – 2014-10-19T18:05:03.167

@K7AAY - Back before RAM was so plentiful, the 2X RAM guideline applied even to unix (and unix-like) operating systemsbbb. I remember that being a guideline back when I was provisioning SunOS machines. I tried to find a reference, but the guideline is so prolific that I can't find anything that predates Linux. Nowdays on many VM's I don't provision swap at all since I don't want swapping to the already busy SAN. I'd rather that the application fail due to OOM than to have swapping. – Johnny – 2014-10-20T00:01:03.453