Questions tagged [swap]

Swap space is an area of the hard disk that serves as an overflow when the computer memory is full. The memory used by inactive applications is partially written out to disk to make room for other applications and for the disk cache for active files.

From the Ubuntu Swap Faq:

Swap space is the area on a hard disk which is part of the Virtual Memory of your machine, which is a combination of accessible physical memory (RAM) and the swap space. Swap space temporarily holds memory pages that are inactive. Swap space is used when your system decides that it needs physical memory for active processes and there is insufficient unused physical memory available. If the system happens to need more memory resources or space, inactive pages in physical memory are then moved to the swap space therefore freeing up that physical memory for other uses. Note that the access time for swap is slower therefore do not consider it to be a complete replacement for the physical memory. Swap space can be a dedicated swap partition (recommended), a swap file, or a combination of swap partitions and swap files.
703 questions
192
votes
4 answers

How can I check if swap is active from the command line?

How can I check if swap is active, and which swap devices are set up, on the command line?
ptrcao
  • 5,635
104
votes
4 answers

How can swapoff be that slow?

Somehow I happened to swap out 14 GB of memory. After having killed the culprit, I have tons of free memory again, so I thought I could bring in the important data again. So with 5 GB out of 32 GB used and 14 GB of swap space used, I ran swapoff…
maaartinus
  • 5,059
46
votes
10 answers

Is swap an anachronism?

I've used unix for quite a while, and for the last couple years I've felt like swap is an anachronism, but I'd be curious what other folks think. My argument is roughly this (assuming no global ulimit or twiddling of OOM settings): There is little…
36
votes
4 answers

What is the purpose of multiple swap files

During installation of most (if not all) distro's of linux, the hard drive is partitioned to include a swap partition by default. It is possible to change this behavior with swapon -p priority According to the man pages, the priority…
spuder
  • 18,053
23
votes
9 answers

When is swap file harmful?

In discussions about swap files ("should I create one?") I often see an obscure mention along the lines "in certain situations swap file can do more harm than good". That comes up often in conjunction with "if you have X GB of RAM or more you don't…
Peregrino69
  • 2,417
17
votes
6 answers

Does changing of the swappiness need a reboot?

If I configure the swappiness value to another, from ex.: 60 to 0, then I always need to reboot the machine to the changes to take effect? Even when modifying with: sysctl -w vm.swappiness=0
evachristine
  • 2,613
15
votes
4 answers

Where to put swap space, at beginning or end and other swap questions

Where do I put my swap? Debian installation gives 2 choices: (1) at the end or (2) at the beginning of the disk space. What is optimal? What is the optimal amount of swap given my computer has 512Mb RAM? Should I have more than one swap? Should…
ptrcao
  • 5,635
6
votes
1 answer

How to resize swap file in CentOS 7

I see a number of explanations referring to resizing swap partitions; however, I cannot find one that explains how to "resize" an existing swap file. My existing /swapfile1 is 512 MB. I want to increase it to 1 GB. Is it simpler to create a new swap…
adam
  • 161
6
votes
2 answers

Why does Linux need swap space in a VM?

Linux VM running nginx (or any other light-weight daemon with stable resource usage). VM is allocated 2GB of memory with 200-300MB used by OS and services with the rest for file cache and buffers. In one specific use-case I expect an easy 500MB…
virullius
  • 1,146
  • 2
  • 10
  • 19
6
votes
1 answer

How can I tell how much my system is swapping?

Is there a good way to see how much my system (for example how frequently, how much swap space it is using each time/ on average) is using the swap space during various tasks?
5
votes
2 answers

Why does Linux write to swap space even if the system has available storage while copying a big file to somewhere?

I have been noticing that if I copy a file to some storage device (the system's HDD, SSD, or to a thumbdrive) a small amount of data (20 - 30 MB) is written to the swap space - and the count increases. Yes, even the systems have available…
15 Volts
  • 2,069
5
votes
1 answer

How do I remove a swap partition that no longer exists?

I had a swap partition on a hard drive (/dev/sdb3), which eventually failed. The drive was removed and replaced. A new swap was created, fstab updated, and turned on (/dev/sdc3), but the old swap still is listed in /proc/swaps, but with…
Paul
  • 371
4
votes
1 answer

Swap partition vs swap file in ubuntu

I am a new linux user switched from windows 10. I have installed ubuntu 20.04.1 lts. I have swap file available in my system. Is it better to use swap partition instead of swap file? Thanks in advance!
4
votes
3 answers

Linux swap file creation and management

I want to increase my swap size to be able to have the hibernate option. First, I tried to add some swapfile. I followed https://bogdancornianu.com/change-swap-size-in-ubuntu/ and typed this in my terminal: sudo dd if=/dev/zero of=swapfile bs=1G…
Frank Wang
  • 43
  • 1
  • 4
4
votes
1 answer

Expand the size of swap partition

I did some partition size expansions of my centOs system and recover boot loader and file system successfully.I also changed the location and expanded the swap (5GB to 8GB) partition along with above deeds. Now the file system looks like this. …
PrazSam
  • 153
1
2 3