Questions tagged [swap]

Linux divides its physical RAM (random access memory) into chucks of memory called pages. Swapping is the process whereby a page of memory is copied to the preconfigured space on the hard disk, called swap space, to free up that page of memory. The combined sizes of the physical memory(RAM) and the swap space is the amount of virtual memory available. Linux has two forms of swap space: the swap partition and the swap file.

From linux.com All about swap space:

Linux divides its physical RAM (random access memory) into chucks of memory called pages. Swapping is the process whereby a page of memory is copied to the preconfigured space on the hard disk, called swap space, to free up that page of memory. The combined sizes of the physical memory and the swap space is the amount of virtual memory available.

Swapping is necessary for two important reasons. First, when the system requires more memory than is physically available, the kernel swaps out less used pages and gives memory to the current application (process) that needs the memory immediately. Second, a significant number of the pages used by an application during its startup phase may only be used for initialization and then never used again. The system can swap out those pages and free the memory for other applications or even for the disk cache. However, swapping does have a downside. Compared to memory, disks are very slow.

Linux has two forms of swap space: the swap partition and the swap file. The swap partition is an independent section of the hard disk used solely for swapping; no other files can reside there. The swap file is a special file in the filesystem that resides amongst your system and data files.

Swap space size should be either similar to system RAM or double it's size.

340 questions
92
votes
5 answers

Why don't EC2 ubuntu images have swap?

I started a couple servers on EC2 and they don't have swap. Am I doing something wrong or is it that the machines just don't have any?
rafamvc
  • 1,119
  • 1
  • 8
  • 7
89
votes
6 answers

swap partition vs file for performance?

What is better for performance? A partition closer to the inside of the disk will have slower access times, and we must wait for the drive to switch between the OS and swap partitions. On the other hand, a swap partition bypasses all of the…
Bill Gray
  • 1,295
  • 1
  • 11
  • 18
81
votes
7 answers

Best way to disable swap in Linux

I am running a custom compiled 3.18.9 kernel and I am wondering about the best way to disable swap on the system. I also use init if it makes a difference. Is it enough to comment or remove the swap line in /etc/fstab to prevent swap from…
user283167
  • 813
  • 1
  • 7
  • 7
67
votes
10 answers

Linux: how to explicitly unswap everything possible?

I've launched something that took lots of memory and now everything lags a lot. I guess all applications' memory has gone to swap in order to free some space for the memory-intensive process, and now everything is slowly returning to RAM when…
kolypto
  • 10,738
  • 12
  • 51
  • 66
65
votes
4 answers

Why disable swap on kubernetes

Since Kubernetes 1.8, it seems I need to disable swap on my nodes (or set --fail-swap-on to false). I cannot find the technical reason why Kubernetes insists on the swap being disabled. Is this for performance reasons? Security reasons? Why is the…
Jeroen Jacobs
  • 1,276
  • 3
  • 15
  • 24
53
votes
12 answers

How much SWAP space on a 2-4GB system?

How should I decide what size to make my swap on a new Linux machine (Debian) with 2-4 GB of RAM? Do I really need swap space?
C. Ross
  • 2,995
  • 8
  • 32
  • 36
50
votes
7 answers

What is swap memory?

I am using RAM for storing some of my database tables and the others are stored in hard disk. Today I came to know that my processes are using swap memory. Now what is swap memory and how can I detect that which process is using swap memory and how…
developer
40
votes
5 answers

Should I be concerned that swap is being used on a host with nearly 40GB of free memory?

I have a production host, below: The system is using 1GB of swap, while maintaining nearly 40GB of free, unused memory space. Should I be concerned about this, or is it mostly normal?
MrDuk
  • 815
  • 1
  • 10
  • 18
31
votes
4 answers

How do I tell if my Windows server is swapping?

I'm using Process Explorer to monitor my windows server while it reconstructs some data. It's primarily a CPU intensive process, but I want to make sure it's not swapping. How can I tell if it is using Process Explorer? My initial guess is in the…
churnd
  • 3,977
  • 5
  • 33
  • 41
30
votes
7 answers

How to get the Linux OOM killer to not kill my process?

How do I get the Linux OOM killer to not kill my processes when physical memory is low but there is plenty of swap space? I have disabled OOM killing and overcommit with sysctl vm.overcommit_memory=2. The VM has 3 GB of absolutely free unfragmented…
Coder
  • 425
  • 1
  • 4
  • 6
30
votes
4 answers

How do I tell what process is causing kswapd to be in use?

I see kswapd using 100% CPU... how can I tell on which process's behalf kswapd is being used so much?
Deshawn
  • 363
  • 2
  • 4
  • 5
24
votes
8 answers

Should I completely turn off swap for linux webserver?

Recently my friend told me that it is a good idea to turn off swap on linux webservers with enough memory. My server has 12 GB and currently uses 4GB (not counting cache and buffers) under peak load. His argument was that in a normal situation…
Poma
  • 1,289
  • 6
  • 22
  • 35
22
votes
3 answers

How to disable swap files in ESXi?

We are running a few Solaris / Linux VMs on ESXi that contain very sensitive encrypted data that eventually get decrypted as required in memory. Everything is fine, except for the ESXi swap files which could potentially store some of the decrypted…
Marius Burz
  • 331
  • 1
  • 2
  • 6
19
votes
4 answers

How to increase swap size?

Recently, I put more ram into my server and now I have got a total of 24GB of RAM. Originally, I setup the OS to have a 2GB swap size. /dev/sdc1 1 281 2257101 82 Linux swap / Solaris /dev/sdc2 * 282 60801…
x-man
  • 377
  • 2
  • 4
  • 12
19
votes
3 answers

How do I increase swap memory in debian?

how to increase swap memory in debian?
1
2 3
22 23