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.

342 questions
2
votes
2 answers

Could swap use many inodes?

I have got a graph about high inode use of our server's disk but I haven't got any detailed information (like df -i) so I'd like to guess the reason. Operating System: Red Hat Linux Process: PDF generation
2
votes
1 answer

How to prevent kernel I/O thrashing in absence of swap memory on Linux?

I had problem with a process spawning very many threads due to a bug, eating up memory, causing heavy swapping to the swap partition. Thus, I switched off swap – which is recommended in server clusters anyway – to let the buggy program fail early. …
Torsten Bronger
  • 276
  • 1
  • 2
  • 12
2
votes
1 answer

Delete a file that was created with fallocate

I started to create a swapfile. I used this command: sudo fallocate -l 1G /swapfile Then, I decided that I want to make the swapfile in a different path, so I used the command again with the right path and activated the new swap file. How can I…
Noam B.
  • 119
  • 3
  • 7
2
votes
1 answer

I loose the swap every time I restart my Ubuntu server

Here is how I set the swap: sudo /bin/dd if=/dev/zero of=/var/swap.1 bs=1MB count="1000" sudo /sbin/mkswap /var/swap.1 sudo /sbin/swapon /var/swap.1 Every time I reboot/restart the swap is gone. The command free gives me zeros for swap. But the…
jnbdz
  • 927
  • 5
  • 24
  • 46
2
votes
1 answer

Lack of free swap space on linux Zabbix server

I have been getting this Lack of free swap space on Zabbix server on my aws instance via zabbix monitoring. I am thinking of creating say 2 Gb of swap space. Do I risk loosing or interfering with anything since it is a live server (being used). I…
Bob Mwenda
  • 21
  • 1
  • 2
2
votes
2 answers

Using swap even though 20GB free memory, swappiness=0

We have a CentOS 7 server that goes into swap a little bit about once a week, despite having > 20GB of available memory, and swappiness is set to 0. We want to be able to use swap as a sort of sentinel that we are running out of memory without…
Jay Paroline
  • 159
  • 1
  • 9
2
votes
2 answers

Active process swapping despite free memory

For some reason our system starts swapping (actively used memory) at around 60GB used memory. (see edit below, it seems I/O and disk cache usage, even of previously run processes has an effect) Turning it off (swapoff-a) for test lead to bad_alloc's…
b.buchhold
  • 121
  • 2
2
votes
1 answer

Linux Mint: Python process gets "MemoryError" before swap is even close to fully used

I'm attempting to run a Python script that requires a lot of Virtual Memory. I'm on Linux Mint 17.3 64 bit and Python 2.7. As the Python process grows, I can see (using free -m) the amount of RAM use increase, but the amount of swap space used…
user1084684
  • 155
  • 1
  • 7
2
votes
0 answers

Linux swap partition not mounted by systemd on boot after dist-upgrade

Recently, I performed a dist-upgrade from Debian Wheezy to Jessie. The upgrade was performed without any error but after the upgrade the swap partition was no longer mounted/activated. The mentioned system is a KVM (qemu-kvm, centos7). During the…
YuTendo
  • 21
  • 1
  • 4
2
votes
2 answers

Why takes CLEARING swap soo long?

Why is moving from RAM to swap fast and from swap to RAM very slow? When I run program that needs more memory that is available, I see that the RAM is prety quickly "cleaned" by moving unsused (=the least accessed) pages to swap. But then when I…
mvorisek
  • 515
  • 1
  • 9
  • 19
2
votes
1 answer

Linux hibernate: how to specify a swap partition to store data if I have two?

We can specify the swap partition to load data from when recovering from a systemd hibernation using kernel argument resume=/dev/xxx. However, I didn't find any command-line or kernel argument to choose which partition to swap into. $ sudo systemctl…
Lv Zheng
  • 131
  • 2
2
votes
2 answers

Linux Swap used is higher than total

I found a bizare think on my server. The swap used is significantly higher than the total swap. free -m total used free shared buffers cached Mem: 1869 1788 80 71 35 …
2
votes
1 answer

How do you know when server memory needs to be increased?

I have a VPS running a few websites for clients. Running free -h shows the following: ~$ free -h total used free shared buffers cached Mem: 994M 855M 138M 39M 72M 420M -/+…
2
votes
1 answer

Forcing a user to use swap space after certain memory usage (using limits.conf?)

I have a backend app that is being used internally by developers hosted on our server, however, the app unfortunately requires the use of Passenger and Ruby, both of which are very memory-hungry. I have an SSD swapfile that should allow reasonable…
Ecksters
  • 123
  • 4
2
votes
1 answer

How do I increase the swap size on a xen guest machine using xm?

I'm attempting to increase the amount of swap on a xen guest machine. At first I thought it'd be similar to increasing the hard drive space, which I do like this: cd /srv/xen/domains/$host/ xm shutdown $host cp disk.img disk.img.backup dd…
lucas
  • 200
  • 3
  • 10