65 votes
Accepted

prevent system freeze/unresponsiveness due to swapping run away memory usage

TL;DR Short answer Easiest: Use a newer Linux release where systemd-oomd became part of systemd in the 2nd half of 2020. Otherwise, have a smaller swap partition and avoid the kernel trying to live ...
JPvRiel's user avatar
  • 1,571
34 votes
Accepted

Deleted a partition, now getting 'Gave up waiting for suspend/resume device' message during boot

I just encountered that same error message on Debian and a similar boot delay, with a slight variation: I knew that I had just voluntarily deleted my swap partition, and didn't plan to recreate it. ...
jmr's user avatar
  • 526
25 votes

How to create swapfile on ssd disk with btrfs

As mentioned above, since Linux 5.0 it is now possible to create swap files on BTRFS. But they should be non-compressed and NoCOW. Here is how do you actually create such a file: Create an empty file:...
MarSoft's user avatar
  • 431
20 votes
Accepted

Should I use a SSD or HDD for "swap" on an old computer

SSD is definitely a steroid to any system. Even machines already sentenced to scrap are revived by it. On the other hand, factory specifications really state that their statistical lifetime is smaller ...
user556625's user avatar
  • 4,190
16 votes

Swapon failed: Invalid argument on a Linux system with Btrfs filesystem

In Linux kernel 5.0.0, btrfs natively supports swapfile now. (You must set it as no-COW) Here's some information from kernel.org: https://btrfs.wiki.kernel.org/index.php/FAQ#...
recolic's user avatar
  • 559
16 votes

Is it possible to create a swap file for a Linux guest VM managed by Vagrant?

Simply add this line to your vagrant file Vagrantfile # Enable Dynamic Swap Space to prevent Out of Memory crashes config.vm.provision "shell", inline: "sudo apt install swapspace -y" And then ...
Jonathan's user avatar
  • 1,742
15 votes
Accepted

What kswapd is doing when there is no swap

Many processes have memory that is backed by a file. This data can be swapped to the file even if you don't have swap space. See: AskUbuntu » Why is kswapd0 running on a computer with no swap?
Zaz's user avatar
  • 2,506
15 votes

What is faster: Intel's Optane SSD or RAM?

