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
7
votes
3 answers

Memory is free, but still swapping?

I'm sure this is a pretty basic question, but I'm just trying to get a grasp of what's going on with my Ubuntu Hardy server running a Rails-based site. It seems that I have free memory available, yet the system is reporting that it is still swapping…
japancheese
7
votes
4 answers

What are the exact conditions based on which Linux swaps process(s) memory from RAM to a swap file?

My server has 8Gigs of RAM and 8Gigs configured for swap file. I have memory intensive apps running. These apps have peak loads during which we find swap usage increase. Approximately 1 GIG of swap is used. I have another server with 4Gigs of RAM…
Zenil
  • 281
  • 1
  • 2
  • 6
6
votes
1 answer

Docker using huge amount of swap memory on Ubuntu 15.04, why?

I am suffering from excessive memory usage, currently amounting to ~940 MB physical and ~1 GB swap memory, on my Ubuntu 15.04 x64 Docker (1.9.1-cs2, build 4ade326) host. According to top, Docker is responsible for the consumption of about 780 MB of…
aknuds1
  • 2,085
  • 3
  • 16
  • 23
6
votes
3 answers

Is it safe to store a swap-file on the Temporary Disk on Azure?

I've got a virtual Linux server running on Microsoft Azure. The machine has a disk /dev/sdb1 mounted to /mnt. This folder contains a file DATALOSS_WARNING_README.txt with the following content: WARNING: THIS IS A TEMPORARY DISK. Any data stored on…
Bob
  • 393
  • 3
  • 8
6
votes
4 answers

How to enable swap with salt stack?

How can I create and enable permanent 1GB swap file with salt stack that will work after reboot? salt.states.mount.swap does not allow to define swap size. Furthermore I need to define swappiness. Currently I do it with echo vm.swappiness = 10 |…
igo
  • 313
  • 4
  • 8
6
votes
3 answers

How to increase swap space on a live server

On Ubuntu 14.04, the swap file has to be increased as the memory and swap usage are reaching 100% usage. On a live production server, can the swap be increased with minimal disruption to the service? Output of free -h: total used …
Nyxynyx
  • 1,449
  • 10
  • 37
  • 47
6
votes
2 answers

Is there ever a reason to use tmpfs instead of or in addition to zRAM?

I'm thinking about using zRam on my server. From what I've read about zRam, it apparently does everything tmpfs does and more. Once zRAM is working, is there any reason to keep tmpfs around? Is there anything tmpfs does that zRAM can't do? Is there…
David Cary
  • 398
  • 3
  • 16
6
votes
8 answers

Swap file fragmentation: fact or fiction?

This is about Windows, but I'm sure it applies to other OS as well. I've heard people say that if you want better performance, you should avoid swap file fragmentation. To do this, you can either manually specify a constant size for the swap file,…
Vilx-
  • 791
  • 4
  • 13
  • 25
6
votes
1 answer

Why does host swap out VMs when there are 16GB of buffer cache and swappiness = 0?

I have a desktop running Ubuntu Quantal using OpenStack Folsom on an Intel i5 with 32 GB RAM and 2 GB swap. I'm running 7 VMs each sized like a EC2 m1.small, so 1.7 GB RAM each. I'm using KVM. As I get up to running 5 or 6 concurrently, the host…
Blair Zajac
  • 531
  • 5
  • 9
6
votes
3 answers

Should I use swap in KVM guest?

Now I'm trying to create KVM templates with CentOS and I'm not sure should I create swap partition on guest OS or not. In future it will be lot's of small VPS with 256-1024Mb RAM and if swap partition is a good idea will be 256Mb of swap enough for…
cpt.Buggy
  • 279
  • 2
  • 9
6
votes
5 answers

What happens if you run out of RAM and swap?

Running MySQL on a box with 32 gigs of RAM. Swap is 99% full, and there is about 200 MB of RAM free. MySQL is the culprit of course. What happens when both RAM and swap are completely filled? Thanks!
cat pants
  • 2,139
  • 10
  • 33
  • 44
5
votes
1 answer

Swapfile mount (/etc/fstab): "swap swap" or "none swap"

There seems to be conflicting information on how to mount a swapfile. swap swap: none swap: both: Both ways work. What is the official recommendation and how does each way affect swapping?
Gaia
  • 1,777
  • 4
  • 32
  • 58
5
votes
4 answers

How to check the content of swap memory in Linux?

I am trying to find out what exactly uses swap memory in my system. Free reports over 5GB of used swap memory, but all processes use only 24MB of swap. I suspect that swap might be used by a tmpfs filesystem, but I don't know how to check it. Would…
gbajson
  • 191
  • 1
  • 8
5
votes
4 answers

Can I run an Oracle server without swap?

Official Oracle docs say that for a machine with more than 16GiB of RAM we need to allocate 16GiB of swap. Our servers are RHEL 7 and have 256GiB of RAM. DBAs do not want to see the system swap, so they want us to monitor the 16GiB of swap very…
chutz
  • 7,569
  • 1
  • 28
  • 57
5
votes
2 answers

Swap with a huge amount of ram available

I have an old, legacy server with an odd problem with swap. Linux version: Red Hat Enterprise Linux Server release 5.6 (Tikanga) Kernel version: 2.6.18-238.el5 Server is virtual. Server has 2 virtual socket. I know swap partition is to small,…
user_0
  • 151
  • 1
  • 5