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.

Filter by
Sorted by
Tagged with
192 votes
4 answers
255k views

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's user avatar
  • 5,595
173 votes
9 answers
166k views

Why use swap when there is more than enough free space in RAM?

Using swap space instead of RAM can drastically slow down a PC. So why, when I have more than enough RAM available, does my Linux system (Arch) use the swap? Checkout my conky output below: Also, ...
Stefan's user avatar
  • 25.2k
122 votes
3 answers
71k views

Why is swappiness set to 60 by default?

I just read some stuff about swappiness on Linux. I don't understand why the default is set to 60. According to me this parameter should be set to 10 in order to reduce swap. Swap is on my hard ...
Hugo's user avatar
  • 2,429
104 votes
4 answers
46k views

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 ...
maaartinus's user avatar
  • 5,049
100 votes
13 answers
61k views

Do I need swap space if I have more than enough amount of RAM?

From what I understand, the purpose of a swap partition in Linux is to free up some "not as frequently accessed" information from RAM and move it to a specific partition on your harddrive (at the cost ...
IQAndreas's user avatar
  • 10.3k
75 votes
6 answers
144k views

How to safely turn off swap permanently and reclaim the space? (on Debian Jessie)

I installed Debian Jessie with default partitioning on my SSD drive. My current disk partitioning looks like this: As I have 16GB of RAM, I assume I don't need swap. But since I have other disk ...
Vlastimil Burián's user avatar
75 votes
6 answers
22k views

What NOT to put on an SSD?

I bought an SSD and I am going to set up my desktop system with a completely fresh Linux installation. SSDs are known to be fast, but they have a disadvantage: The number of writes (per block?) is ...
user41961's user avatar
  • 753
71 votes
3 answers
70k views

I can't enable Swap space on CentOS 7

So I'm following a tutorial to install OTRS which is Open source Ticket Request System. So in order to install, it requires: 4GB of Swap space. Here's the command I used: [root@ip-10-0-7-41 ~]# df -h ...
The One's user avatar
  • 4,822
59 votes
3 answers
36k views

Are there any side effects when two distros share a swap partition?

In order to save disk space, I want to have two OS installations share a single swap partition (a dual-boot). Is this a good idea?
tshepang's user avatar
  • 65.5k
56 votes
6 answers
8k views

How do I use swap space for emergencies only?

I have a Debian (Buster) laptop with 8 GB RAM and 16GB swap. I'm running a very long running task. This means my laptop has been left on for the past six days while it churns through. While doing ...
Philip Couling's user avatar
48 votes
14 answers
12k views

What specifically can swap do that RAM can't?

What specifically can Linux do when it has swap that it can't without swap? For this question I want to focus on the difference between for example, a Linux PC with 32 GB RAM and no swap vs. a ...
Philip Couling's user avatar
48 votes
2 answers
51k views

Docker -- WARNING: No swap limit support

I'm running Docker(1.9.1) on Ubuntu 16.04. When I run docker info the last line of the output says WARNING: No swap limit support. INFO[0781] GET /v1.21/info Containers: ...
Stephen C's user avatar
  • 825
46 votes
10 answers
4k views

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 ...
synthesizerpatel's user avatar
38 votes
3 answers
15k views

What does the vm.swappiness parameter really control?

Per the kernel documentation: This control is used to define how aggressive the kernel will swap memory pages. Higher values will increase aggressiveness, lower values decrease the amount of swap. ...
phemmer's user avatar
  • 71.7k
36 votes
4 answers
27k views

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 ...
spuder's user avatar
  • 18k
36 votes
1 answer
37k views

Swap partition in LVM?

I was wondering if putting the swap partition into a logical volume group has any drawbacks (e.g. performance), or would it be "just the same" as having it as a separate primary/logical partition? I ...
Levite's user avatar
  • 493
36 votes
2 answers
15k views

How to set per process swapiness for linux?

/proc/sys/vm/swappiness is nice, but I want a knob that is per process like /proc/$PID/oom_adj. So that I can make certain processes less likely than others to have any of their pages swapped out. ...
Dan D.'s user avatar
  • 603
36 votes
5 answers
6k views

Making Linux read swap back into memory

The Linux kernel swaps out most pages from memory when I run an application that uses most of the 16GB of physical memory. After the application finishes, every action (typing commands, switching ...
drrossum's user avatar
  • 472
34 votes
5 answers
16k views

Why does Linux use a swap partition rather than a file?

It seems to me a swap file is more flexible.
Cheng's user avatar
  • 6,621
34 votes
6 answers
66k views

How to completely disable swap?

I am using Debian sid, hard drive formatted with ext4, running on linux 3.1 I remember on previous linux versions (maybe before 3.0), if I run out of memory, and swap is not enabled, programs will ...
syockit's user avatar
  • 753
34 votes
1 answer
31k views

What sets the size of tmpfs? What happens when its full?

What sets the size of the tmpfs? (On my machine it resides in /dev/shm) I can see its entry in /etc/fstab, but no notation of its size. When checking with df -h, it seems to be half the size of the ...
Bichoy's user avatar
  • 3,106
31 votes
12 answers
7k views

How can I tweak my Linux desktop to be more responsive?

I have the experience that Linux works fine until the physical memory is exhausted. As soon as swap space is used the performance is severely degraded and the GUI becomes unresponsive. This problem ...
txwikinger's user avatar
  • 2,216
30 votes
2 answers
10k views

Is it possible to trigger OOM-killer on forced swapping?

Is it possible to have the system preemptively swap out inactive pages (vm.swappiness), but invoke the oom-killer when the system runs out of RAM (as opposed to running out of memory) and is forced to ...
phemmer's user avatar
  • 71.7k
28 votes
3 answers
5k views

Is the "page-to-disk" feature Linus talks about in his autobiography essentially the concept of swapping we use today?

In his autobiography, Just for Fun, Linus mentions the "page-to-disk" feature that was pivotal in making Linux a worthy competitor to Minix and other UNIX clones of the day: I remember that,...
computronium's user avatar
25 votes
2 answers
1k views

Is this how Linux paging should behave?

When my Linux system gets close to paging (i.e., in my case, 16GB ram almost full, 16GB swap completely empty) if a new process X tries to allocate some memory the system completely locks. That is, ...
John Terragon's user avatar
23 votes
9 answers
10k views

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 ...
Peregrino69's user avatar
  • 2,415
23 votes
1 answer
34k views

How to test swap partition

I'm trying to diagnose some random segfaults on a headless server and one thing that seems curious is that they only seem to happen under memory pressure and my swap size will not go above 0. How can ...
joshperry's user avatar
  • 463
22 votes
6 answers
14k views

Can Linux "run out of RAM"?

I saw several posts around the web of people apparently complaining about a hosted VPS unexpectedly killing processes because they used too much RAM. How is this possible? I thought all modern OS' ...
themirror's user avatar
  • 6,968
22 votes
4 answers
22k views

How to re-load all running applications from swap space into RAM?

If my desktop run out of memory and swaps a lot then I free or kill the application wasting my RAM. But, after that, all my desktop/applications have been swapped and are horribly slow, do you know a ...
profy's user avatar
  • 373
21 votes
1 answer
25k views

swapon: Operation not permitted

I'm running this as root, obviously. I've created a file called /swap/sw1, by dumping 512 megs of /dev/zero into it. I then ran mkswap, which said: Setting up swapspace version 1, size = 524284 KiB ...
configurator's user avatar
20 votes
2 answers
38k views

How to find the swap uuid

I am in the process of setting up a raid. sda was used during the installation and I just copied the partition table of sda to sdb like so: $ sudo sfdisk -dL /dev/sda > partition_table_sda $ sudo ...
mulllhausen's user avatar
  • 2,668
19 votes
2 answers
10k views

What 'sw' means in the fstab swap entry for 'mount options' column

In my /etc/fstab file I have an entry for my swap as follows: /root/swap swap swap sw 0 0 I have other machines and also I've seen online that sometimes they put default or xfs or other options. ...
VaTo's user avatar
  • 3,101
19 votes
2 answers
4k views

how to check what is in swap?

On my system i have some amount of swap used: undefine@uml:~$ free total used free shared buffers cached Mem: 16109684 15848264 261420 633496 ...
undefine's user avatar
  • 1,410
18 votes
2 answers
10k views

Linux: Total swap used = swap used by processes +?

So, I'm trying to do some investigation on where does swap use come from in a system with high swap usage: # free total used free shared buffers cached Mem: ...
ninj's user avatar
  • 189
18 votes
3 answers
16k views

What is the appropriate value of vm.swappiness when using zram?

I'm using zram on my computer as a compressed RAM-backed swap. When the system needs to swap something out, swapping it to a zram-backed swap file is more or less equivalent to compressing that data ...
Ryan C. Thompson's user avatar
17 votes
6 answers
30k views

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's user avatar
  • 2,613
17 votes
3 answers
44k views

How to configure swappiness in Linux Memory Management?

The swappiness parameter controls the tendency of the kernel to move processes out of physical memory and onto the swap disk. What is the default setting and how to configure that to improve overall ...
GAD3R's user avatar
  • 66.4k
17 votes
2 answers
27k views

What does it mean exactly when a processes "Time" has stopped in top?

I'll be looking into why we're getting critical swap alerts, and I'll find something like: PID USER PR NI VIRT RES SHR S %CPU %MEM TIME+ SWAP COMMAND 14683 user1 30 10 16.0g 772m ...
CptSupermrkt's user avatar
  • 1,492
17 votes
3 answers
18k views

How do I set up an encrypted swap file in Linux?

2017 WARNING! The accepted answer appears to work, but with recent kernels I discovered that the system would hang as soon as it started swapping. If you attempt using an encrypted swap file, make ...
cjm's user avatar
  • 27.1k
17 votes
3 answers
9k views

How can I create a swap file?

I know how to create and use a swap partition but can I also use a file instead? How can I create a swap file on a Linux system?
Vlastimil Burián's user avatar
17 votes
2 answers
20k views

How do I increase the maximum swap space on Mac OS X?

On Mac OS X Yosemite 10.10.5, when I try to run a calculation that needs to allocate and use 128 GB of memory (it is a command line program written in C), the kernel kills my process with extreme ...
Mark Adler's user avatar
  • 1,995
16 votes
3 answers
13k views

Dynamically growing swap file on Debian

I know how to create a swap file and use it as swap. But I have to configure the size of the file beforehand and the space is used on the disk, if the swap is used or not. How do I create a swap that ...
rubo77's user avatar
  • 28.8k
16 votes
1 answer
12k views

How to make tmpfs to use only the physical RAM and not the swap?

How to be sure that a tmpfs filesystem can only deal with physical and it's not using a swap partition on disk? Since I have a slow HDD and a fast RAM, I would like, at least, giving higher priority ...
user1717079's user avatar
16 votes
1 answer
28k views

Guide on how to enable hibernation on Linux Mint 20 Cinnamon (Ubuntu 20) and prevent unwanted wakeups

How can I enable hibernation on Linux Mint 20 Cinnamon (Ubuntu 20) and prevent unwanted wakeups?
Texno's user avatar
  • 181
15 votes
3 answers
29k views

What command can be used to force release everything in swap partition back to memory?

What command can be used to force release everything in swap partition back to memory ? Presume that I have enough memory.
daisy's user avatar
  • 54.4k
15 votes
2 answers
4k views

Does Linux perform "opportunistic swapping", or is it a myth?

Suppose a program asks for some memory, but there is not enough free memory left. There are several different ways Linux could respond. One response is to select some other used memory, which has ...
sourcejedi's user avatar
15 votes
4 answers
10k views

Swap: Better to create a dedicated swap partition or to create a swap file?

Is there a rationale when to create a dedicated swap partition vs. creating a swap file, for example like /tmp/swap? In my certain case, memory is kind of low (1GB), disk space on a SSD is pretty huge ...
CarstenP's user avatar
  • 309
15 votes
4 answers
44k views

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 ...
ptrcao's user avatar
  • 5,595
14 votes
4 answers
3k views

Silent disk errors and reliability of Linux swap

My understanding is that hard drives and SSDs implement some basic error correction inside the drive, and most RAID configurations e.g. mdadm will depend on this to decide when a drive has failed to ...
James Johnston's user avatar
14 votes
1 answer
21k views

"cryptsetup: ERROR: Couldn't resolve device" combined with "cryptsetup: WARNING: target 'sda3_crypt' not found in /etc/crypttab"

After setting up hibernation on ubuntu 20.04 and modifying it that it works for encrypted swap partitions, I'm getting several issues: First, after rebooting from hibernation, I got "Gave up ...
Andreas L.'s user avatar

1
2 3 4 5
14