1 s(second) = 1000 ms(millisecond) 1 ms(millisecond) = 1000 μs(microsecond) 1 μs(microsecond) = 1000 ns(nanosecond) DRAM: 200 ns 3D Xpoint: 7 μs (7000 ns) enterprise NVMe PCIe SSD: 30 μs (30,000 ...
Neel's user avatar
  • 251
15 votes

Deleted a partition, now getting 'Gave up waiting for suspend/resume device' message during boot

Because of the message Gave up waiting for suspend/resume device I suspect a problem with your swap partition. Check if your system uses swap by running swapon. Next run swapon -a and observe the ...
Kamil Maciorowski's user avatar
13 votes

Should I use a SSD or HDD for "swap" on an old computer

Your question states speed is not a factor, but resources are. In this case, HDDs give you far greater GBs for your money than any SSD on the market currently. If you're after pure resource, HDDs ...
Jonno's user avatar
  • 21.2k
11 votes

What is the exact difference between the parameters (pgpgin, pswpin) and (pswpout, pgpgout) in /proc/vmstat?

So old question and no correct answer so far. First of all, memory is segmented by CPU and Kernel into so called pages. Size of page is given by architecture of CPU, many architectures support ...
Petr's user avatar
  • 2,331
11 votes

How to check Paging Memory on swap for Windows, via command line?

try this: systeminfo | find "Virtual Memory" this will return: Virtual Memory: Max Size: 17.297 MB Virtual Memory: Available: 7.186 MB Virtual Memory: In Use: 10.111 MB here is my powershell ...
manuel 's user avatar
  • 231
11 votes

How to stop a Linux process for later execution swapping-out its memory

You might look into a technique called checkpoint/restore. This will allow you to take a running process and save its state to a set of files, then restore it at a later time. To use it, start by ...
virtex's user avatar
  • 1,289
10 votes

Swapon failed: Invalid argument on a Linux system with Btrfs filesystem

I got the cryptic error now after an unclean shutdown. The only solution was to delete the old swapfile and recreate it. As on btrfs, there are certain restrictions (e.g. copy-on-write has to be ...
Philipp Claßen's user avatar
9 votes
Accepted

How to create swapfile on ssd disk with btrfs

Status in 2019 The development of Btrfs and Linux kernel rendered my original answer obsolete. Please see this other answer. Original answer from 2016 From btrfs FAQ: Does btrfs support swap ...
Kamil Maciorowski's user avatar
8 votes

How to create swapfile on ssd disk with btrfs

Swap file support has been added to kernel version 5.0 as can be seen at commit https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/?id=ed46ff3d423780fa5173b38a844bf0fdb210a2a7 ...
arvati's user avatar
  • 81
7 votes

How permanently change Linux swap disk priority

It looks like the pri parameter set to -1 in /etc/fstab (default value by the way) doesn't affect the priority reported by swapon. To make it work, you have to change for a bigger number (like 1). ...
Sandburg's user avatar
  • 155
7 votes

How to create swapfile on ssd disk with btrfs

In Linux 5.0 or later: file='/swapfile' # create file touch "$file" # No Copy-on-Write chattr +C "$file" # Allocate 10 GB (much faster than dd) fallocate -l 10G "$file" #...
Ole Tange's user avatar
  • 4,789
7 votes
Accepted

Check which processes are eating swap on Linux?

Run top Press f to select displayed fields Navigate down to SWAP using arrow keys Hit Space - SWAP will become preceded by asterisk * Press right arrow key - this will allow you to move SWAP to a ...
Peregrino69's user avatar
  • 4,652
6 votes

How permanently change Linux swap disk priority

Yes, but trying to set a negative priority doesn't work; we are only allowed to use positive numbers. To tell the system to use a given swap partition or file before another one, assign a larger ...
JimBobHarris's user avatar
6 votes

Modify Windows "Swappiness"

There's more to virtual memory than just "apps allocating RAM and when physical RAM runs out, something gets paged out to SWAP". In Linux (and possibly UNIX at large), the system tries to keep pages ...
frr's user avatar
  • 273
6 votes

Where does VIM (gvim/macvim) keep swap files for unsaved/unnamed buffers?

I work on Windows 10 and :recover didn't find a swap file. vim -r listed the swap file from the last edit session (also never saved) named _.swp. Recovering was possible with :recover _.
rolacher's user avatar
6 votes
Accepted

Is it safe to share a swap partition with more than one Linux OS?

Yes as long as you don't try anything weird such as hibernating one OS, then booting directly into another and expecting no issues. (One version of hibernation will save the ram directly into the swap ...
djsmiley2kStaysInside's user avatar
6 votes
Accepted

Force a process to only use swap memory?

So is there a way in Linux to force a single process to only use memory in swap space? (without having to implement a custom allocator) No, this is not possible. The process cannot run on the swap; ...
Tomas's user avatar
  • 7,399
5 votes

How do I quickly stop a process that is causing thrashing (due to excess memory allocation)?

What is the quickest way to regain control of a Linux system that has become nonresponsive or extremely sluggish due to excessive swapping? Already answered above with Alt-SysRq-F Is there ...
JPvRiel's user avatar
  • 1,571
5 votes

Should I use a SSD or HDD for "swap" on an old computer

The big question is "Does this support AHCI" - which you'll need for maximum performance and things like trim to work. Even without it, an SSD is faster than a spinning rust drive - but its less of a ...
Journeyman Geek's user avatar
  • 129k
4 votes
Accepted

Is it possible to create a swap file for a Linux guest VM managed by Vagrant?

The memory setting you see is only used to configure the VM's RAM. However, the swap space definition is part of the disk image. This image is provided to you as part of the config.vm.box definition ...
C-Otto's user avatar
  • 216
4 votes
Accepted

swapoff failed: Invalid argument

swapoff tells you swapoff failed: Invalid argument when the device is already not being used for swap. Example: deltik@node51 [~]$ sudo swapoff /dev/zero swapoff: /dev/zero: swapoff failed: Invalid ...
Deltik's user avatar
  • 19.6k
4 votes
Accepted

Hibernation without swap enabled

Disabling swap when you already know that your system can get to the point when it won't have enough memory is a bad idea. Right at the moment when kernel doesn't have any memory to allocate your ...
yakrobat's user avatar
  • 127
4 votes

Explain `fstab` swap syntax

You can specify the priority in fstab: /dev/sda2 none swap sw,pri=30 0 0 /dev/sdb2 none swap sw,pri=20 0 0 /dev/sdc2 none swap sw,pri=10 0 0 By default, each ...
Joe's user avatar
  • 906

Only top scored, non community-wiki answers of a minimum length are eligible